{"id":"CVE-2025-46721","aliases":["CVE-2025-46721","GHSA-w9hf-35q4-vcjw","GO-2025-3683"],"related":[],"kind":"vulnerability","state":"published","title":"nosurf vulnerable to CSRF due to non-functional same-origin request checks","summary":"nosurf is cross-site request forgery (CSRF) protection middleware for Go. A vulnerability in versions prior to 1.2.0 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 CSRF checks and issue requests on user's behalf. 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`. A patch for the issue was released in nosurf 1.2.0. 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).","summarySource":"cvelist","descriptions":[{"lang":"en","text":"nosurf is cross-site request forgery (CSRF) protection middleware for Go. A vulnerability in versions prior to 1.2.0 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 CSRF checks and issue requests on user's behalf. 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`. A patch for the issue was released in nosurf 1.2.0. 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).","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"en","text":"Vulnerable to CSRF due to non-functional same-origin request checks in github.com/justinas/nosurf","format":"markdown","source":"go"},{"lang":"es","text":"nosurf es un middleware de protección contra cross-site request forgery (CSRF) para Go. Una vulnerabilidad en versiones anteriores a la 1.2.0 permite a un atacante que controla el contenido del sitio web objetivo o de un subdominio del mismo (ya sea mediante XSS o de otro modo) eludir las comprobaciones CSRF y emitir solicitudes en nombre del usuario. Debido al uso indebido de la librería `net/http` de Go, nosurf categoriza todas las solicitudes entrantes como solicitudes HTTP de texto plano, en cuyo caso no se comprueba que el encabezado `Referer` tenga el mismo origen que la página web objetivo. Si el atacante controla el contenido HTML del sitio web objetivo (p. ej., `example.com`) o de un sitio web alojado en un subdominio del sitio objetivo (p. ej., `attacker.example.com`), también podrá manipular las cookies configuradas para el sitio web objetivo. Al obtener el token CSRF secreto de la cookie o sobrescribirla con un nuevo token conocido por el atacante, `attacker.example.com` puede generar solicitudes entre sitios a `example.com`. Se publicó una corrección para este problema en nosurf 1.2.0. En lugar de actualizar a una versión parcheada de nosurf, los usuarios pueden usar otro middleware HTTP para garantizar que una solicitud HTTP no segura provenga del mismo origen (por ejemplo, al requerir un encabezado `Sec-Fetch-Site: same-origin` en la solicitud).","source":"nvd"}],"published":"2025-05-13T15:29:30.068Z","modified":"2026-06-17T09:26:52.463Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-352"],"affected":[{"ranges":[{"version":"< 1.2.0","status":"affected"}],"vendor":"justinas","product":"nosurf","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.2.0"}],"ecosystem":"Go","package":"github.com/justinas/nosurf","purl":"pkg:golang/github.com/justinas/nosurf","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.2.0"}],"ecosystem":"Go","package":"github.com/justinas/nosurf","purl":"pkg:golang/github.com/justinas/nosurf","source":"go"},{"ranges":[{"status":"affected","fixed":"1.2.0"}],"vendor":"nosurf_project","product":"nosurf","cpe":"cpe:2.3:a:nosurf_project:nosurf:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/justinas/nosurf/security/advisories/GHSA-w9hf-35q4-vcjw","tags":["advisory","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/justinas/nosurf/commit/ec9bb776d8e5ba9e906b6eb70428f4e7b009feee","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/advisories/GHSA-rq77-p4h8-4crw","tags":["advisory","exploit","not-applicable","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/justinas/nosurf-cve-2025-46721","tags":["exploit","third-party-advisory","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/justinas/nosurf/releases/tag/v1.2.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-46721","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/justinas/nosurf","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-05-13T19:07:19.880Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-46721","url":"https://www.cve.org/CVERecord?id=CVE-2025-46721","licence":"CVE Terms of Use","modified":"2025-05-13T19:07:23.093Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-w9hf-35q4-vcjw","url":"https://github.com/advisories/GHSA-w9hf-35q4-vcjw","licence":"CC-BY-4.0","modified":"2026-02-04T03:18:59.066Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2025-3683","url":"https://pkg.go.dev/vuln/GO-2025-3683","licence":"CC-BY-4.0","modified":"2025-06-12T14:09:57.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-46721","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-46721","licence":"Public domain","modified":"2026-06-17T09:26:52.463Z"}],"updatedAt":"2026-11-25T22:58:57.974Z","epss":{"score":0.00248,"percentile":0.17231,"date":"2026-12-01T12:00:22.000Z"}}