Vulnerabilities in pkg:golang/github.com/justinas/nosurf
PACKAGECVE-2025-46721 is a MODERATE nosurf vulnerable to csrf due vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Github.com/justinas/nosurf libraries in the Go ecosystem. The issue involves nosurf vulnerable to csrf due to non-functional same-origin request checks. Remediation is available by upgrading affected packages to version 1.2.0.
pkg:golang/github.com/justinas/nosurf
Vulnerability advisories affecting package pkg:golang/github.com/justinas/nosurf. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-w9hf-35q4-vcjw | CVE-2025-46721 | MODERATE | nosurf vulnerable to CSRF due to non-functional same-origin request checks |
| GHSA-5x84-q523-vvwr | CVE-2020-36564 | HIGH | nosurf vulnerable to improper input validation |
CVE-2025-46721 at a Glance
How to Fix CVE-2025-46721
To remediate this vulnerability, upgrade all affected Github.com/justinas/nosurf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/justinas/nosurf to 1.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/justinas/nosurf
How to Check if You Are Affected
To determine whether your application is affected by CVE-2025-46721, inspect your project dependencies for Github.com/justinas/nosurf:
inspect dependencies for github.com/justinas/nosurf
Analyze the terminal output to locate any version of Github.com/justinas/nosurf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-352: Cross-Site Request Forgery (CSRF), where the web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. In Github.com/justinas/nosurf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-46721 Affected Github.com/justinas/nosurf Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/justinas/nosurf
|
Go |
< 1.2.0
|
1.2.0
|
References
Frequently Asked Questions
What is CVE-2025-46721?
Which Github.com/justinas/nosurf versions are affected?
What version fixes CVE-2025-46721?
Is github.com/justinas/nosurf affected?
What CWE is associated with CVE-2025-46721?
How can I check Go dependencies for CVE-2025-46721?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-w9hf-35q4-vcjw",
"modified" : "2025-05-14T14:56:27Z",
"published" : "2025-05-14T14:56:27Z",
"aliases" : [ "CVE-2025-46721" ],
"summary" : "nosurf vulnerable to CSRF due to non-functional same-origin request checks",
"details" : "### Impact\n\nThis vulnerability allows an attacker who controls content on the target site, or on a subdomain of the target site (either via XSS, or otherwise) to bypass Cross-Site Request Forgery checks and issue requests on user's behalf.\n\n### Details\n\nDue to misuse of the Go `net/http` library, nosurf categorizes all incoming requests as plain-text HTTP requests, in which case the `Referer` header is not checked to have the same origin as the target webpage.\n\nIf the attacker has control over HTML contents on either the target website (e.g. `example.com`), or on a website hosted on a subdomain of the target (e.g. `attacker.example.com`), they will also be able to manipulate cookies set for the target website. By acquiring the secret CSRF token from the cookie, or overriding the cookie with a new token known to the attacker, `attacker.example.com` is able to craft cross-site requests to `example.com`. \n\n### Patches\n\nA patch for the issue was released in nosurf 1.2.0.\n\n### Workarounds\n\nIn lieu of upgrading to a patched version of nosurf, users may additionally use another HTTP middleware to ensure that a non-safe HTTP request is coming from the same origin (e.g. by requiring a `Sec-Fetch-Site: same-origin` header in the request).\n\n### References\n\nhttps://github.com/advisories/GHSA-rq77-p4h8-4crw\nhttps://github.com/justinas/nosurf-cve-2025-46721\nhttps://www.cve.org/CVERecord?id=CVE-2025-46721\nhttps://github.com/justinas/nosurf/releases/tag/v1.2.0",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/justinas/nosurf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/justinas/nosurf/security/advisories/GHSA-w9hf-35q4-vcjw"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-46721"
}, {
"type" : "WEB",
"url" : "https://github.com/justinas/nosurf/commit/ec9bb776d8e5ba9e906b6eb70428f4e7b009feee"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-rq77-p4h8-4crw"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/justinas/nosurf"
}, {
"type" : "WEB",
"url" : "https://github.com/justinas/nosurf-cve-2025-46721"
}, {
"type" : "WEB",
"url" : "https://github.com/justinas/nosurf/releases/tag/v1.2.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-05-14T14:56:27Z",
"nvd_published_at" : "2025-05-13T16:15:31Z"
}
}