# Reflected XSS in the shared note view on https://evernote.com

Reflected XSS in Evernote's shared note viewer via ionUrl parameter, bypassing a substring check to inject a javascript: URI and steal cookies.

- Payout: $500
- Severity: medium
- Program: Evernote
- Found by: sarka
- Disclosed: 2022-04-20
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1518343
- Library page: https://bugbountylibrary.com/r/h1%3A1518343
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:medium technique:js-analysis technique:source-review vuln:xss

**Target:** www.evernote.com /shard/s[N]/client/snv shared note viewer endpoint
**Root cause:** The renderAfterSaveNoteView() function assigns window.location.href from the ionUrl URL parameter after only checking that the string contains 'https://www.evernote.com/' as a substring, not that it starts with it, allowing a javascript: URI with the evernote URL appended as a comment.
**Steps:**
1. Fetch and beautify main.68d4af6d45d9dcaab6e6.js from dashboard.svc.www.evernote.com/app/nv/
2. Locate renderWithContext() switch on this.view; note the 'after-save-note' case calls renderAfterSaveNoteView()
3. Observe renderAfterSaveNoteView() sets window.location.href = ionUrl if ionUrl contains J.baseUrl ('https://www.evernote.com/')
4. Craft ionUrl=`javascript:alert(document.cookie)//https://www.evernote.com/` and view=after-save-note
5. Visit `https://www.evernote.com/shard/s1/client/snv?view=after-save-note&ionUrl=javascript:alert(document.cookie)//https://www.evernote.com/`
**How found:** Read the shared-note viewer JS bundle, spotted the renderWithContext() switch keyed on the URL 'view' parameter, followed the 'after-save-note' branch to renderAfterSaveNoteView(), and noticed the ionUrl value flows into window.location.href guarded only by an indexOf substring check rather than a prefix check.
**Exploitation:** Send victim a crafted snv URL with view=after-save-note and a javascript: ionUrl payload; the viewer script sets window.location.href to the javascript URI, executing attacker script in the evernote.com origin to read cookies and act as the victim. Note link need not be valid; attacker can also use a valid note link to execute silently and force sign-in first to ensure cookies exist.
**Insight:** When a redirect/sink is guarded by indexOf/contains on a trusted domain, test javascript: and data: schemes with the trusted URL appended as a // comment or query string to satisfy the substring check while the scheme stays attacker-controlled.

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

**XSS payload URL with javascript: ionUrl**

```
https://www.evernote.com/shard/s1/client/snv?view=after-save-note&ionUrl=javascript:alert(document.cookie)//https://www.evernote.com/
```

