fix: redact received payload values from response validation errors#121
Merged
Merged
Conversation
Closes the unmet LIB-7 acceptance criterion requiring a fast-check property test for abort-signal composition. Verifies that for any ordering of timeout/upstream aborts, the combined signal aborts exactly once with the first reason. Runs in ~130ms (200 runs), well under 1s. No production code changed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Valibot's default issue messages embed the raw received value (e.g. `Expected number but received "hunter2-SECRET"`). Since validated payloads can carry secrets (passwords, tokens, child PII) that Librus echoes back, `LibrusResponseValidationError.details.issues` could leak them. Rebuild each issue summary from the `Invalid <label>:` prefix and `issue.expected` only, never `issue.received`. Add a guard test asserting no summary contains the crafted secret substrings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Summary
summarizeIssuesinsrc/sdk/validation/responseValidation.tsbuilt error strings straight from Valibot's default issue messages, which embed the raw received value — e.g.password: Invalid type: Expected number but received "hunter2-SECRET". Since validated payloads can carry secrets (passwords, tokens, child PII) that the Librus server echoes back,LibrusResponseValidationError.details.issuescould leak them.Flagged as a "mild secret-adjacent risk" in
.tasks/rearchitect/08-test-coverage.mdand confirmed empirically while working LIB-7. Kept out of LIB-7 because that task was tests-only / no production changes.Change
redactReceivedValue, which rebuilds each issue summary from theInvalid <label>:prefix andissue.expectedonly — both schema-derived — and never includesissue.received. Chosen over regex-stripping thereceived …suffix because it can't miss the no-expectedmessage form (Invalid type: Received null). No schema undersrc/sdk/validation/sets a custommessage:, so all messages follow Valibot's defaultInvalid <label>:shape.{ password: "hunter2-SECRET", token: "Bearer-LEAK" }againstv.object({ password: v.number(), token: v.number() })and asserting no issue summary contains either secret.Verification
vitest run test/responseValidation.truncation.test.ts— 7/7 pass (6 existing + 1 new).tsc --noEmitandeslintclean. Existing format/truncation tests unaffected.🤖 Generated with Claude Code