The CSRF Token Nobody Checked
*AI disclosure: This article was drafted with AI assistance as an analytical case study of a public disclosure. It is not my own discovery.*


AI-generated illustration
A 2015 Messenger.com disclosure shows that issuing anti-forgery tokens is worthless if the server never verifies them
AI disclosure: This article was drafted with AI assistance as an analytical case study of a public disclosure. It is not my own discovery.
A CSRF token that the server never compares is decoration. Jack Whitton reported that shortly after Messenger.com launched in April 2015, state-changing requests succeeded with the anti-forgery parameter removed entirely, and after testing a few endpoints he concluded the check was missing on every request. Facebook shipped what he called a simple and quick fix: tokens are now verified everywhere.
Disclaimer: * Educational and defensive use only. Both researchers report Facebook fixed the issues in 2015. This article intentionally omits reproduction details.*
Vulnerability Overview
- Type: Cross-site request forgery (missing server-side token validation)
- CWE (analytical mapping, not from the source): CWE-352
- CVE: Not stated in the disclosure
- Severity/CVSS: Not reported. Bounty: Not reported
What Happened (high level)
Browsers attach session cookies to a request no matter which site triggered it. The usual defense is an unguessable per-session token that the server compares on every state-changing call. Messenger.com clients sent that token, but the new domain’s backend did not reject requests that lacked it.
Whitton compared normal requests with variants that tampered with the token. On Messenger.com, removing it still produced a normal success response for a settings change and for removing a participant from a group thread. He credits Mazin Ahmed (@mazen160), who independently found and published related Messenger CSRF issues in June 2015.
My reading: a new product on a separate origin inherited the client-side token plumbing but not the server-side enforcement.
Impact
Any page a logged-in user visited could trigger actions in that user’s Messenger account. Beyond settings, the disclosures describe removing people from threads, sending messages, and deleting threads on the victim’s behalf. For a messaging product, silent message spoofing is a trust failure, not a cosmetic bug.
Remediation & Defense-in-Depth (my own analysis)
1. Enforce in one place, default-deny. Verify the token in shared middleware that runs before any handler. Endpoints should opt out explicitly, never opt in.
2. Compare tokens in constant time against server-held state. A missing, empty, or wrong-length value fails the same way as a wrong one.
3. Refuse state changes over safe methods. GET and HEAD must never mutate data, or a method switch quietly bypasses the check.
4. Layer SameSite cookies and Origin checks. SameSite=Lax or Strict blocks most cross-site cookie sends; an Origin or Fetch-Metadata check rejects cross-site writes even if a token check regresses.
# Pseudocode: global, default-deny CSRF gate that runs before routing
SAFE_METHODS = {"GET", "HEAD", "OPTIONS"}
def csrf_gate(request, route):
if request.method in SAFE_METHODS:
if route.mutates_state:
raise Rejected("state change over safe method")
return
if route.csrf_exempt_reason: # explicit, reviewed opt-out only
return
site = request.headers.get("Sec-Fetch-Site")
if site not in (None, "same-origin", "same-site"):
raise Rejected("cross-site write")
expected = request.session.get("csrf_token")
supplied = request.form.get("csrf_token") or request.headers.get("X-CSRF-Token")
if not expected or not supplied:
raise Rejected("missing token") # absent == invalid
if not constant_time_equal(expected, supplied):
raise Rejected("bad token")
5. Regression-test the negative cases in CI. For every mutating route, assert rejection with the token removed, emptied, altered, and with the method switched. Diff the route list against the test list so new endpoints cannot ship untested.
Key Takeaways
- Sending a token is not the defense; rejecting requests without a valid one is.
- New domains and product launches deserve a fresh look at shared security controls.
- Test the failure path: a CSRF suite that only checks success proves nothing.
Credit & Sources
Research by Jack Whitton: Messenger.com Site-Wide CSRF (26 July 2015). Related independent research by Mazin Ahmed: Facebook Messenger Multiple CSRF Vulnerabilities (9 June 2015). Facts come from those posts; analysis, code and remediation are original suggestions.
First published by Adam Hale on Medium.
Sources
Share
Reactions
Comments
Your name and comment appear on this article for other readers.
Corrections and tips:[email protected]

