CVE-2025-46721: CWE-352: Cross-Site Request Forgery (CSRF) in justinas nosurf
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).
AI Analysis
Technical Summary
CVE-2025-46721 is a medium-severity vulnerability affecting versions of the Go middleware 'nosurf' prior to 1.2.0. Nosurf is designed to protect web applications from Cross-Site Request Forgery (CSRF) attacks by validating that state-changing requests originate from the legitimate user. The vulnerability arises due to improper handling of HTTP requests within the Go 'net/http' library, which causes nosurf to treat all incoming requests as plain-text HTTP requests. Consequently, nosurf fails to validate the 'Referer' header to confirm same-origin requests. This flaw can be exploited by an attacker who controls content on the target site or any of its subdomains, for example via Cross-Site Scripting (XSS) or other means. By controlling HTML content on a subdomain (e.g., attacker.example.com), the attacker can manipulate cookies scoped to the main domain (example.com). This allows them to either extract the secret CSRF token from the cookie or overwrite it with a token known to the attacker. With this capability, the attacker can craft malicious cross-site requests that bypass the CSRF protections, effectively performing unauthorized actions on behalf of the user. The vulnerability does not require authentication but does require user interaction, such as visiting a malicious page. A patch was released in nosurf version 1.2.0 that addresses this issue. Until upgrading, users can mitigate the risk by deploying additional HTTP middleware that enforces same-origin policies on unsafe HTTP requests, for example by requiring the 'Sec-Fetch-Site: same-origin' header. There are no known exploits in the wild at this time.
Potential Impact
For European organizations, this vulnerability poses a significant risk to web applications that utilize the nosurf middleware for CSRF protection, particularly those built with the Go programming language. Exploitation could lead to unauthorized actions performed on behalf of authenticated users, potentially resulting in data manipulation, unauthorized transactions, or privilege escalation within web applications. The ability to bypass CSRF protections undermines the integrity of user sessions and can facilitate further attacks such as account takeover or data leakage. Given the reliance on cookies for session management in many European enterprise and government web services, attackers controlling subdomains or injecting malicious content could leverage this vulnerability to compromise sensitive operations. This is especially critical for sectors with high regulatory requirements such as finance, healthcare, and public administration, where unauthorized actions could lead to compliance violations and reputational damage. The medium CVSS score reflects the moderate ease of exploitation combined with the significant impact on integrity and user trust. However, the absence of known exploits suggests that immediate widespread risk is limited, but proactive patching is essential to prevent future exploitation.
Mitigation Recommendations
1. Upgrade nosurf middleware to version 1.2.0 or later immediately to apply the official patch addressing this vulnerability. 2. Implement additional HTTP middleware that enforces strict same-origin policies on unsafe HTTP requests, such as requiring the 'Sec-Fetch-Site: same-origin' header, to provide defense-in-depth. 3. Review and restrict subdomain creation and content control within your organization to minimize the risk of attackers controlling subdomains that can manipulate cookies. 4. Employ Content Security Policy (CSP) headers to reduce the risk of XSS vulnerabilities that could facilitate control over subdomain content. 5. Conduct thorough security testing of web applications to identify and remediate any XSS or other injection vulnerabilities that could be leveraged in conjunction with this CSRF bypass. 6. Monitor web application logs for unusual or unauthorized requests that may indicate exploitation attempts. 7. Educate developers about secure cookie handling, including setting the HttpOnly and Secure flags, and proper CSRF mitigation techniques beyond relying solely on middleware.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Italy, Spain, Poland
CVE-2025-46721: CWE-352: Cross-Site Request Forgery (CSRF) in justinas nosurf
Description
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).
AI-Powered Analysis
Technical Analysis
CVE-2025-46721 is a medium-severity vulnerability affecting versions of the Go middleware 'nosurf' prior to 1.2.0. Nosurf is designed to protect web applications from Cross-Site Request Forgery (CSRF) attacks by validating that state-changing requests originate from the legitimate user. The vulnerability arises due to improper handling of HTTP requests within the Go 'net/http' library, which causes nosurf to treat all incoming requests as plain-text HTTP requests. Consequently, nosurf fails to validate the 'Referer' header to confirm same-origin requests. This flaw can be exploited by an attacker who controls content on the target site or any of its subdomains, for example via Cross-Site Scripting (XSS) or other means. By controlling HTML content on a subdomain (e.g., attacker.example.com), the attacker can manipulate cookies scoped to the main domain (example.com). This allows them to either extract the secret CSRF token from the cookie or overwrite it with a token known to the attacker. With this capability, the attacker can craft malicious cross-site requests that bypass the CSRF protections, effectively performing unauthorized actions on behalf of the user. The vulnerability does not require authentication but does require user interaction, such as visiting a malicious page. A patch was released in nosurf version 1.2.0 that addresses this issue. Until upgrading, users can mitigate the risk by deploying additional HTTP middleware that enforces same-origin policies on unsafe HTTP requests, for example by requiring the 'Sec-Fetch-Site: same-origin' header. There are no known exploits in the wild at this time.
Potential Impact
For European organizations, this vulnerability poses a significant risk to web applications that utilize the nosurf middleware for CSRF protection, particularly those built with the Go programming language. Exploitation could lead to unauthorized actions performed on behalf of authenticated users, potentially resulting in data manipulation, unauthorized transactions, or privilege escalation within web applications. The ability to bypass CSRF protections undermines the integrity of user sessions and can facilitate further attacks such as account takeover or data leakage. Given the reliance on cookies for session management in many European enterprise and government web services, attackers controlling subdomains or injecting malicious content could leverage this vulnerability to compromise sensitive operations. This is especially critical for sectors with high regulatory requirements such as finance, healthcare, and public administration, where unauthorized actions could lead to compliance violations and reputational damage. The medium CVSS score reflects the moderate ease of exploitation combined with the significant impact on integrity and user trust. However, the absence of known exploits suggests that immediate widespread risk is limited, but proactive patching is essential to prevent future exploitation.
Mitigation Recommendations
1. Upgrade nosurf middleware to version 1.2.0 or later immediately to apply the official patch addressing this vulnerability. 2. Implement additional HTTP middleware that enforces strict same-origin policies on unsafe HTTP requests, such as requiring the 'Sec-Fetch-Site: same-origin' header, to provide defense-in-depth. 3. Review and restrict subdomain creation and content control within your organization to minimize the risk of attackers controlling subdomains that can manipulate cookies. 4. Employ Content Security Policy (CSP) headers to reduce the risk of XSS vulnerabilities that could facilitate control over subdomain content. 5. Conduct thorough security testing of web applications to identify and remediate any XSS or other injection vulnerabilities that could be leveraged in conjunction with this CSRF bypass. 6. Monitor web application logs for unusual or unauthorized requests that may indicate exploitation attempts. 7. Educate developers about secure cookie handling, including setting the HttpOnly and Secure flags, and proper CSRF mitigation techniques beyond relying solely on middleware.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2025-04-28T20:56:09.084Z
- Cisa Enriched
- true
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 682cd0fc1484d88663aecca0
Added to database: 5/20/2025, 6:59:08 PM
Last enriched: 7/6/2025, 6:26:34 PM
Last updated: 8/15/2025, 11:46:00 AM
Views: 18
Related Threats
CVE-2025-8878: CWE-94 Improper Control of Generation of Code ('Code Injection') in properfraction Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress
MediumCVE-2025-8143: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in pencidesign Soledad
MediumCVE-2025-8142: CWE-98 Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion') in pencidesign Soledad
HighCVE-2025-8105: CWE-94 Improper Control of Generation of Code ('Code Injection') in pencidesign Soledad
HighCVE-2025-8719: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in reubenthiessen Translate This gTranslate Shortcode
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.