REDHAT-BUG-2488480: CRLF Injection
form-data is a library for creating readable multipart/form-data streams. In versions through 4.0.5, the field argument to FormData#append and the filename option are concatenated verbatim into the Content-Disposition header without escaping carriage return (CR), line feed (LF), or double-quote (") characters. An application that passes attacker-controlled data as a field name or filename (for example, an API gateway that turns JSON object keys into multipart field names) allows the attacker to terminate the header line and inject additional headers, or to smuggle entire additional multipart parts, into the request the application forwards to a backend. This can let the attacker add or override form fields (e.g. set isadmin=true) seen by the downstream parser. This is an instance of CWE-93 (CRLF injection). The fix escapes CR, LF, and " as %0D, %0A, and %22 in field names and filenames, matching the serialization browsers use per the WHATWG HTML multipart/form-data encoding algorithm. Exploitation requires the consuming application to use untrusted input as a field name or filename; applications that use only fixed/trusted field names are not affected. Fixed in 2.5.6, 3.0.5, and 4.0.6.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
form-datato a version that resolves this vulnerability.Fixed in 2.5.6 - Upgrade
Upgrade
form-datato a version that resolves this vulnerability.Fixed in 3.0.5 - Upgrade
Upgrade
form-datato a version that resolves this vulnerability.Fixed in 4.0.6 - Configuration
Upgrade to a fixed form-data version so that the `field` argument to `FormData#append` and the `filename` option escape CR, LF, and `"` when generating the multipart `Content-Disposition` header (unfixed versions through 4.0.5 concatenate these values verbatim).
form-data (FormData#append field / filename option) Escaping of field names and filenames in Content-Disposition = Escape CR as %0D, LF as %0A, and double-quote (") as %22 (rather than concatenating verbatim) - Compensating control
Ensure consuming applications do not pass untrusted input as a multipart form-data field name or filename; only use fixed/trusted field names and filenames when calling `FormData#append`. (This specific issue requires attacker-controlled values in those parameters.)