# Stored XSS in Elastic App Search

Stored XSS via a javascript: URL stored in an App Search document field, executed when an admin opens the Reference UI preview and clicks the title link.

- Payout: $2,000
- Severity: high
- Program: Elastic
- Found by: iamnoooob
- Disclosed: 2020-07-28
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/846905
- Library page: https://bugbountylibrary.com/r/h1%3A846905
- Tags: area:web domain:web impact:ato impact:integrity kind:bounty platform:hackerone sev:high tech:elasticsearch technique:chained vuln:xss

**Target:** Elastic App Search Reference UI preview (reference_application/preview)
**Root cause:** The Reference UI renders a document field as an anchor href without validating the URL scheme, so a stored `javascript://...%0aalert()` value becomes a clickable script-executing link.
**Steps:**
1. Create an App Search deployment and engine.
2. Paste JSON document: `{"url":"javascript://test%0aalert(document.domain)"}`.
3. In Reference UI set Title field=url and URL field=url, click Generate Preview.
4. Open the preview URL `.../reference_application/preview?titleField=url&urlField=url`.
5. Ctrl+click or middle-click the title link; the javascript: payload executes.
**How found:** Tester supplied a `javascript://` scheme with an encoded newline in a document field and observed the Reference UI rendered it directly as an anchor href, then confirmed execution on click.
**Exploitation:** Low-privileged user with document write access stores the malicious URL, then shares the crafted preview URL with an admin/owner; when the admin clicks the title link the stored javascript: URI runs in the App Search origin.
**Insight:** When a UI lets users pick which document field becomes a link href, test whether arbitrary schemes (javascript:, data:) survive into the anchor; the `%0a` newline trick bypasses naive `javascript:` string checks.

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

**Malicious JSON document with javascript URL payload**

```
{
"url":"javascript://test%0aalert(document.domain)"
}
```

**Reference UI preview URL triggering stored XSS**

```
https://069c551087be451bb8d1aecb3cf64341.app-search.us-east-1.aws.found.io/as/engines/test/reference_application/preview?titleField=url&urlField=url
```

