# CVE-2025-24358: gorilla/csrf CSRF vulnerability due to broken Referer validation

> An attacker with XSS on a related domain can bypass CSRF protections to perform authenticated actions on Go web applications using this library.

- **Severity:** Medium 5.4 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N/E:P`)
- **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:** Yes
- **Published:** 15 Apr 2025
- **Updated:** 1 May 2025
- **Also known as:** CLEANSTART-2025-TT45966, DEBIAN-CVE-2025-24358, DLA-4151-1, GHSA-rq77-p4h8-4crw, GO-2025-3607, MINI-447g-8ffj-q7jp, MINI-8f68-757x-cwhr, MINI-fw5r-v3mw-g3cg, MINI-h932-7x25-m27r, MINI-jj73-c2w5-vhcp, MINI-jr5f-jr7q-rhqw, MINI-m24v-ghjg-wp3h, MINI-mrvj-r5fm-62x5, UBUNTU-CVE-2025-24358

## What is CVE-2025-24358?

CVE-2025-24358 is a medium-severity vulnerability in gorilla csrf, published on 15 Apr 2025. 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

gorilla/csrf provides Cross Site Request Forgery (CSRF) prevention middleware for Go web applications & services. Prior to 1.7.2, gorilla/csrf does not validate the Origin header against an allowlist. Its executes its validation of the Referer header for cross-origin requests only when it believes the request is being served over TLS. It determines this by inspecting the r.URL.Scheme value. However, this value is never populated for "server" requests per the Go spec, and so this check does not run in practice. This vulnerability allows an attacker who has gained XSS on a subdomain or top level domain to perform authenticated form submissions against gorilla/csrf protected targets that share the same top level domain. This vulnerability is fixed in 1.7.2.

Weakness: CWE-352 (Cross-Site Request Forgery)

## Which versions are affected by CVE-2025-24358?

3 open source packages ship an affected version, including github.com/gorilla/csrf.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/gorilla/csrf` | Go | All versions | 1.7.3 |
| `github.com/gorilla/csrf` | Go | All versions | 1.7.3 |
| `github.com/gorilla/csrf` | Go | All versions | 1.7.3 |

## How do I fix CVE-2025-24358?

Upgrade github.com/gorilla/csrf to 1.7.3 or later.

## Is CVE-2025-24358 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-24358 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-24358 and fix it if it is affected.

What it is: CVE-2025-24358 is a medium-severity vulnerability in gorilla csrf, published on 15 Apr 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-24358 exists.

Affected packages and fixed versions:
- github.com/gorilla/csrf (Go): affected all versions; fixed in 1.7.3
- github.com/gorilla/csrf (Go): affected all versions; fixed in 1.7.3
- github.com/gorilla/csrf (Go): affected all versions; fixed in 1.7.3

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-2025-24358/ (Markdown: https://insights.sbomify.com/CVE-2025-24358/index.md)
```

## Sources

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

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