Skip to content

Fix CodeQL ReDoS and XSS alerts - #3598

Merged
velo merged 1 commit into
masterfrom
fix/codeql-alerts
Oct 5, 2026
Merged

velo merged 1 commit into
masterfrom
fix/codeql-alerts

Conversation

@velo

@velo velo commented Oct 5, 2026

Copy link
Copy Markdown
Member

Fixes the four open CodeQL code-scanning alerts on master.

#14 Inefficient regular expression (Expressions.java): in VARIABLE_LIST_PATTERN, the :.* modifier can match commas, and the repeated (,item)* group matches them too. An input like $,$: + ,$:×n + \n has exponentially many ways to split before it fails. The pattern is now "any number of name*?, items, then a final name(:.*|*)?", with possessive quantifiers and non-capturing groups, so each character can be matched only one way. The pattern is only used with matches() and no groups are read.

  • Same results as the old pattern on 3,000,000 random strings, on Java 8 and Java 25.
  • Java 8, adversarial input with n = 24: 3559 ms before, about 8 µs after.
  • ExpressionsTest.variableListPatternDoesNotBacktrackExponentially checks a 100,000-repeat input within 2 s. On Java 21 the old pattern is fast too, so this test guards against future changes; the Java 8 timings above are the evidence for the fix.

#17, #18, #19 Cross-site scripting (form-spring test Server.java): upload1, upload2 and upload3 echo request data back without a response type, so it could be served as HTML. They now declare produces = TEXT_PLAIN_VALUE. The Feign client sends no Accept header for these calls, so the tests don't change.

Tests: core 741 (4 skipped), form-spring 9, all passing.

…ng test server

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
@velo
velo enabled auto-merge October 5, 2026 11:52
@velo
velo merged commit 6cd2846 into master Oct 5, 2026
4 checks passed
@velo
velo deleted the fix/codeql-alerts branch October 5, 2026 12:05
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.

1 participant