Stored XSS via Custom Template Injection — How I Bypassed Cloudflare WAF
A custom template engine evaluated user input in fields like display name, leading to stored XSS when rendered in support tickets, friend lists, and profiles. The custom delimiters bypassed Cloudflare WAF, allowing JavaScript execution in multiple contexts.
Published on medium.com
While testing an e-commerce platform, I discovered a stored XSS vulnerability through a custom template injection that completely bypassed Cloudflare WAF protection. What made this finding interesting was that the payload wasn’t executing where I injected it — it was silently rendering somewhere else entirely.
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 custom template engine evaluated user-supplied input as template expressions without proper sanitisation, and the custom delimiters evaded WAF signatures.
Impact
Stored XSS could execute in user profiles, friend lists, support tickets, and product comments, potentially affecting other users and support agents, though the text does not specify the exact consequences beyond script execution.
What the attacker needed
Ability to set display name; victim views the injected content
How it was found
- Fuzz input fields with a polyglot payload and observe a template rendering error in the address field.
- Inject %%7*7%% into various fields including the name field.
- Later view a support ticket and see the display name rendered as 49, confirming execution.
- Inject %%self%% to confirm access to the JavaScript global scope.
- Inject %% alert('XSS') %% to achieve JavaScript execution.
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.
The website used its own template system to insert user details into pages. Because it treated special markers in a user's name as code, an attacker could store a script that ran for anyone who viewed that name. This is called stored cross-site scripting (XSS), where malicious code is saved and later shown to other users.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.