CVE-2024-56140 Bypass of CSRF Middleware in Astro
Attackers can bypass CSRF protections in Astro when origin checks are enabled, allowing unauthorized state-changing requests.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2024-56140?
CVE-2024-56140 is a medium-severity vulnerability in withastro astro, published on 18 Dec 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Official description
Astro is a web framework for content-driven websites. In affected versions a bug in Astro’s CSRF-protection middleware allows requests to bypass CSRF checks. When the `security.checkOrigin` configuration option is set to `true`, Astro middleware will perform a CSRF check. However, a vulnerability exists that can bypass this security. A semicolon-delimited parameter is allowed after the type in `Content-Type`. Web browsers will treat a `Content-Type` such as `application/x-www-form-urlencoded; abc` as a `simple request` and will not perform preflight validation. In this case, CSRF is not blocked as expected. Additionally, the `Content-Type` header is not required for a request. This issue has been addressed in version 4.16.17 and all users are advised to upgrade. There are no known workarounds for this vulnerability.
Weakness: CWE-352
Which versions are affected by CVE-2024-56140?
2 open source packages ship an affected version, including astro. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
astro npm | All versions | 4.16.17 |
astro npm | All versions | 4.16.17 |
Products include Astro Astro.
How do I fix CVE-2024-56140?
Upgrade astro to 4.16.17 or later.
Is CVE-2024-56140 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-56140 exists.
Other vulnerabilities in withastro astro
- CVE-2024-56159 Server source code is exposed to the public if sourcemaps are enabled
- CVE-2026-54299 Astro: Host header SSRF in prerendered error page fetch
- CVE-2025-59837 astro allows bypass of image proxy domain validation leading to SSRF and potential XSS
- CVE-2026-50146 Astro: Reflected XSS via unescaped slot name
- CVE-2025-64764 Astro is vulnerable to Reflected XSS via the server islands feature
Sources
Also known as GHSA-c4pw-33h3-35xw.