Commit 37204a7
committed
BUG/MINOR: sample: reject a \0 byte in url_dec, json_query and jwt_*_query
A string sample cannot contain a \0 byte by design: this is what
distinguishes it from a binary sample, and every consumer relies on it.
Yet url_dec decoded "%00" to a \0, json_query decoded "\u0000" to one,
and jwt_header_query/jwt_payload_query could return one from the base64
decoded JSON. Such a sample was then matched by "-m str" on its prefix
only, so "/public%00/admin" matched "/public" and an allow-list could be
bypassed.
Commit 442f583 ("BUG/MINOR: pattern: do not match a string with an
embedded \0 on its prefix") worked around it in pat_match_str(), which
is the wrong place since such a string must not exist at all.
This commit reverts it and fixes the producers instead: url_decode() now
fails on "%00" like it does on an invalid sequence, and json_query and
jwt_*_query fail on a decoded \0. This is also cheaper, as the string
is checked once where it is produced instead of on every call to
pat_match_str().
This must be backported to all stable branches, in place of 442f583
where it was not yet backported.1 parent 209c027 commit 37204a7
3 files changed
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | 502 | | |
510 | 503 | | |
511 | 504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4703 | 4703 | | |
4704 | 4704 | | |
4705 | 4705 | | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
4706 | 4710 | | |
4707 | 4711 | | |
4708 | 4712 | | |
| |||
4967 | 4971 | | |
4968 | 4972 | | |
4969 | 4973 | | |
| 4974 | + | |
| 4975 | + | |
| 4976 | + | |
| 4977 | + | |
4970 | 4978 | | |
4971 | 4979 | | |
4972 | 4980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2654 | 2654 | | |
2655 | 2655 | | |
2656 | 2656 | | |
2657 | | - | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2658 | 2662 | | |
2659 | 2663 | | |
2660 | 2664 | | |
| |||
0 commit comments