Skip to content
CSRF Write-up Advanced

Old school anti-CSRF mechanism

The Play framework's older CSRF defence relied on a blacklist of simple-request content types, but the multipart boundary parameter is attacker-controlled and can be crafted so Akka HTTP's header parser rejects the value and sets it to None. An attacker could then send a cross-site request that the browser treats as a simple request while the blacklist check is skipped, achieving a full CSRF bypass.

blog.doyensec.com

Published on blog.doyensec.com

This blog post illustrates a vulnerability affecting the Play framework that we discovered during a client engagement. This issue allows a complete Cross-Site Request Forgery (CSRF) protection bypass under specific configurations.

Luca Carettoni, on blog.doyensec.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the CSRF filter compared the raw Content-Type header against a blacklist, while the underlying Akka HTTP parser could reject a malformed multipart boundary and treat the content type as absent, so the two components disagreed about the request's type.

Impact

Under specific configurations, an attacker could fully bypass CSRF protection, allowing forged cross-site requests.

What the attacker needed

Victim is logged in; victim visits attacker page; legacy CSRF config in use

The fix

The issue was fixed in Play 2.8.2 and 2.7.5.

How it was found

  1. Identify requests the browser can send cross-site without a preflight OPTIONS request.
  2. Note that multipart/form-data is the only such request whose Content-Type can be modified, via the boundary value.
  3. Craft a boundary that violates the Akka HTTP header parsing rules so the parsed value becomes None.
  4. Send the forged cross-site request so the blacklist check is skipped.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

CSRF is when a malicious site makes your browser send a request to another site where you are logged in, so the action happens as you. Play tried to block this by refusing certain request formats that browsers can send without a safety check, but the extra 'boundary' text in one of those formats is written by the attacker and can be made invalid so the framework ignores the check entirely.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.