Query: percent-decoded NUL silently truncates parameter names and values

Open
#753 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start with src/net/http/query.c, especially url_decode() and cwist_query_map_parse() around the linked lines. Trace how query names and values are decoded and how duplicate keys are handled, then add coverage for encoded NUL in both positions and duplicate-key handling. Done means decoded NULs produce HTTP 400 without silently truncating query data.

Written by the indexing model from the issue text.

Description

bug

Confirmed on dev at fd8cf045770459ebc0f6b6740f54dcd30a80ce6c.

url_decode() accepts %00 and writes the decoded NUL into a C string. All subsequent map operations then treat that byte as the end of the key or value, silently truncating attacker-controlled input.

Source: https://github.com/c4punks/CWIST/blob/fd8cf045770459ebc0f6b6740f54dcd30a80ce6c/src/net/http/query.c#L263-L312

Reproduction:

cwist_query_map_parse(map, "role=user%00admin&next=ok");
role=user next=ok

The raw query still contains role=user%00admin, while the application map sees role=user. WAF rules, signatures, authorization checks, and application handlers can therefore make different security decisions on the same request.

Reject decoded NUL bytes in query names and values with HTTP 400 rather than silently truncating them. Add coverage for encoded NUL in both positions and for duplicate-key handling.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 54m
Merged PRs (30d)
185

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.