Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.
Reliance on Cookies without Validation and Integrity Checking in a Security Decision
This vulnerability occurs when an application makes security decisions—like granting access or verifying identity—based solely on cookie data without first confirming the cookie's authenticity or…
What is CWE-784?
Real-world CVEs caused by CWE-784
-
Attacker can bypass authentication by setting a cookie to a specific value.
-
Attacker can bypass authentication and gain admin privileges by setting an "admin" cookie to 1.
-
Content management system allows admin privileges by setting a "login" cookie to "OK."
-
e-dating application allows admin privileges by setting the admin cookie to 1.
-
Web-based email list manager allows attackers to gain admin privileges by setting a login cookie to "admin."
Angreiferpfad Schritt für Schritt
- 1
The following code excerpt reads a value from a browser cookie to determine the role of the user.
- 2
The following code could be for a medical records application. It performs authentication by checking if a cookie has been set.
- 3
The programmer expects that the AuthenticateUser() check will always be applied, and the "authenticated" cookie will only be set when authentication succeeds. The programmer even diligently specifies a 2-hour expiration for the cookie.
- 4
However, the attacker can set the "authenticated" cookie to a non-zero value such as 1. As a result, the $auth variable is 1, and the AuthenticateUser() check is not even performed. The attacker has bypassed the authentication.
- 5
In the following example, an authentication flag is read from a browser cookie, thus allowing for external control of user state data.
Vulnerable Java
The following code excerpt reads a value from a browser cookie to determine the role of the user.
Cookie[] cookies = request.getCookies();
for (int i =0; i< cookies.length; i++) {
Cookie c = cookies[i];
if (c.getName().equals("role")) {
userRole = c.getValue();
}
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-784
- Architecture and Design Avoid using cookie data for a security-related decision.
- Implementation Perform thorough input validation (i.e.: server side validation) on the cookie data if you're going to use it for a security related decision.
- Architecture and Design Add integrity checks to detect tampering.
- Architecture and Design Protect critical cookies from replay attacks, since cross-site scripting or other attacks may allow attackers to steal a strongly-encrypted cookie that also passes integrity checks. This mitigation applies to cookies that should only be valid during a single transaction or session. By enforcing timeouts, you may limit the scope of an attack. As part of your integrity check, use an unpredictable, server-side value that is not exposed to the client.
How to detect CWE-784
Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.
Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.
Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.
Plexicus erkennt CWE-784 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.
Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.
Frequently asked questions
Was ist CWE-784?
This vulnerability occurs when an application makes security decisions—like granting access or verifying identity—based solely on cookie data without first confirming the cookie's authenticity or integrity.
Wie gravierend ist CWE-784?
MITRE stuft die Exploit-Wahrscheinlichkeit als hoch ein — diese Schwachstelle wird aktiv in freier Wildbahn ausgenutzt und sollte priorisiert behoben werden.
Welche Sprachen oder Plattformen sind von CWE-784 betroffen?
MITRE lists the following affected platforms: Web Based.
Wie kann ich CWE-784 verhindern?
Avoid using cookie data for a security-related decision. Perform thorough input validation (i.e.: server side validation) on the cookie data if you're going to use it for a security related decision.
Wie erkennt und behebt Plexicus CWE-784?
Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-784 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.
Wo erfahre ich mehr über CWE-784?
MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/784.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.
Weaknesses related to CWE-784
Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.
Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.