[codex] Harden input sanitization#296
Closed
lisamariet wants to merge 1 commit into
Closed
Conversation
Drop prototype-polluting keys recursively, return null-prototype sanitized objects, and bound traversal for oversized payloads. Add focused tests for JSON-parsed pollution keys and middleware behavior.
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
sanitizeValue()against nested prototype-pollution payloads by dropping__proto__,constructor, andprototypekeys recursively.Why
Issue #284 asks for deeper prototype-pollution protection in request sanitization before downstream handlers build filters or spread request data. The previous sanitizer removed some dangerous keys, but it still returned regular objects and did not cap array/object traversal.
Validation
npx jest src/utils/sanitization.test.js src/middleware/sanitizeInput.test.js --runInBand --forceExitnpx eslint src/utils/sanitization.js src/utils/sanitization.test.js src/middleware/sanitizeInput.js src/middleware/sanitizeInput.test.jsgit diff --check HEAD~1..HEADBaseline note
Full
npm testand fullnpm run lintcurrently fail on unrelated pre-existing repository baseline issues outside this patch. The focused sanitizer tests and focused ESLint checks above pass.