fix: harden codexcli-mcp converters against prototype pollution and add regression tests#1630
Open
dyoshikawa-claw wants to merge 2 commits into
Open
fix: harden codexcli-mcp converters against prototype pollution and add regression tests#1630dyoshikawa-claw wants to merge 2 commits into
dyoshikawa-claw wants to merge 2 commits into
Conversation
added 2 commits
May 12, 2026 14:16
…dd regression tests
- Add PROTOTYPE_POLLUTION_KEYS skip for __proto__/constructor/prototype in
removeEmptyEntries, convertToCodexFormat, and convertFromCodexFormat
- Add isPlainObject guard to replace broad object type check, avoiding
misclassification of Date/Map/Set as empty plain objects
- Add isRecord type guard helper to replace as-casts
- Add MAX_REMOVE_EMPTY_ENTRIES_DEPTH (32) recursion depth cap
- Warn when a server entry collapses to empty after removeEmptyEntries
- Add TOML-string-level regression test asserting getFileContent() never
contains .env] for server with env: {}
- Add regression test for arrays-of-objects not recursed into
- Tighten test assertions: replace optional chaining with non-null
assertion after expect().toBeDefined()
Closes #1626
…ing, and improve depth warning - Import isRecord from shared utils/type-guards.js instead of local definition - Add PROTOTYPE_POLLUTION_KEYS guard for server names in both converters - Use Object.hasOwn instead of 'in' operator for accurate warning check - Warn when removeEmptyEntries depth cap is exceeded
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
Closes #1626
Security hardening
__proto__/constructor/prototypekeys inremoveEmptyEntries,convertToCodexFormat, andconvertFromCodexFormatto prevent prototype pollutionisPlainObjectguard to replace broadtypeof === 'object'check, avoiding misclassification of Date/Map/Set as empty plain objectsisRecordtype guard helper to replaceas-casts andeslint-disablecommentsRobustness
MAX_REMOVE_EMPTY_ENTRIES_DEPTH = 32) to prevent stack overflow on deeply nested inputremoveEmptyEntriesTest coverage
getFileContent()never contains.env]for server withenv: {}args: [{}])expect().toBeDefined()Related
removeEmptyEntriesrecursive)