Sec/lens4 headers#459
Open
fredbi wants to merge 3 commits into
Open
Conversation
…allbacks The runtime delegates credential comparison to caller-supplied authentication callbacks (UserPassAuthentication, TokenAuthentication, ScopedTokenAuthentication, and their Ctx variants). Callers that compare a secret against a known value must use crypto/subtle.ConstantTimeCompare to avoid response-timing side-channels. This commit: - Documents the contract on all six callback type godocs. - Updates the apikey and basic auth examples to demonstrate the safe pattern, so users copying the snippets inherit it. No API change. The runtime itself does not compare secrets and remains structurally timing-safe. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
RFC 7231 §5.3.1 defines qvalue as a fraction in [0, 1]: when the leading digit is "1", the only valid decimal portion is "0", "00" or "000". expectQuality previously accepted inputs like "1.1" or "1.9" verbatim and returned values > 1, letting a malformed Accept entry artificially boost its priority above all properly-formed offers. The fix surfaces the malformed input via the existing q < 0 sentinel; ParseAccept and ParseAccept2 inherit the rejection. Found by FuzzParseAccept (lens 4 of the security scrub). The "0;q=1.1" minimised input is persisted under testdata/fuzz/ as a regression seed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Lands seven fuzz targets covering the header-parsing surface of the security scrub (lens 4): - runtime.ContentType - mediatype.Parse / mediatype.MatchFirst / mediatype.ParseAccept - negotiate/header.parseValueAndParams / ParseAccept / ParseList Each target carries a seed corpus of edge cases (malformed quoting, multi-byte sequences, oversized inputs, invalid q-values, trailing-semicolon and comma anomalies) plus per-target invariants (non-zero MediaType only on success; Q in [0,1]; non-empty params keys; no empty list entries). CI auto-discovers FuzzXxx via the shared go-test-monorepo workflow. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
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.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist