A browser attaches cookies to requests, not intentions. Ask whether a state-changing endpoint can distinguish a real user action from a forged one.
Cookies are ambient authority: the browser sends them automatically to the cookie's host. If a state-changing endpoint relies only on that cookie, another site can cause the request without reading the response. The server authenticates the browser, not the human.
A successful request feels like a successful user action. The browser has no concept of intent, so the server must supply the missing proof.
What is actually at stake?
Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.
Assets
- Account email and password recovery
- Money, credits and billing plan
- MFA and security settings
- Administrative approvals
Actors
- Attacker who can host a page
- Malicious advertisement or email link
- Compromised site visited by the victim
- Insider who can send a link
Trust boundaries
- Browser cookie to server session
- Cross-site request to state change
- GET vs POST semantics
- Origin/Referer/Fetch Metadata to server policy
Abuse cases
- Change email over a top-level GET
- Disable MFA with a forged form
- Transfer credits to an attacker wallet
- Add an API key or webhook
- Revoke all sessions
Follow the decision, not the payload
Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.
- 01
Victim session
The victim is signed in and the browser holds a session cookie for the target site.
- 02
Attacker page
The attacker hosts a page, image, form or navigation that targets the victim site.
- 03
Automatic credentials
The browser attaches cookies according to host and SameSite rules; the attacker does not need to read them.
- 04
State change
The endpoint accepts the request without proving user intent, so the server performs the action.
- 05
Impact
The attacker may not read the response, but the side effect is enough: email change, transfer, MFA disable or approval.
The state-changing GET
Composite case study from public CSRF disclosuresA composite case based on a common account-takeover chain: a settings endpoint changed the recovery email over GET and checked only the session cookie.
A tester loaded the endpoint from a second origin. The browser sent the Lax cookie on the top-level navigation, and the recovery email changed without a token.
The attacker could trigger a password reset to the new address and take over the account. The victim saw only a harmless page visit.
The endpoint used GET for a state change and had no synchronizer token or Origin check. The cookie was treated as proof of intent.
Use POST with a per-session CSRF token, validate Origin/Fetch Metadata, and set SameSite=Lax or Strict on the session cookie.
Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.
A repeatable testing sequence
- Find state-changing requests and their parameters.
- Check whether the action is protected by a token, origin check or non-idempotent method.
- Test a top-level navigation and a cross-site form submission separately.
- Observe whether SameSite, Origin and Referer checks are actually enforced.
- Prove the state change from the victim's account, not just a 200 response.
Where smart people get fooled
- SameSite=Lax still sends cookies on top-level GET navigation; state-changing GETs are exploitable.
- A CSRF token in a cookie is not a synchronizer token unless the server compares it with a request value.
- Checking the Origin header only on some routes leaves older endpoints exposed.
- A CORS block prevents reading the response, not sending the request.
What would the logs show?
A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.
- State-changing requests with no CSRF token or with a token that matches a cookie
- Requests with an Origin or Referer from an unexpected site
- GET requests that change account, billing or security settings
- A burst of account changes after a user visits an external link
- Session activity inconsistent with the user's navigation
index=web sourcetype=app_logs | eval risky=if(match(uri,"(?i)(change-email|change-role|transfer|mfa|api-key|webhook|revoke)") AND method="GET",1,0) | where risky=1 | stats count values(uri) by user_id, referer | where count > 0Fix the decision, then prove it stays fixed
- Use non-idempotent methods and a per-session, unpredictable synchronizer token.
- Validate Origin and Fetch Metadata on state-changing requests.
- Set session cookies SameSite=Lax or Strict and never use GET for state changes.
- Require re-authentication for high-impact actions.
app.get("/account/change-email", (req, res) => {
db.users.update(req.user.id, { email: req.query.email });
res.send("updated");
});app.post("/account/change-email", requireSession, requireCsrf, (req, res) => {
if (!originAllowed(req)) return res.status(403).end();
db.users.update(req.user.id, { email: req.body.email });
res.send("updated");
});Use POST, a per-session synchronizer token, and Origin/Fetch Metadata checks. A token must be compared server-side; putting it in a cookie alone does not help.
Regression tests a reviewer would ask for
Cross-site GET
GivenA state-changing endpoint accepts GET
WhenA different origin navigates to it
ThenThe request is rejected or the method is not allowed
Missing token
GivenA POST endpoint changes email
WhenThe request omits the CSRF token
ThenThe server rejects it before the update
Wrong origin
GivenA valid session and token
WhenThe Origin header is an untrusted site
ThenThe server rejects the request
Cookie token
GivenThe CSRF token is stored in a cookie
WhenThe request repeats the same value only in the cookie
ThenThe server does not treat it as proof of intent
What this finding is not
Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.
- The endpoint returns 403 to a cross-site form: verify whether the token is actually validated or only present.
- The UI hides the action: the endpoint may still accept a direct request.
- SameSite=Strict blocks the request in one browser: test top-level GET, older clients and alternate flows.
- A CORS error appears in the console: CORS blocks reading, not sending; the state change may still occur.
Terms you should be able to use precisely
- CSRF
- Cross-site request forgery: causing a victim's browser to send an authenticated state-changing request.
- Synchronizer token
- A per-session unpredictable value compared between the page and the state-changing request.
- SameSite
- A cookie attribute that controls whether the cookie is sent on cross-site requests.
- Origin header
- A browser header identifying the origin that initiated a request; it can support CSRF checks.
- Fetch Metadata
- Browser-provided request headers such as Sec-Fetch-Site that describe the request context.
- Ambient authority
- Credentials the browser attaches automatically, without the user explicitly proving intent.
Answer these without reciting a payload
Why can a CSRF attack succeed without reading the response?
The goal is the side effect: the request changes email, transfers money or disables MFA. The attacker does not need to read the response.
Does SameSite=Lax prevent CSRF?
It blocks most cross-site subresource requests but still sends cookies on top-level GET navigation. State-changing GET endpoints remain exploitable.
How do you implement a CSRF token correctly?
Generate an unpredictable per-session token, include it in the form or header, and compare it server-side. Do not rely on a token that is also accepted from a cookie without comparison.
Can you separate the mechanism from the payload?
Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.
CSRF لا تحتاج إلى قراءة الاستجابة؛ يكفي أن يحدث الأثر. المتصفح يرسل الكوكي تلقائيًا، والخادم يظن أن الطلب يعبّر عن نية المستخدم. الحل ليس إخفاء النموذج، بل رمز مزامنة لكل جلسة، وفحص Origin، ومنع تغيير الحالة عبر GET. تذكّر أن SameSite=Lax ما زال يسمح بالتنقل الأعلى عبر GET، وأن خطأ CORS يمنع القراءة فقط وليس إرسال الطلب.
If an attacker can make the browser send the request but cannot read the response, is the action still dangerous?