Trust Boundary Violation
ID |
scala.cookie.scala_cookie_rule_trustboundaryviolation |
Severity |
low |
Resource |
Cookie |
Language |
Scala |
Description
A trust boundary can be thought of as line drawn through a program. On one side of the line, data is untrusted. On the other side of the line, data is assumed to be trustworthy. The purpose of validation logic is to allow data to safely cross the trust boundary - to move from untrusted to trusted. A trust boundary violation occurs when a program blurs the line between what is trusted and what is untrusted. By combining trusted and untrusted data in the same data structure, it becomes easier for programmers to mistakenly trust unvalidated data.
Rationale
A trust boundary can be thought of as line drawn through a program. On one side of the line, data is untrusted. On the other side of the line, data is assumed to be trustworthy. The purpose of validation logic is to allow data to safely cross the trust boundary - to move from untrusted to trusted. A trust boundary violation occurs when a program blurs the line between what is trusted and what is untrusted. By combining trusted and untrusted data in the same data structure, it becomes easier for programmers to mistakenly trust unvalidated data.
The following code illustrates a vulnerable pattern detected by this rule:
def setSessionAttributeNameTainted(req: HttpServletRequest): Unit = {
val input = req.getParameter("input")
// VULNERABLE: Trust Boundary Violation
req.getSession.setAttribute(input, "true")
}
Remediation
Follow secure coding practices and review the references below for detailed remediation guidance.
References
-
OWASP Top 10 2021 - A01 : Broken Access Control.