# CVE-2021-41270: CSV Injection in Symfony

> Attackers can execute arbitrary commands via CSV formula injection if the csv_escape_formulas option is not enabled or configured incorrectly.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Nov 2021
- **Updated:** 4 Aug 2024
- **Also known as:** BIT-symfony-2021-41270, DEBIAN-CVE-2021-41270, GHSA-2xhg-w2g5-w95x, UBUNTU-CVE-2021-41270

## What is CVE-2021-41270?

CVE-2021-41270 is a medium-severity vulnerability in Fedoraproject Fedora, published on 24 Nov 2021. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

Symfony/Serializer handles serializing and deserializing data structures for Symfony, a PHP framework for web and console applications and a set of reusable PHP components. Symfony versions 4.1.0 before 4.4.35 and versions 5.0.0 before 5.3.12 are vulnerable to CSV injection, also known as formula injection. In Symfony 4.1, maintainers added the opt-in `csv_escape_formulas` option in the `CsvEncoder`, to prefix all cells starting with `=`, `+`, `-` or `@` with a tab `\t`. Since then, OWASP added 2 chars in that list: Tab (0x09) and Carriage return (0x0D). This makes the previous prefix char (Tab `\t`) part of the vulnerable characters, and OWASP suggests using the single quote `'` for prefixing the value. Starting with versions 4.4.34 and 5.3.12, Symfony now follows the OWASP recommendations and uses the single quote `'` to prefix formulas and add the prefix to cells starting by `\t`, `\r` as well as `=`, `+`, `-` and `@`.

Weakness: CWE-1236 (Improper Neutralization of Formula Elements in a CSV File)

## Which versions are affected by CVE-2021-41270?

9 open source packages ship an affected version, including symfony/serializer, symfony and symfony/symfony. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `symfony/serializer` | Packagist | From 4.1.0 | 4.4.35 |
| `symfony/serializer` | Packagist | From 4.1.0 | 4.4.35 |
| `symfony/serializer` | Packagist | From 5.0.0 | 5.3.12 |
| `symfony/serializer` | Packagist | From 5.0.0 | 5.3.12 |
| `symfony` | Bitnami | From 4.1.0 | 4.4.35, 5.3.12 |
| `symfony/symfony` | Packagist | From 4.1.0 | 4.4.35 |
| `symfony/symfony` | Packagist | From 4.1.0 | 4.4.35 |
| `symfony/symfony` | Packagist | From 5.0.0 | 5.3.12 |
| `symfony/symfony` | Packagist | From 5.0.0 | 5.3.12 |

Products: Fedoraproject Fedora, Sensiolabs Symfony.

## How do I fix CVE-2021-41270?

Upgrade symfony/serializer to a fixed version for your release line: 4.4.35 or 5.3.12.

## Is CVE-2021-41270 being exploited?

There is no known exploitation of CVE-2021-41270 in the wild and no public exploit code.

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2024-4577](https://insights.sbomify.com/CVE-2024-4577/): PHP-CGI OS Command Injection (critical 9.8, exploited in the wild)
- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-41270 and fix it if it is affected.

What it is: CVE-2021-41270 is a medium-severity vulnerability in Fedoraproject Fedora, published on 24 Nov 2021. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-41270 in the wild and no public exploit code.

Affected packages and fixed versions:
- symfony/serializer (Packagist): affected from 4.1.0; fixed in 4.4.35
- symfony/serializer (Packagist): affected from 4.1.0; fixed in 4.4.35
- symfony/serializer (Packagist): affected from 5.0.0; fixed in 5.3.12
- symfony/serializer (Packagist): affected from 5.0.0; fixed in 5.3.12
- symfony (Bitnami): affected from 4.1.0; fixed in 4.4.35, 5.3.12
- symfony/symfony (Packagist): affected from 4.1.0; fixed in 4.4.35
- symfony/symfony (Packagist): affected from 4.1.0; fixed in 4.4.35
- symfony/symfony (Packagist): affected from 5.0.0; fixed in 5.3.12
- symfony/symfony (Packagist): affected from 5.0.0; fixed in 5.3.12

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-41270/ (Markdown: https://insights.sbomify.com/CVE-2021-41270/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-41270
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-41270
- OSV: https://osv.dev/vulnerability/CVE-2021-41270

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-41270/
Summaries are generated and may contain mistakes; the official description above is the record.
