Possible DOM XSS on app.hey.com
The search box on app.hey.com reflects the email subject into the DOM without proper sanitisation, allowing HTML injection. An attacker could send an email with a crafted subject and if the victim searches for it, a link with a javascript: URL is rendered, but script execution is blocked by the Content Security Policy (CSP).
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 5 days
- Paid in 3 days
- Disclosed after 11 days
#Summary:
Hello Team, While testing it was observed that on https://app.hey.com/, on Search box there is a possibility of XSS. Although the payload is reflected in the DOM but the CSP blocks the execution of the script, the XSS can happen if the CSP is somehow bypassed. The Subject parameter is vulnerable.
Apart from XSS, the HTML injection attack is working pretty straight forward.
#Steps To Reproduce:
- Go to https://app.hey.com
- Login to your account.
- Click on 'Write' Mail button.
- Add the recipient as yourself.
- In the Subject, add following payload
TestPayload</a><a href="javascript:alert(1)">ClickHere</a>
- Send the mail.
- Go to top left corner Search Box and type "TestPayload"
- You will see the mail you sent to yourself, and <a> tag will be there "ClickHere".
- Click on it, you will see the CSP violation in the Console.
- Below is the CSP of the page:
script-src 'self' https://production.haystack-assets.com stats.hey.com *.braintreegateway.com *.braintree-api.com hcaptcha.com *.hcaptcha.com;
object-src 'none';
base-uri 'none';
form-action 'self';
frame-ancestors 'none';
report-uri https://sentry.io/api/1371426/security/?sentry_key=3a5ea420eecc45bd9e1d1c2424683f3a&sentry_environment=production&sentry_release=
As seen from the CSP, there might be a possibility of Host whitelists bypass.
Impact
If attacker send such type of mail to a victim and if victim accidentally searches for the same mail then the Script will be executed leading to account takeover. This is possible only if CSP is bypassed.
Context
HEY is Basecamp's email service, and https://app.hey.com is its web mail client. The feature at the centre of this report is the Search box in the top left corner of the interface, which lets a signed-in user search their own mailbox.
The researcher found that a crafted subject line produces a working link in the search results. That gives HTML injection, and because the injected anchor can carry a javascript: URL, it also gives a DOM-based cross-site scripting primitive. The script itself does not run, because the page's Content Security Policy blocks it. The report is therefore about a stored injection that is one CSP bypass away from executing.
Setup
No special tooling is described. The preconditions are simply:
- A HEY account, used to log in at
https://app.hey.com. - The ability to send mail to yourself from that account, so that a crafted subject lands in your own mailbox and becomes searchable.
- A browser console, used to observe the CSP violation when the injected link is clicked.
Finding it
While testing the application, the researcher observed that the Search box on https://app.hey.com offered a possibility of XSS. The Subject parameter was identified as the vulnerable one. The payload is reflected into the DOM, but the CSP blocks execution of the script, so the XSS only materialises if the CSP can somehow be bypassed. Independently of the script execution question, the HTML injection works straightforwardly: injected markup in a subject is rendered as markup in the search results.
Exploitation
Step 1: open the application and sign in
Go to https://app.hey.com and log in to your account. All subsequent steps happen inside the authenticated mail client.
Step 2: compose a mail to yourself
Click the 'Write' mail button and add yourself as the recipient. Sending to your own address is what makes the message appear in your own mailbox, and therefore in your own search results.
Step 3: put the payload in the Subject
In the Subject field, enter the following:
TestPayload</a><a href="javascript:alert(1)">ClickHere</a>
The value is HTML-entity encoded: < and > stand in for < and >. Decoded, the subject reads TestPayload</a><a href="javascript:alert(1)">ClickHere</a>. The visible link text is ClickHere.
Step 4: send the mail
Send the message. It is now stored in your mailbox with the crafted subject.
Step 5: search for the subject
Go to the Search box in the top left corner and type TestPayload. The message you sent to yourself appears in the results, and the <a> tag is present there, rendered as a link labelled ClickHere.
Step 6: click the injected link
Click ClickHere. The javascript:alert(1) URL is not executed; instead the CSP violation appears in the browser console. The page's policy is:
script-src 'self' https://production.haystack-assets.com stats.hey.com *.braintreegateway.com *.braintree-api.com hcaptcha.com *.hcaptcha.com;
object-src 'none';
base-uri 'none';
form-action 'self';
frame-ancestors 'none';
report-uri https://sentry.io/api/1371426/security/?sentry_key=[redacted]&sentry_environment=production&sentry_release=
Reading the directives:
script-srcallows scripts only from the application's own origin,https://production.haystack-assets.com,stats.hey.com, the Braintree gateway and API hosts, and hCaptcha hosts. Ajavascript:URL does not satisfy this list, which is why the alert never fires.object-src 'none'blocks plugin content.base-uri 'none'prevents an injected<base>element from changing how relative URLs resolve.form-action 'self'restricts where forms can submit.frame-ancestors 'none'prevents the page being framed.report-urisends violation reports to a Sentry endpoint, which is how the researcher saw the block reported.
The researcher noted that, given the hosts on the script-src whitelist, there might be a possibility of a host whitelist bypass. That is the gap between the HTML injection that demonstrably works and the script execution that the policy currently prevents.
Root cause
The only thing standing between the injection and script execution is the CSP. The policy is strict about javascript: URLs, so the payload as written is blocked, but the script-src list contains several third-party hosts. The researcher noted that a host whitelist bypass might be possible. The report does not demonstrate such a bypass.
Impact
The researcher's stated scenario is a mail sent by an attacker to a victim. If the victim then accidentally searches for the same mail, the injected markup is rendered in the results, and if the CSP is bypassed the script executes, leading to account takeover. Both conditions matter: the victim has to perform the search that surfaces the message, and the CSP has to be defeated. The report is explicit that execution is possible only if the CSP is bypassed. The HTML injection on its own works without any of that.
Fix
The report does not describe a fix or a subsequent change to the application.
Variants to test
- Other fields rendered in search results. Try sender display names, snippet text and folder or label names with the same encoded anchor payload. A positive result is the markup rendering as a link in the results list rather than as literal text.
- Other rendering contexts. Vary the closing tag to match the element the value sits inside, for example
</div>,</span>or</td>, and check whether the injected element appears in the DOM. A positive result is a new element in the results markup that you control. - Attribute-context injection. If a value lands inside an attribute rather than between tags, try breaking out of the quoted attribute. A positive result is a new attribute or event handler appearing on the rendered element.
- CSP whitelist review. Enumerate every host in
script-srcand look for JSONP endpoints, user-uploaded script hosting or open redirects on those hosts. A positive result is a URL on a whitelisted host that returns attacker-controlled JavaScript, which would let thejavascript:payload be replaced with a script load the policy permits. - Same pattern in other Basecamp products. Apply the self-addressed mail and search sequence to other mail or message search interfaces in the same family. A positive result is the same breakout in the results rendering.
Hunting notes
The signal during testing is simple: send yourself content containing encoded angle brackets and search for it. If the brackets come back as markup, you have injection; the console then tells you whether a CSP is the only thing in the way.
What happened, in plain words
HEY is an email service made by Basecamp. When you sign in to HEY in a browser, you use a web mail client at https://app.hey.com: a website that shows your inbox, lets you write mail and lets you search your own messages. This report is about one small part of that website, the Search box in the top left corner.
A researcher found that a crafted subject line shows up as a working link in search results. That is called HTML injection. Because the injected text can contain a link that tries to run a small piece of JavaScript (the programming language that web pages use to do things in your browser), the finding is also described as a cross-site scripting (XSS) issue. In this case the browser refuses to run the script, because the site has a rule set called a Content Security Policy (CSP) that says which scripts are allowed. So the injection works, but the script does not run. The report is about a stored injection that is one CSP bypass away from running code.
Background you need first
A few ideas come up again and again below, so here they are from zero.
- HTML is the language that describes what a web page contains: headings, paragraphs, links, images. A link is written with an
<a>tag, and the address it points to is stored in an attribute calledhref. For example,<a href="https://example.com">ClickHere</a>shows the words ClickHere and sends you to example.com when you click. - Escaping means turning characters that have a special meaning in HTML into harmless stand-ins. The character
<is special because it starts a tag, so it can be written as<, and>as>. A browser reading<shows a literal<on the page instead of treating it as the start of a tag. This is how a website can display user text safely: it escapes the text so it is shown as words, not interpreted as page structure. - The DOM (Document Object Model) is the browser's live, in-memory model of the page. When a site puts text into the page with JavaScript, it is changing the DOM. If a site inserts text into the DOM as HTML rather than as plain text, any tags inside that text become real page elements.
- JavaScript is the code that runs inside web pages.
alert(1)is the classic tiny test: it makes the browser pop up a box with the number 1 in it. If a page can be made to runalert(1)from someone else's input, that is the usual proof that script execution is possible. - A
javascript:URL is a link address that starts withjavascript:instead ofhttps:. Clicking such a link makes the browser run the code that follows. It is a way of turning a link into a script trigger. - XSS (cross-site scripting) is a class of bug where someone else's content ends up being treated as code by a victim's browser. DOM-based XSS means the dangerous handling happens in the browser, in the page's own JavaScript, rather than on the server.
- Stored XSS means the malicious content is saved somewhere first (here, in an email in your mailbox) and is re-rendered later, whenever the page that displays it is opened.
- CSP (Content Security Policy) is a set of rules a website sends to the browser saying what the page is allowed to load and run. It is like a guest list at a door: even if someone hands you an invitation, the door only opens for names on the list. A CSP can say, for example, that scripts may only come from certain addresses. If a
javascript:link is not on the list, the browser blocks it and reports the attempt. - A whitelist is a list of things that are allowed. In a CSP, the
script-srcdirective is a whitelist of where scripts may come from. - The browser console is a panel built into browsers (usually opened with developer tools) that shows errors and messages from the page, including CSP violation reports. It is where you can see that a script was blocked.
The feature involved
The Search box in the top left corner of the HEY interface lets a signed-in user search their own mailbox. In other words, when you search, the site takes the subject lines of matching emails and displays them in the results list. That display step is where the problem is.
Setting up
No special tools are needed. The preconditions are:
- A HEY account, used to log in at
https://app.hey.com. - The ability to send mail to yourself from that account, so that a crafted subject lands in your own mailbox and becomes searchable.
- A browser console, used to observe the CSP violation when the injected link is clicked.
Sending mail to yourself is a common testing trick: it puts your test content into a place you fully control, so you can see exactly how the site handles it.
Finding it
While testing the application, the researcher observed that the Search box on https://app.hey.com offered a possibility of XSS. The Subject parameter was identified as the vulnerable one. The payload is reflected into the DOM, but the CSP blocks execution of the script, so the XSS only materialises if the CSP can somehow be bypassed. Independently of the script execution question, the HTML injection works straightforwardly: injected markup in a subject is rendered as markup in the search results.
Exploitation, step by step
Step 1: open the application and sign in
Go to https://app.hey.com and log in to your account. All subsequent steps happen inside the authenticated mail client. You need to be signed in because the search only covers your own mailbox.
Step 2: compose a mail to yourself
Click the 'Write' mail button and add yourself as the recipient. Sending to your own address is what makes the message appear in your own mailbox, and therefore in your own search results. If you sent it to someone else, you would not be able to search for it yourself.
Step 3: put the payload in the Subject
In the Subject field, enter the following:
TestPayload</a><a href="javascript:alert(1)">ClickHere</a>
Line by line, in plain words:
TestPayloadis an ordinary word. It is there so that you have something unique to type into the Search box later, and so you can recognise your own message in the results.</a>is the escaped form of</a>. A closing</a>tag ends a link.<a href="javascript:alert(1)">is the escaped form of<a href="javascript:alert(1)">. It opens a new link whose address is ajavascript:URL. If clicked and allowed to run, that address would make the browser show an alert box with the number 1.ClickHereis the visible text of that new link, so there is something obvious to click.</a>closes the new link.
The visible link text is ClickHere.
Step 4: send the mail
Send the message. It is now stored in your mailbox with the crafted subject. This is the "stored" part of stored XSS: the content sits in the mailbox and will be shown again every time something displays it.
Step 5: search for the subject
Go to the Search box in the top left corner and type TestPayload. The message you sent to yourself appears in the results, and the <a> tag is present there, rendered as a link labelled ClickHere. If the site had escaped the subject properly, you would see the literal characters of the payload instead of a working link. Seeing a link is the proof of HTML injection.
Step 6: click the injected link
Click ClickHere. The javascript:alert(1) URL is not executed; instead the CSP violation appears in the browser console. The page's policy is:
script-src 'self' https://production.haystack-assets.com stats.hey.com *.braintreegateway.com *.braintree-api.com hcaptcha.com *.hcaptcha.com;
object-src 'none';
base-uri 'none';
form-action 'self';
frame-ancestors 'none';
report-uri https://sentry.io/api/1371426/security/?sentry_key=[redacted]&sentry_environment=production&sentry_release=
Reading the directives, one at a time:
script-srcis the guest list for scripts. It allows scripts only from the application's own origin ('self'),https://production.haystack-assets.com,stats.hey.com, the Braintree gateway and API hosts, and hCaptcha hosts. Ajavascript:URL does not satisfy this list, which is why the alert never fires.object-src 'none'blocks plugin content, such as embedded objects that could run code.base-uri 'none'prevents an injected<base>element from changing how relative URLs resolve. Without this, an attacker could redirect every relative link on the page.form-action 'self'restricts where forms can submit, so an injected form cannot send your data elsewhere.frame-ancestors 'none'prevents the page being framed inside another site, which blocks a class of clickjacking tricks.report-urisends violation reports to a Sentry endpoint, which is how the researcher saw the block reported. Sentry is a service for collecting error and security reports.
The researcher noted that, given the hosts on the script-src whitelist, there might be a possibility of a host whitelist bypass. That is the gap between the HTML injection that demonstrably works and the script execution that the policy currently prevents. In everyday terms: the door is locked, but the guest list includes several outside companies, and if any of them can be tricked into serving code the attacker wants, the lock may not matter.
Why it happens
The only thing standing between the injection and script execution is the CSP. The policy is strict about javascript: URLs, so the payload as written is blocked, but the script-src list contains several third-party hosts. The researcher noted that a host whitelist bypass might be possible. The report does not demonstrate such a bypass.
Impact
The researcher's stated scenario is a mail sent by an attacker to a victim. If the victim then accidentally searches for the same mail, the injected markup is rendered in the results, and if the CSP is bypassed the script executes, leading to account takeover. Account takeover means the attacker ends up in control of the victim's account.
Both conditions matter: the victim has to perform the search that surfaces the message, and the CSP has to be defeated. The report is explicit that execution is possible only if the CSP is bypassed. The HTML injection on its own works without any of that.
Fix
The report does not describe a fix or a subsequent change to the application.
Variants to test
- Other fields rendered in search results. Try sender display names, snippet text and folder or label names with the same encoded anchor payload. A positive result is the markup rendering as a link in the results list rather than as literal text.
- Other rendering contexts. Vary the closing tag to match the element the value sits inside, for example
</div>,</span>or</td>, and check whether the injected element appears in the DOM. A positive result is a new element in the results markup that you control. - Attribute-context injection. If a value lands inside an attribute rather than between tags, try breaking out of the quoted attribute. A positive result is a new attribute or event handler appearing on the rendered element.
- CSP whitelist review. Enumerate every host in
script-srcand look for JSONP endpoints, user-uploaded script hosting or open redirects on those hosts. A positive result is a URL on a whitelisted host that returns attacker-controlled JavaScript, which would let thejavascript:payload be replaced with a script load the policy permits. - Same pattern in other Basecamp products. Apply the self-addressed mail and search sequence to other mail or message search interfaces in the same family. A positive result is the same breakout in the results rendering.
Hunting notes
The signal during testing is simple: send yourself content containing encoded angle brackets and search for it. If the brackets come back as markup, you have injection; the console then tells you whether a CSP is the only thing in the way.
Glossary
- HTML: the language that describes the structure and content of a web page, using tags such as
<a>for links. - Tag: a piece of HTML markup, such as
<a>or</a>, that tells the browser what an element is and where it starts or ends. - Attribute: a setting inside an HTML tag, such as
hrefon a link, that gives the element extra information. href: the attribute of a link that holds its destination address.- Escaping / HTML entities: writing special characters in a safe stand-in form, such as
<for<and>for>, so they display as text instead of being interpreted as markup. - DOM (Document Object Model): the browser's live model of the page, which scripts read and change.
- JavaScript: the programming language that runs inside web pages.
alert(1): a JavaScript command that opens a browser pop-up showing the number 1, commonly used as a harmless proof of script execution.javascript:URL: a link address that runs JavaScript when clicked, instead of navigating to a page.- XSS (cross-site scripting): a bug class where someone else's content is treated as code by a victim's browser.
- DOM-based XSS: XSS where the unsafe handling happens in the browser's own page script rather than on the server.
- Stored XSS: XSS where the malicious content is saved first and re-rendered later, for example from an email in a mailbox.
- HTML injection: getting your own HTML markup into a page so that it becomes real elements, even if no script runs.
- CSP (Content Security Policy): rules sent by a site telling the browser what it may load and run, including which sources scripts may come from.
- Directive: one rule inside a CSP, such as
script-srcorform-action. script-src: the CSP directive that whitelists where scripts may come from.object-src: the CSP directive controlling plugin content; here set to'none'to block it.base-uri: the CSP directive controlling whether a<base>element may change how relative URLs resolve.form-action: the CSP directive restricting where forms may submit.frame-ancestors: the CSP directive controlling whether the page may be embedded in a frame on another site.report-uri: the CSP directive that says where violation reports are sent.- Whitelist: a list of things that are allowed; here, the hosts permitted by
script-src. - Whitelist bypass: finding a way to get code to run from a host that is on the allowed list, defeating the point of the list.
- Origin: the combination of scheme, host and port that identifies where a page or resource comes from;
'self'in a CSP means the page's own origin. - Third-party host: a server run by another company that a site loads resources from.
- Sentry: a service for collecting error and security reports from applications.
- Browser console: a browser panel that shows page errors and messages, including CSP violations.
- Account takeover: a situation where an attacker gains control of a victim's account.
- JSONP: a technique for loading data across sites by returning it as a script, which can be abused if a whitelisted host offers it.
- Open redirect: a link on a site that sends visitors to an address supplied in the link, which can be abused to make a trusted host point elsewhere.
- Parameter: a named input value that a feature accepts, such as the subject of an email.