fix: harden codexcli-mcp converters against prototype pollution and add regression tests#1630
Merged
dyoshikawa merged 3 commits intoMay 14, 2026
Merged
Conversation
…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
…mat with isRecord, and add prototype-pollution regression tests
- Replace raw console.warn in codexcli-mcp.ts with warnWithFallback so the
single allow-listed no-console site in src/utils/logger.ts is reused and
test stderr stays clean.
- Add isRecord(config) guard in convertToCodexFormat for symmetry with
convertFromCodexFormat (defends against non-object server entries when
validation is skipped).
- Add four regression tests proving the PROTOTYPE_POLLUTION_KEYS filter
works:
* outbound: __proto__/constructor/prototype as server-name keys are
stripped and Object.prototype is not polluted
* outbound: __proto__/constructor/prototype as config-key level are
stripped
* outbound: __proto__ in nested env is stripped via removeEmptyEntries
* inbound: __proto__ server-name keys are stripped by
convertFromCodexFormat during toRulesyncMcp() round-trip
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
@dyoshikawa-claw Thank you! |
Merged
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)