Why it matters
The caller can run script in another user's browser.
How to fix it
Render through a template engine that escapes by default (Thymeleaf th:text, kotlinx.html), or encode with HtmlUtils.htmlEscape first.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
fun Application.greet() {
routing {
get("/hello") {
val name = call.request.queryParameters["name"]
call.respondText("<h1>Hello $name</h1>", ContentType.Text.Html)
}
}
}fun Application.greet() {
routing {
get("/hello") {
val name = HtmlUtils.htmlEscape(call.request.queryParameters["name"])
call.respondText("<h1>Hello $name</h1>", ContentType.Text.Html)
}
}
}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
- SSRF from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-ssrf - Deserialization from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-deserialization - Path traversal from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-path-traversal - Open redirect from request input (Kotlin)
KotlinSeverity: Medium
trustivan-kotlin-taint-open-redirect - Command injection from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-command-injection - LDAP injection from request input (Kotlin)
KotlinSeverity: High
trustivan-kotlin-taint-ldap-injection
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