CWE-93 Base Brouillon

Improper Neutralization of CRLF Sequences ('CRLF Injection')

This vulnerability occurs when an application uses carriage return and line feed characters (CRLF) to structure data, like separating lines or records, but fails to properly sanitize these sequences…

Définition

What is CWE-93?

This vulnerability occurs when an application uses carriage return and line feed characters (CRLF) to structure data, like separating lines or records, but fails to properly sanitize these sequences from user-supplied input before processing.
CRLF injection, often called 'HTTP Response Splitting' in web contexts, happens because attackers can inject the characters \r\n (CRLF) into input fields. When this unsanitized input is later used to construct structured outputs like HTTP headers, log files, or email headers, the injected characters can create new lines or entries. This allows attackers to manipulate the application's behavior, forge log entries, or inject malicious content that other users might see. To prevent this, developers must rigorously validate and sanitize all user-controlled data that influences output formatting. This involves encoding or stripping CRLF sequences (\r, \n, and their encoded equivalents like %0d%0a) before the data is used in any context where these characters have special meaning, such as HTTP responses, generated files, or system commands.
Vulnerability Diagram CWE-93
CRLF Injection / HTTP Response Splitting Input contains value\r\nSet-Cookie: a=b HTTP Response Set-Header: value ↳ \r\n ← splits headers Set-Cookie: a=b \r\n\r\n <injected body> Browser sees 2 responses / fake page CR/LF chars forge new headers or split response bodies.
Impact réel

Real-world CVEs caused by CWE-93

  • CRLF injection enables spam proxy (add mail headers) using email address or name.

  • CRLF injection in API function arguments modify headers for outgoing requests.

  • Spoofed entries in web server log file via carriage returns

  • Chain: inject fake log entries with fake timestamps using CRLF injection

  • Chain: Application accepts CRLF in an object ID, allowing HTTP response splitting.

  • Chain: HTTP response splitting via CRLF in parameter related to URL.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    The following code segment reads the name of the author of a weblog entry, author, from an HTTP request and sets it in a cookie header of an HTTP response.

  2. 2

    Assuming a string consisting of standard alpha-numeric characters, such as "Jane Smith", is submitted in the request the HTTP response including this cookie might take the following form:

  3. 3

    However, because the value of the cookie is composed of unvalidated user input, the response will only maintain this form if the value submitted for AUTHOR_PARAM does not contain any CR and LF characters. If an attacker submits a malicious string, such as

  4. 4

    then the HTTP response would be split into two responses of the following form:

  5. 5

    The second response is completely controlled by the attacker and can be constructed with any header and body content desired. The ability to construct arbitrary HTTP responses permits a variety of resulting attacks, including:

Exemple de code vulnérable

Vulnerable Java

The following code segment reads the name of the author of a weblog entry, author, from an HTTP request and sets it in a cookie header of an HTTP response.

Vulnérable Java
String author = request.getParameter(AUTHOR_PARAM);
  ...
  Cookie cookie = new Cookie("author", author);
  cookie.setMaxAge(cookieExpiration);
  response.addCookie(cookie);
Charge utile de l'attaquant

However, because the value of the cookie is composed of unvalidated user input, the response will only maintain this form if the value submitted for AUTHOR_PARAM does not contain any CR and LF characters. If an attacker submits a malicious string, such as

Charge utile de l'attaquant
Wiley Hacker\r\nHTTP/1.1 200 OK\r\n
Exemple de code sécurisé

Secure pseudo

Sécurisé pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-93

  • Implementation Avoid using CRLF as a special sequence.
  • Implementation Appropriately filter or quote CRLF sequences in user-controlled input.
Signaux de détection

How to detect CWE-93

Automated Static Analysis High

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-93 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-93 ?

This vulnerability occurs when an application uses carriage return and line feed characters (CRLF) to structure data, like separating lines or records, but fails to properly sanitize these sequences from user-supplied input before processing.

Quelle est la gravité de CWE-93 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

Quels langages ou plateformes sont affectés par CWE-93 ?

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir CWE-93 ?

Avoid using CRLF as a special sequence. Appropriately filter or quote CRLF sequences in user-controlled input.

Comment Plexicus détecte et corrige CWE-93 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-93 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-93 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/93.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-93

CWE-74 Parent

Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')

This vulnerability occurs when an application uses untrusted external input to build a command, query, or data structure for another…

CWE-1236 Frère

Improper Neutralization of Formula Elements in a CSV File

This vulnerability occurs when an application writes user-supplied data into a CSV file without properly sanitizing special characters.…

CWE-75 Frère

Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)

This vulnerability occurs when an application fails to properly filter or encode user-supplied data containing special characters or…

CWE-77 Frère

Improper Neutralization of Special Elements used in a Command ('Command Injection')

This vulnerability occurs when an application builds a system command using untrusted user input without properly sanitizing it. An…

CWE-78 Frère

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

OS Command Injection occurs when an application builds a system command using untrusted, external input without properly sanitizing it.…

CWE-79 Frère

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

This vulnerability occurs when a web application fails to properly sanitize or encode user-supplied input before displaying it on a…

CWE-88 Frère

Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')

This vulnerability occurs when an application builds a command string for execution by another component, but fails to properly separate…

CWE-89 Frère

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

SQL Injection occurs when an application builds a database query using untrusted user input without properly sanitizing it. This allows an…

CWE-91 Frère

XML Injection (aka Blind XPath Injection)

XML Injection occurs when an application fails to properly validate or escape user-controlled input before including it in XML documents…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.