Why it matters
A line break in the value can add headers or split the response.
How to fix it
Validate the value against a strict pattern (no CR or LF) or choose the header value from a fixed set held by the server.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
using Microsoft.AspNetCore.Mvc;
public class LangController : Controller
{
public IActionResult Set(string lang)
{
Response.Headers["Content-Language"] = lang;
return Ok();
}
}using Microsoft.AspNetCore.Mvc;
public class LangController : Controller
{
public IActionResult Set(string lang)
{
Response.Headers["Content-Language"] = lang == "fr" ? "fr" : "en";
return Ok();
}
}What TrustIvan reads
Runs on repository scans of C# 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
- Template injection from request input (C#)
C#Severity: High
trustivan-csharp-taint-template-injection - SQL string concatenation (C#)
C#Severity: Medium
trustivan-csharp-sql-string-concatenation - NoSQL injection from request input (C#)
C#Severity: High
trustivan-csharp-taint-nosql-injection - BinaryFormatter use (C#)
C#Severity: High
trustivan-csharp-binaryformatter-use - Code injection from request input (C#)
C#Severity: High
trustivan-csharp-taint-code-injection - Json type name handling (C#)
C#Severity: High
trustivan-csharp-json-type-name-handling
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