Description
The product saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by a spreadsheet product.
Potential Impact
Confidentiality
Read Application Data, Execute Unauthorized Code or Commands
Demonstrative Examples
=HYPERLINK(link_location, [friendly_name])HYPERLINK(link_location, [friendly_name])Mitigations & Prevention
When generating CSV output, ensure that formula-sensitive metacharacters are effectively escaped or removed from all data before storage in the resultant CSV. Risky characters include '=' (equal), '+' (plus), '-' (minus), and '@' (at).
If a field starts with a formula character, prepend it with a ' (single apostrophe), which prevents Excel from executing the formula.
Certain implementations of spreadsheet software might disallow formulas from executing if the file is untrusted, or if the file is not authored by the current user.
Detection Methods
- 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 sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2019-12134 | Low privileged user can trigger CSV injection through a contact form field value |
| CVE-2019-4521 | Cloud management product allows arbitrary command execution via CSV injection |
| CVE-2019-17661 | CSV injection in content management system via formula code in a first or last name |
Related Weaknesses
Frequently Asked Questions
What is CWE-1236?
CWE-1236 (Improper Neutralization of Formula Elements in a CSV File) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when...
How can CWE-1236 be exploited?
Attackers can exploit CWE-1236 (Improper Neutralization of Formula Elements in a CSV File) to read application data, execute unauthorized code or commands. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-1236?
Key mitigations include: When generating CSV output, ensure that formula-sensitive metacharacters are effectively escaped or removed from all data before storage in the resultant CSV. Risky characters include '=' (equal), '+
What is the severity of CWE-1236?
CWE-1236 is classified as a Base-level weakness (Medium abstraction). It has been observed in 3 real-world CVEs.