Skip to content

Enforce the 1,000-field object limit in validate-findings.cjs - #111

Open
MohitRawat017 wants to merge 2 commits into
cloudflare:mainfrom
MohitRawat017:fix/107-findings-object-field-limit
Open

MohitRawat017 wants to merge 2 commits into
cloudflare:mainfrom
MohitRawat017:fix/107-findings-object-field-limit

Conversation

@MohitRawat017

Copy link
Copy Markdown

Fixes #107. Implements the resolution proposed there by @Inkesk-Dozing — thanks for the detailed analysis and the precise diff suggestions, which this follows closely.

What was missing

validate-coverage-ledger.cjs bounds object property cardinality both pre-parse (token scan in preflightJsonText) and post-parse (preflightDocument), but validate-findings.cjs had no object-field bound at all: a findings payload within the 5 MiB input limit but with hundreds of thousands of keys passed enforceJsonTextLimits, forced a large dictionary allocation in JSON.parse, and drove an unthrottled Object.keys loop in validate().

Changes (validate-findings.cjs)

  • LIMITS gains objectFields: 1000, matching the coverage-ledger validator.
  • enforceJsonTextLimits now counts object fields pre-parse: object containers carry a fields counter and an expectsKey flag (set on { and on , inside an object, mirroring the existing expectsItem array pattern), so a string that opens a key position increments the count and a >1000-field object is rejected with input exceeds 1000 field object limit before JSON.parse is ever called. String/escape handling is unchanged — keys containing {, ,, " or escapes are not miscounted.
  • collectDataLimitErrors rejects parsed objects with more than 1000 keys (${location}: exceeds 1000 object fields), mirroring preflightDocument in the ledger validator.
  • validate() stops iterating object keys once the error cap (LIMITS.validationErrors) is reached.
  • validate-findings.test.cjs: alignment test now expects the shared objectFields limit; new tests for pre-parse CLI rejection, the exactly-1000 boundary (passes the scanner, fails schema validation instead), and post-parse rejection.
  • Docs: the validator limit sentences in VALIDATION-AND-REPORTING.md and RECONNAISSANCE.md now state the 1,000-fields-per-object bound (the ledger one was already enforced but undocumented).

Verification

  • node --test on both test files: 68 pass, 0 fail (65 pre-existing + 3 new; baseline on main was 65/65).
  • Boundary probes: exactly 1000 fields passes the scanner; 1001 fields (plain, duplicate raw keys, nested-in-array, whitespace-heavy, key placed in the last bytes of a 1 MiB payload) all rejected pre-parse with exit 1 and no exception trace. Objects with ≤1000 fields each — nested or across 1000 array items — are not rejected.
  • Differential fuzz (74 generated documents with hostile keys/values, plus raw-duplicate-key and boundary cases): the limit fires if and only if some object exceeds 1000 fields; no other parse failures introduced.
  • A valid findings document produces byte-identical output and exit code on main and this branch.
  • Hostile payload benchmark (4.85 MiB, one object with 400,000 keys, Node 22, 3 runs): main ~770-805 ms wall-clock per run (rejected only at schema validation after the full parse); this branch 27-30 ms (indistinguishable from Node startup; rejected pre-parse). Happy path unchanged (~26-29 ms on both).

Notes for reviewers

  • The pre-parse counting is a small extension of the existing single-pass scanner rather than a port of the ledger validator's fuller state machine, to keep the two files' existing styles.
  • Happy to rework anything; and @Inkesk-Dozing if your own patch is further along, equally happy to close this in favor of yours.

Ports the object-field cardinality defenses from
validate-coverage-ledger.cjs so both validators reject objects with
more than 1,000 fields before JSON.parse and on the parsed document,
and stops schema validation iteration once the error cap is reached.

Fixes cloudflare#107
athallajovian9-cyber added a commit to JovianOps/security-audit-skill that referenced this pull request Oct 26, 2026
coffeegrind123 added a commit to coffeegrind123/security-audit-skill that referenced this pull request Nov 11, 2026
Upstream main has not moved since 2026-09-14, but 79 pull requests are
open. Each was read at the diff level, tested in its own worktree, and
checked for conflicts; the best of each duplicate group is ported.

Validators: cloudflare#143 archived verifier owner reuse, cloudflare#87 shared artifacts
within one attempt, cloudflare#102/cloudflare#103 duplicate JSON keys, cloudflare#111 1,000-field
objects, cloudflare#127 ordinary class must match assignment, cloudflare#104 self-excluded
ordinary block, cloudflare#141 verbatim quotes checked with --target, cloudflare#45 line
upper bound, cloudflare#84 --terminal rejects open units, cloudflare#145 identity-checked
open on Windows (POSIX still fails closed), cloudflare#48 retained-artifact
check (skills/ part only). Overlapping changes were merged so both
behaviours and both test sets survive.

Method: cloudflare#125 critic reasons through handoff, cloudflare#132 deployment controls
become units, cloudflare#83 carried-record gates, cloudflare#93 abort cleanup, cloudflare#23
streaming tool calls, cloudflare#50 config-dependent reachability stays
needs_validation, cloudflare#58 sequential verifier fallback, cloudflare#96 verifier no
longer sees the hunter's verdict, severity or fix.

Execution safety (cloudflare#76 neutralized git, symlink-safe copies; cloudflare#95
sanitized repo ID and prior-run compatibility; cloudflare#108 untrusted-content
prompt block; cloudflare#129 isolation built beside the host) moves into
EXECUTION-SAFETY.md so SKILL.md stays under its token budget.

Companions: cloudflare#101 cryptography, cloudflare#116 Android, cloudflare#35 edge isolate state.

Skipped: duplicates (cloudflare#82 cloudflare#106 cloudflare#91 cloudflare#70 cloudflare#138 cloudflare#131 cloudflare#75 cloudflare#63 cloudflare#97 cloudflare#123 cloudflare#25
cloudflare#26 cloudflare#16 cloudflare#40 cloudflare#42 cloudflare#142), validator-weakening fallbacks (cloudflare#59 cloudflare#113 cloudflare#99),
README/LICENSE churn, rebrands, scope creep, and cloudflare#85 cloudflare#90 cloudflare#8 cloudflare#89 cloudflare#32.

UPGRADE.md records this sync procedure.

Co-authored-by: Rohankollabathula67 <rohankollabathula67@gmail.com>
Co-authored-by: lab 1207 <hajarevaibhav527@gmail.com>
Co-authored-by: Rudy Celekli <rudy@gradiahq.com>
Co-authored-by: Mohit Rawat <rawatmohit17906@gmail.com>
Co-authored-by: MAHER AL-AQIL <18458259+maqalaqil@users.noreply.github.com>
Co-authored-by: CodeInf <jiuqiaoy@gmail.com>
Co-authored-by: pucedoteth <119044801+pucedoteth@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
Co-authored-by: Pizo <pizofreude@proton.me>
Co-authored-by: ZhiHe-ma <302089060+ZhiHe-ma@users.noreply.github.com>
Co-authored-by: shivam <juyaljii610@gmail.com>
Co-authored-by: Dante <duanjl.china@gmail.com>
Co-authored-by: Francisco <francisco@theysay.me>
Co-authored-by: Roman Dolgov <alter@users.noreply.github.com>
Co-authored-by: bodapatisaikrishna <saikrishnabodapati@gmail.com>
Co-authored-by: alvessh <117163985+alvessh@users.noreply.github.com>
Co-authored-by: itinance <hhuebel@itinance.com>
Co-authored-by: ChoYugyeong <cho4639@gmail.com>
Co-authored-by: Shaun Liebenberg <shaun@liebies.co.za>
Co-authored-by: JAI <jai19kharb@gmail.com>
Co-authored-by: ghostzeronz-coder <ghostzeronz-coder@users.noreply.github.com>
Co-authored-by: Aman Mohamed Ali <69119173+spidervirus@users.noreply.github.com>
Co-authored-by: Sandeep.dhami <sandeep84397@gmail.com>
Co-authored-by: jastfan <duohello640@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asymmetric parser hardening: validate-findings.cjs lacks pre-parse and in-memory objectFields limits, exposing parent workflow to key-amplification DoS

1 participant