fix(parser): quote-aware element skip + strict duplicate-q rejection#55
Open
eilandert wants to merge 1 commit into
Open
fix(parser): quote-aware element skip + strict duplicate-q rejection#55eilandert wants to merge 1 commit into
eilandert wants to merge 1 commit into
Conversation
Second-pass audit follow-ups on the Accept-Encoding parser and its tests.
Correctness (medium): the element-skip in ngx_http_zstd_accept_encoding()
was not quoted-string aware, while eval_qvalue()'s value-skip (just made
quote-aware) was. A quoted comma inside a non-q parameter therefore split
the element and fabricated a phantom coding token, e.g.
Accept-Encoding: gzip;x="a, zstd";q=1 -> accepted zstd (wrong)
Both skip sites now route through a single ngx_http_zstd_skip_quoted()
helper (RFC 9110 §5.6.4 quoted-string, honoring quoted-pair escapes,
strictly length-bounded). eval_qvalue() also rejects a repeated "q"
parameter (RFC 9110 §12.4.2 permits at most one weight).
Fuzzing: fuzz/extract_parser.sh now also slices the new helper. The
reference oracle in fuzz_accept_encoding.c learns simple (no-escape)
quoted-string parameters so it is confident on the quoted-comma class it
previously skipped, and bails to "unsure" on stray quotes in name/token
positions so it never disagrees with the production parser on malformed
input. Six curated NN_ corpus seeds cover the quoted/dup-q cases.
Verified: 3.5M ASan+UBSan runs clean, no oracle divergence.
Tests: t/00-filter.t TEST 68 asserts the zstd_bypass identity arm (predicate
fires -> identity response that still carries Vary, the cache-poisoning case
TEST 66 omitted).
Repo hygiene: untrack t/servroot-static/ (Test::Nginx working dir that was
committed despite the .gitignore rule).
CI: clang-tidy now gates on the low-FP security/cert checks
(--warnings-as-errors) while keeping bugprone/unix advisory.
Both modules compile clean under -Wall -Wextra -Werror with and without
-DZSTD_STATIC_LINKING_ONLY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second-pass audit follow-ups on the Accept-Encoding parser and its tests.
Correctness (medium)
The element-skip in
ngx_http_zstd_accept_encoding()was not quoted-string aware, whileeval_qvalue()'s value-skip was. A quoted comma inside a non-qparameter split the element and fabricated a phantom coding token:Both skip sites now route through a single
ngx_http_zstd_skip_quoted()helper (RFC 9110 §5.6.4 quoted-string, honoring quoted-pair escapes, strictly length-bounded).eval_qvalue()also rejects a repeatedqparameter (RFC 9110 §12.4.2 permits at most one weight).Client controls its own header, so this is correctness, not a security issue.
Fuzzing
fuzz/extract_parser.shslices the new helper into the standalone target.NN_corpus seeds for the quoted / dup-qcases.Tests
t/00-filter.tTEST 68 asserts thezstd_bypassidentity arm (predicate fires → identity response that still carriesVary, the cache-poisoning case TEST 66 omitted).Repo hygiene
Untrack
t/servroot-static/(Test::Nginx working dir committed despite the.gitignorerule).CI
clang-tidy now gates on the low-FP security/cert checks (
--warnings-as-errors) while keeping bugprone/unix advisory.Both modules compile clean under
-Wall -Wextra -Werrorwith and without-DZSTD_STATIC_LINKING_ONLY.