# Cross-site scripting via hardcoded front-end watched expression.

Hardcoded frontend watched-expression rendered unsanitized HTML; a Python class overriding get_datetime().strftime() injected XSS into the algo debugger, firing on collaborators and cloners.

- Payout: $1,225
- Severity: medium
- Program: Quantopian
- Found by: irisrumtub
- Disclosed: 2022-12-21
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/684544
- Library page: https://bugbountylibrary.com/r/h1%3A684544
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:medium tech:python tech:websocket technique:chained technique:source-review vuln:xss

**Target:** Algorithm debugger watched-expression output (WebSocket set_watch) on www.quantopian.com
**Root cause:** Frontend hardcodes the expression get_datetime().strftime("%Y-%m-%d %H:%M:%S")#__QUANTOPIAN__ and injects its evaluated result directly into unsanitized HTML, while the Python runtime lets user code shadow get_datetime and control the output.
**Steps:**
1. Observe debugger sends WebSocket `{"e":"set_watch","p":["get_datetime().strftime(\"%Y-%m-%d %H:%M:%S\")#__QUANTOPIAN__"]}`
2. Confirm the response for that exact expression is rendered as raw HTML in the date area
3. Define a Python class `get_datetime` with `strftime` returning `<img src=x onerror=alert(1)>`
4. Set a breakpoint so the debugger opens and run the algorithm
5. XSS fires in the debugger date area; alternatively intercept the outgoing POST and inject the class into the full code payload
6. Obfuscate the class in a shared algorithm so it fires when a victim clones and runs it
**How found:** Noticed the debugger's set_watch WebSocket request with a hardcoded expression; hypothesized the date area rendered unsanitized HTML, confirmed by tampering with the WebSocket response, then realized the expression is user-controllable Python and shadowed get_datetime.
**Exploitation:** Attacker adds a shadowing get_datetime class to algorithm code, either waiting for a collaborator to re-validate or intercepting the outgoing POST to inject the class invisibly; the debugger evaluates the hardcoded watched expression, returns attacker HTML, and executes JS on quantopian.com, enabling algorithm theft.
**Escalation:** Two vectors: silent injection via intercepted POST to a collaborator, and stored/obfuscated payload in a shared algorithm that fires on anyone who clones and runs it.
**Insight:** When a frontend hardcodes an expression string and renders its evaluated result as HTML, check whether the underlying runtime lets user code shadow the referenced symbol (class/function) to control that output.

## Proof of concept (copied exactly from the original report)

**Python class overriding get_datetime to inject XSS payload**

```
class get_datetime():
    def __init__(self):
        self.img = '<img src=x'+' one'+'rror=alert(1)>'
    def strftime(self, x=None):
        return self.img
```

**WebSocket set_watch request with hardcoded expression**

```
{"e":"set_watch","p":["get_datetime().strftime(\"%Y-%m-%d %H:%M:%S\")#__QUANTOPIAN__"]}
```

