Security weaknessCWE Top 25 · #3
CWE-352 Cross-site request forgery (CSRF)
Another website tricks a logged-in user’s browser into sending actions to your site that the user never intended.
- Senior security engineers
- 540+ projects delivered
- Reply within one business day
Quick answer
What is CWE-352?
Cross-Site Request Forgery: 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.
Business impact
What CWE-352 could cost your business
MITRE documents what this weakness can do. Here is what that means for a website, store or app.
Confidentiality
Private data exposed
Customer records, credentials, orders or internal files can be read by people who should never see them.
- Gain Privileges or Assume Identity
- Bypass Protection Mechanism
- Read Application Data
Integrity
Data, pages or code changed
Prices, orders, content or the code your site runs can be altered without your approval.
- Gain Privileges or Assume Identity
- Bypass Protection Mechanism
- Read Application Data
Availability
Downtime and lost sales
Crashes, slowdowns or exhausted resources can take your site, store or app offline.
- Gain Privileges or Assume Identity
- Bypass Protection Mechanism
- Read Application Data
Access Control
Accounts and admin areas exposed
Logins and permission checks can be bypassed, putting admin and customer accounts at risk.
- Gain Privileges or Assume Identity
- Bypass Protection Mechanism
- Read Application Data
Non-Repudiation
Actions you cannot trace
Changes can happen without a reliable record, which slows incident response and compliance work.
- Gain Privileges or Assume Identity
- Bypass Protection Mechanism
- Read Application Data
In plain English
What Cross-site request forgery (CSRF) means for your business
- 540+projects delivered
- 9+years in business
- 23+certified experts
A senior engineer replies within one business day.
Cross-site request forgery, or CSRF, abuses the way browsers attach cookies to requests. When you are logged in to a site, your browser sends your session cookie with every request to it, no matter which page started that request. If your site does not check that an action really came from its own pages, a different website can trigger that action in the background while your user is signed in.
The attacker never sees a password and never logs in. They rely on your user’s existing session. That makes the impact depend on who gets tricked. For a customer, it could mean a changed email address or shipping address. For an administrator, it could mean a new admin account, changed settings or deleted content. The request looks legitimate in your logs because it came from a real, authenticated user.
Where it shows up
- Account settings forms that change an email address, password or payout details and accept the request without a one-time token tied to the session.
- WordPress plugin settings pages and AJAX actions that save options or delete data without verifying a nonce, which is a short-lived security token.
- Links or buttons that perform an action through a simple GET request, such as deleting an item, logging out or approving a comment.
- Admin panels and internal dashboards that rely only on the session cookie to authorize state-changing API calls from the browser.
Free security check
Is CWE-352 hiding in your site?
A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.
Official definition
How MITRE defines CWE-352
Cross-Site Request Forgery
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.
Also known as: Session Riding, Cross Site Reference Forgery, XSRF, CSRF
Fix it
How to fix Cross-site request forgery (CSRF)
Practical steps in priority order. Share them with your developer or agency.
Add anti-CSRF tokens to actions
Generate an unpredictable token per session or per form, include it in every state-changing request, and verify it on the server. Use your framework’s built-in protection, such as WordPress nonces or the CSRF middleware in Laravel and Django.
Set SameSite on session cookies
Mark session cookies SameSite=Lax or SameSite=Strict, along with Secure and HttpOnly. Browsers then withhold the cookie on most cross-site requests. Treat this as a second layer, not a replacement for tokens.
Never change state with GET
Use POST, PUT, PATCH or DELETE for any request that creates, updates or removes data. GET requests should only read. This keeps images, links and prefetching from triggering actions by accident or by design.
Verify the request origin
For sensitive endpoints, check that the Origin or Referer header matches your own domain and reject mismatches. For APIs called by JavaScript, require a custom header and a strict CORS policy that lists allowed origins.
Re-confirm high-risk actions
Ask for the current password, a one-time code or an explicit confirmation step before changing email, password, payment details or user roles. A forged background request cannot complete that extra step.
Signs you may be affected
- Forms that change data have no hidden token field, or the server accepts requests without it.
- Settings or account details change, and the user responsible does not remember doing it.
- Session cookies are set without a SameSite attribute, and actions can be triggered by a plain link.
Questions to ask your developer
- Do all forms and AJAX actions that change data verify a CSRF token?
- Are our session cookies set with SameSite, Secure and HttpOnly attributes?
- Do any links or GET requests change data on our site?
Prevention
What MITRE recommends, phase by phase
Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.
- 01
Architecture and Design
- Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. For example, use anti-CSRF packages such as the OWASP CSRFGuard. [REF-330] Another example is the ESAPI Session Management control, which includes a component for CSRF. [REF-45]
- Generate a unique nonce for each form, place the nonce into the form, and verify the nonce upon receipt of the form. Be sure that the nonce is not predictable (CWE-330). [REF-332]
- Identify especially dangerous operations. When the user performs a dangerous operation, send a separate confirmation request to ensure that the user intended to perform that operation.
Show 2 more recommendations
- Use the "double-submitted cookie" method as described by Felten and Zeller: When a user visits a site, the site should generate a pseudorandom value and set it as a cookie on the user’s machine. The site should require every form submission to include this value as a form value and also as a cookie value. When a POST request is sent to the site, the request should only be.
- Do not use the GET method for any request that triggers a state change.
- 02
Implementation
- Ensure that the application is free of cross-site scripting issues (CWE-79), because most CSRF defenses can be bypassed using attacker-controlled script.
- Check the HTTP Referer header to see if the request originated from an expected page. This could break legitimate functionality, because users or proxies may have disabled sending the Referer for privacy reasons.
Detection and evidence
How CWE-352 is found, and where it has hit
The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.
How it is detected
- Manual AnalysisThis weakness can be detected using tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. Specifically, manual analysis can be useful for finding this weakness, and.
- Automated Static AnalysisCSRF is currently difficult to detect reliably using automated techniques. This is because each application has its own implicit security policy that dictates which requests can be influenced by an outsider and automatically performed on behalf of a user, versus which requests require strong.
- Automated Static Analysis – Binary or BytecodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Bytecode Weakness Analysis – including disassembler + source code weakness analysis Binary Weakness Analysis – including disassembler + source code weakness analysis
- Manual Static Analysis – Binary or BytecodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Binary / Bytecode disassembler – then use manual analysis for vulnerabilities & anomalies
- Dynamic Analysis with Automated Results InterpretationAccording to SOAR [REF-1479], the following detection techniques may be useful: Web Application Scanner
Real vulnerabilities it caused
- CVE-2004-1703Add user accounts via a URL in an img tag
- CVE-2004-1995Add user accounts via a URL in an img tag
- CVE-2004-1967Arbitrary code execution by specifying the code in a crafted img tag or URL
- CVE-2004-1842Gain administrative privileges via a URL in an img tag
- CVE-2005-1947Delete a victim’s information via a URL or an img tag
- CVE-2005-2059Change another user’s settings via a URL or an img tag
How we fix it
From finding to fixed: how Codefreex closes CWE-352
Scan and confirm
We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.
Fix at the source
We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.
Verify the fix
We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.
Keep it fixed
Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.
Website SecurityPenetration TestingMalware Removal & Hack RepairWordPress Maintenance
Related weaknesses
Weaknesses related to CWE-352
FAQ
CWE-352: FAQs
Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.
How serious is CSRF?
The impact depends on what the forged request can do and who is tricked into sending it. Against an ordinary account it may change profile details or trigger an unwanted action. Against an administrator it can change site settings or create new privileged users. MITRE rates the likelihood of exploitation as medium.
Does a SameSite cookie setting fix CSRF by itself?
It helps a great deal, but do not rely on it alone. SameSite tells the browser to withhold cookies on most cross-site requests, yet behavior varies with the setting, the request method and older browsers. Requests from subdomains you do not fully control may still count as same-site. Keep server-side tokens as the primary defense.
How do I prevent CSRF?
Use the CSRF protection built into your framework and make sure it covers every state-changing route, including AJAX and API calls. Set SameSite cookies. Keep GET requests read-only. Require re-authentication for sensitive changes. Also fix any cross-site scripting issues, because a script running on your own pages can read tokens and bypass these defenses.
What is CWE-352?
CWE-352, “Cross-Site Request Forgery”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. 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 serious is CWE-352?
MITRE rates the likelihood of exploit as Medium. It can affect confidentiality, integrity, availability, non-repudiation, with impacts such as gain privileges or assume identity, bypass protection mechanism, read application data. It ranks number 3 on the 2025 CWE Top 25 Most Dangerous Software Weaknesses. The real risk depends on where the weakness sits and what data or functions it exposes.
How do you prevent CWE-352?
Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. For example, use anti-CSRF packages such as the OWASP CSRFGuard. [REF-330] Another example is the ESAPI. Ensure that the application is free of cross-site scripting issues (CWE-79), because most CSRF defenses can be bypassed using attacker-controlled script.
Can Codefreex check my site for CWE-352?
Yes. A senior engineer reviews your site, store or app for CWE-352 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.
Free security check
Find out if CWE-352 affects your site
Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.
- A senior strategist reviews your request, not a sales bot
- Clear scope, timeline and estimate within one business day
- Free 30-minute discovery call, no obligation
- NDA available on request
- Emailhello@codefreex.com
- CallUSA +1 (209) 375-3475 · India +91 790 3375 530
- Prefer to talk?Book a 30-minute call
Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.