Skip to content

Commit dbd3964

Browse files
jbachorikclaude
andcommitted
fix(extension): make isValidClassName regex non-backtracking
The class-name validation pattern in EmbeddedExtensionRepository used ambiguous quantifiers where the inner character class allowed '$' and the outer group matched '$'-prefixed segments. On input like 'A$A$A$A' with a trailing mismatch, the engine explored exponentially many partitions (CodeQL js/redos, alert #15). Switch the three repetitions to possessive quantifiers (`*+`) so each commit step is final. Semantics are preserved for all accepted and rejected class names (verified against SecurityValidationTest). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e74a6e3 commit dbd3964

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

btrace-extension/src/main/java/org/openjdk/btrace/extension/impl/EmbeddedExtensionRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ static boolean isValidClassName(String className) {
281281
}
282282
// Basic validation: must be a valid Java identifier pattern
283283
// Allows: package.Class, package.Class$Inner
284-
return className.matches("^[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_$]*)*(\\$[a-zA-Z_][a-zA-Z0-9_$]*)*$");
284+
return className.matches(
285+
"^[a-zA-Z_][a-zA-Z0-9_]*+(\\.[a-zA-Z_][a-zA-Z0-9_$]*+)*+(\\$[a-zA-Z_][a-zA-Z0-9_$]*+)*+$");
285286
}
286287

287288
/**

0 commit comments

Comments
 (0)