XSS via Client Side Template Injection on www.███/News/Speeches
The search parameter on a news page is evaluated by a client-side template engine, allowing an attacker to inject and execute arbitrary JavaScript. This enables running code in the victim's browser and potentially bypassing CORS on other endpoints.
Originally disclosed on HackerOne
- Triaged in 44 hours
- Fixed in 3 months
- Disclosed after 3 months
Dear DoD - Team, I am able to execute javascript code on www.███████/News/Speeches.
This endpoint has a search functionality with the parameter Search. The supplied value to this parameter gets embedded into the website.
Furthermore the frontend of the website is presumably created with a template engine. These engines handle user supplied data within double curly braces {{...}} for example. If the user input is not sanitized corretly template injection can occur.
When supplying the Search parameter with a value inside double curly braces it gets evaluated and the result is then embedded into the web page.
For example the search value www.███████/News/Speeches?Search={{7*7}} gets evaluated to 49 and put into the web page (see image_1.png).
Besides simple mathematical equations, javascript code can be put inside those braces too (see image_2.png). This will execute the code as well which results in a XSS vulnerability.
There are some mitigations to this. For example some methods are blacklisted which means alert(1) is not allowed. However this can be bypassed by encoding the payload into a base64 string and call a decode method before evaluating (executing) the code.
I've come up with a simple payload which triggers all javascript code thus bypassing the blacklisting of potential dangerous methods.
https://www.████/News/Speeches/?Search={{window['eval'](window['atob'](window['decodeURIComponent']('BASE_64_ENCODED_PAYLOAD')))}}
A poc video is attached.
Recap
A client side template injection vulnerability is present through the Search parameter. This leads to the ability to run arbitrary javascript code on the client side.
Impact
- run arbitrary javascript code on the victims machine
- Since the javascript code is run within the realm of ██████ CORS bypass on other endpoints could be possible.
- Forgery of information
System Host(s)
www.█████████
Affected Product(s) and Version(s)
CVE Numbers
Steps to Reproduce
- Copy the provided link in the description section
- Replace the
BASE_64_ENCODED_PAYLOADwith an actual base64 encoded javascript code. For ExampleYWxlcnQoMSk=which isalert(1)in base64. - Insert the crafted url into the browser.
- done
Suggested Mitigation/Remediation Actions
Sanitize the user input so double curly braces {{...}} won't trigger a client side server injection
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the client-side template engine evaluates user input from the Search parameter without proper sanitisation, allowing template injection.
Impact
An attacker could run arbitrary JavaScript on the victim's machine, potentially bypass CORS on other endpoints, and forge information.
What the attacker needed
Victim clicks a crafted link
How it was found
- Copy the provided link from the description.
- Replace the placeholder with a base64-encoded JavaScript payload.
- Insert the crafted URL into the browser.
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 report has not been written yet. The Original tab links to the source.
The website treats what you type in a search box like a template, so code inside double curly braces runs. This lets an attacker run their own JavaScript in your browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.