SVG Abuse: Account Takeover Without XSS
An SVG file upload allowed embedding HTML meta tags that set an unsafe referrer policy and redirect to an attacker server, leaking OAuth tokens from the URL. Combined with a permissive OAuth redirect URI validation, an attacker could take over a victim's account.
medium.com
Published on medium.com
SVG uploads are a fun attack surface! Most testers check for XSS, but what if the Content Security Policy (CSP)is set to script-src: none?
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 combination of insufficient file type validation (allowing SVG uploads based on Content-Type header) and OAuth redirect URI validation that only checks the domain prefix rather than exact match.
Impact
An attacker could steal OAuth tokens and take over user accounts, provided the OAuth token is included in the URL and the redirect URI validation is permissive.
What the attacker needed
SVG upload allowed; SVG served from main domain; OAuth redirect URI validation permissive; Victim clicks link and authenticates
The fix
The report recommends blocking SVG uploads server-side by checking magic bytes, enforcing exact-match redirect_uri validation, and stripping foreignObject and meta elements from SVGs.
How it was found
- Upload an SVG file with a foreignObject containing meta tags for referrer policy and redirect.
- Note the URL where the SVG is served.
- Construct an OAuth authorization link with the SVG URL as the redirect_uri.
- Send the link to the victim; after authentication, the OAuth provider redirects to the SVG.
- The SVG's meta tags cause the browser to redirect to the attacker's server with the token in the Referer header.
- Capture the token from the Referer header on the attacker's server.
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.
This report shows how uploading a seemingly harmless image file (an SVG) can be abused. The SVG contains special instructions that make the browser send the full web address, including a secret login token, to an attacker's server when the victim is redirected there. The attacker also needs a flaw in the login system that allows redirecting to any page on the target site.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.