Vulnerabilities in pkg:golang/github.com/justinas/nosurf

PACKAGE
Advisory Identifier: GHSA-w9hf-35q4-vcjw
Advisory Summary

CVE-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.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/justinas/nosurf

2 Known Advisory Record(s)

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

CVE Identifier CVE-2025-46721
GHSA Identifier GHSA-w9hf-35q4-vcjw
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-352: Cross-Site Request Forgery (CSRF)
Affected Product Github.com/justinas/nosurf
Package Ecosystem Go
Published Date
Last Updated

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.

github.com/justinas/nosurf fixed: 1.2.0
Upgrade github.com/justinas/nosurf to 1.2.0
Verify Direct and Transitive Dependencies

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

### Impact This 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. ### Details Due 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. If 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`. ### Patches A patch for the issue was released in nosurf 1.2.0. ### Workarounds In 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). ### References https://github.com/advisories/GHSA-rq77-p4h8-4crw https://github.com/justinas/nosurf-cve-2025-46721 https://www.cve.org/CVERecord?id=CVE-2025-46721 https://github.com/justinas/nosurf/releases/tag/v1.2.0

CVE-2025-46721 Affected Github.com/justinas/nosurf Versions

1 component(s)
Fixed Versions:
1.2.0
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?
CVE-2025-46721 is a security vulnerability in Github.com/justinas/nosurf involving nosurf vulnerable to CSRF due to non-functional same-origin request checks under CWE-352: Cross-Site Request Forgery (CSRF).
Which Github.com/justinas/nosurf versions are affected?
Affected versions include releases prior to 1.2.0 across affected packages: github.com/justinas/nosurf.
What version fixes CVE-2025-46721?
Upgrading to 1.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/justinas/nosurf affected?
Yes, github.com/justinas/nosurf is affected in releases prior to 1.2.0. Upgrade your dependency to 1.2.0 or later.
What CWE is associated with CVE-2025-46721?
CVE-2025-46721 is classified under CWE-352: Cross-Site Request Forgery (CSRF) (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.).
How can I check Go dependencies for CVE-2025-46721?
Run the dependency tree command: 'inspect dependencies for github.com/justinas/nosurf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}