Repository navigation
fix(tests): make ReDoS guard assert cost scaling, not wall-clock (#13907) - #14039
Merged
Merged
Conversation
) The property test asserted an absolute 250ms ceiling on sanitizeErrorMessage() for adversarial inputs. That ceiling had no margin over the pipeline's real fixed cost (3x redact + 2x normalize passes added by #12506), so it failed on cost under any machine load, not on backtracking. Replace it with a check that the sanitizer's cost does not scale with input length beyond a generous noise allowance, which is what a bounded-backtracking guarantee actually claims; keep a coarse absolute hang ceiling as a backstop.
Collaborator
Author
|
Validated in local merge-train /tmp/mt-train3b.log on 192.168.0.113 @ train tip 408e2128791696a18966681953136fc96aeb99b0 (32 PRs boarded): static gates green; full test:unit 40694 tests, 17 failing — every one reproduces on the pure release tip (base-red sweep list), zero new reds. Merged --admin per merge-gates §4/§7. |
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…aper-inference#13907) (cheaper-inference#14039) The property test asserted an absolute 250ms ceiling on sanitizeErrorMessage() for adversarial inputs. That ceiling had no margin over the pipeline's real fixed cost (3x redact + 2x normalize passes added by cheaper-inference#12506), so it failed on cost under any machine load, not on backtracking. Replace it with a check that the sanitizer's cost does not scale with input length beyond a generous noise allowance, which is what a bounded-backtracking guarantee actually claims; keep a coarse absolute hang ceiling as a backstop.
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.
Closes #13907
Root cause
tests/unit/correctness/sanitizers.property.test.tsasserted an absolute 250mswall-clock ceiling for
sanitizeErrorMessage()on adversarial inputs (1,000–20,000chars). That ceiling had no margin over the sanitizer's real fixed cost: the input is
truncated to
MAX_ERROR_LEN + MAX_ERROR_SCAN_HEADROOM(4096 + 512 = 4608 chars), thenrun through 3x
redactSensitiveErrorText(redactErrorPaths(stripStackTail(...)))interleaved with 2x
normalizeSecurityEscapes(open-sse/utils/errorSanitization.ts:696-705,added by #12506). That layered pipeline's fixed per-call cost is what the assertion was
timing, not backtracking — there is no catastrophic backtracking here, so the test failed
on ordinary CI/machine load rather than on any real ReDoS regression.
Fix
Replaced the fixed-ms assertion with a check on the actual security property: the
sanitizer's cost must not scale with adversarial input size beyond a generous
noise-tolerant allowance (baseline is a median of small-input runs; the allowance is
baseline * 100 + 1000ms), plus a coarse 5s absolute "did it hang forever" backstop keptonly as a secondary check. A real superlinear/exponential ReDoS blows past this by orders
of magnitude regardless of machine load; ordinary fixed-cost regex work never gets close.
No production code was touched — this is a test-only fix per the plan's recommended
Option A. Option B (optimizing the sanitizer's fixed pipeline cost) is explicitly
deferred as a separate, security-boundary-sensitive change.
Regression test — RED → GREEN
tests/unit/correctness/sanitizers.property.test.tstoo slow: 317.066339ms for len=1000(also reproduced pre-existing at 440-643ms in the triage plan-file's own probe run).
box (load average ~72 from many parallel CI/agent processes during validation):
Gates run
node scripts/check/check-file-size.mjs— no violation on the touched file (onepre-existing, unrelated violation on
tests/unit/chatcore-translation-paths.test.ts,not touched by this PR).
node scripts/check/check-complexity.mjs— OK (2857 violations vs baseline 3218).node scripts/check/check-cognitive-complexity.mjs— OK (1291 violations vs baseline 1437).npm run typecheck:core— exit 0.npx eslint --suppressions-location config/quality/eslint-suppressions.json tests/unit/correctness/sanitizers.property.test.ts— clean.node --import tsx/esm --test tests/unit/correctness/sanitizers.property.test.ts— green,run 4 times to confirm stability under load.
node scripts/check/check-changelog-integrity.mjs— OK.Base-red
Scope
Test-only change (
tests/unit/correctness/sanitizers.property.test.ts) plus a changelogfragment. No production code touched.