test(v4): stop redos tests failing on CPU contention - #6360
Open
irfanfandi wants to merge 1 commit into
Open
Conversation
Both tests in redos.test.ts decided pass/fail from wall-clock timing, so load from parallel test files flipped them. The file failed in 2 of 6 full-suite runs on a clean main and passed every time it ran alone. The pattern sweep treated any non-"safe" status as a failure. "unknown" only means the checker gave up, and recheck's fuzz checker derives "vulnerable" from how long an attack string runs, so the verdict tracked available CPU rather than the pattern. Ignore "unknown" and re-confirm a "vulnerable" verdict with a generous attackTimeout before failing; a genuinely exponential pattern exhausts any budget, so detection is unchanged. The emoji test asserted a 100ms budget on a single cold call, which sat in JIT noise given the pattern matches in ~0.2ms. Warm up, take the best of three, and allow 500ms.
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.
Fixes #6359.
Both tests in
redos.test.tsdecide pass/fail from wall-clock timing, so CPU contention from parallel test files flips them. Onead9fcb3the file failed in 2 of 6 full-suite runs and passed every time it ran alone, which also makes the pre-push hook reject unrelated pushes.no built-in pattern is ReDoS-vulnerabletreated any non-safestatus as a failure.unknownonly means the checker gave up, andrecheck's fuzz checker derivesvulnerablefrom how long an attack string runs — so the verdict tracks available CPU rather than the pattern. SqueezingattackTimeoutreproduces it on an idle machine, non-monotonically:The flagged patterns are fine — matched against adversarial input they scale linearly and stay under a millisecond out to 6.4KB. So this now ignores
unknownand re-confirms avulnerableverdict with a generous budget before failing. A genuinely exponential pattern exhausts any budget, so detection is unchanged:^(a+)+$,^(a|a)*$,^([a-zA-Z0-9]+)*@x$and^(\w+\s?)*$are all still caught.emoji rejects a backtracking payload in linear timeasserted a 100ms budget on a single cold call. The fixed pattern matches that payload in ~0.2ms and stays flat out to 200 emoji, so the threshold sat in JIT and scheduler noise while the regression it guards against took ~1.9s. It now warms up, takes the best of three, and allows 500ms — still three orders of magnitude below the exponential case.