Repository navigation
fix(insurance): cap and sanitize vendor values echoed in decode errors - #337
Conversation
A rejected enum value is echoed only when it is a short identifier ([A-Za-z0-9_.-], up to 32 bytes); otherwise the error reports its length. Tests cover every validated enum site through full decode. Closes #336 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 3 billable files and costs up to $0.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 42 minutes for your next included review. View limit details
Comment |
|
Gate review (Opus, independent) at 91f9a7a: CHANGES REQUESTED (test strength only; production code is correct). Verified (local,
F1 (blocking, test gap): 3 regex mutants SURVIVE (
Suggested fix (test only), e.g. in assert.Equal(t, "(19 bytes, not shown)", describeVendorValue("abc\nIGNORE PREVIOUS"))
assert.Equal(t, "(4 bytes, not shown)", describeVendorValue("ab\x1bc"))
assert.Equal(t, "(5 bytes, not shown)", describeVendorValue("ab"))
assert.Equal(t, "(3 bytes, not shown)", describeVendorValue(`a"b`))(check the byte counts; the point is a short value with a newline / control / bidi / quote char.) N1 (non-blocking, from the cli #2166 gate F1): decode errors are built in N2 (non-blocking, pre-existing, documented): |
…entifiers Withheld cases: embedded and trailing newline, control char, bidi override, quote, space, NUL, plus a newline-prefixed 300-byte payload through decode. Kills the (?m), \S and quote-in-class regex mutants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Gate verdict (Opus, independent) at 90ef448: APPROVED, merging.
|
Closes #336
Decode errors for rejected enum values (payment option, term, term reason, plan status, provider) used
%qon the raw vendor string, so a hostile response could put an arbitrarily long, attacker-chosen string into an error that consumers print or return to an LLM.describeVendorValue: echoes the value only when it matches^[A-Za-z0-9_.-]{1,32}$(a new vendor enum value stays visible to the operator); otherwise reports(N bytes, not shown).unsupported valuesites use it.invalid decimal<= 64B,%.20qnumber check, JSON syntax error quotes one character, client.go request errors echo caller input). A comment notes a future int/float wire field would echo the number literal.Verification (local, fixture-based, not a live vendor call):
TestDecode_RejectedEnumValueIsBoundedAndSanitized: 8 comparison fields plus plan status with a 300+ byte control-character prompt-injection value through full decode; asserts error < 256 bytes, no injected text/control chars, and that a benign identifier is still echoed.%qat each of the 5 sites and removing the identifier check (6 mutants) each fail the suite.golangci-lint run ./...andgo test ./...in pkg pass (GOTOOLCHAIN=go1.26.9).🤖 Generated with Claude Code