Why it matters
The caller can supply a pattern that backtracks for minutes on a short input (ReDoS).
How to fix it
Escape the value with Regex.escape when it is meant literally.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
@RestController
class SearchController {
@GetMapping("/search")
fun search(@RequestParam q: String, @RequestParam text: String): Boolean = Regex(q).containsMatchIn(text)
}@RestController
class SearchController {
@GetMapping("/search")
fun search(@RequestParam q: String, @RequestParam text: String): Boolean =
Regex(Regex.escape(q)).containsMatchIn(text)
}What TrustIvan reads
Runs on repository scans of Kotlin source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Expression injection from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-expression-injection - Header injection from request input (Kotlin)
KotlinSeverity: Medium
trustivan-kotlin-taint-header-injection - XPath injection from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-xpath-injection - SQL string template (Kotlin)
KotlinSeverity: Medium
trustivan-kotlin-sql-string-template - LDAP injection from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-ldap-injection - Weak hash (Kotlin)
KotlinSeverity: Medium
trustivan-kotlin-weak-hash
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation