Skip to content
XSS Disclosed report Intermediate

DOM Based XSS via postMessage at https://inventory.upserve.com/login/

The login page at inventory.upserve.com listens for postMessage events and runs any code in the 'exec' property of the message data using eval, but only checks whether the sender's origin contains the string 'https://hq.upserve.com' anywhere. An attacker can host a page on a domain like hq.upserve.com.mydomain.com, send a crafted message, and execute arbitrary JavaScript in the context of the login page, potentially stealing credentials.

gamer7112 Follow

Originally disclosed on HackerOne

Bounty$2,500 High 7.1 View original
  • Paid in 5 days
  • Disclosed after 17 days

Summary by the program

Due to incomplete origin validation, DOM-based XSS was possible at https://inventory.upserve.com/login/ when receiving a postMessage.

The report

#Description DOM based XSS is possible at https://inventory.upserve.com/login/ due to insecure origin checking when receiving a postMessage.

#POC

  1. Visit https://hq.upserve.com.████████/upserve_xss.html
  2. Click link
  3. View alert on https://inventory.upserve.com

#Vulnerable Code

JavaScript
window.addEventListener("message", function(e) {
  if (~e.origin.indexOf("https://hq.upserve.com")) {
    if (e.data && typeof e.data == "object") {
      try {
        if (e.data["exec"]) {
          eval(e.data["exec"]);
        }
      } catch (err) {
        console.log(err);
      }
    } else {
      console.log("Non-object passed");
    }
  } else {
    console.log("Incorrect origin: " + e.origin.toString());
    return;
  }
});

The origin check simply determines if "https://hq.upserve.com" is anywhere in the origin so an origin like "https://hq.upserve.com.mydomain.com" will pass this check just fine.

Impact

Due to the page being a login page, login credentials could be logged and stolen when a victim goes to login.

The original report as published on HackerOne, by gamer7112. 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

The origin check uses a substring match (indexOf) instead of an exact comparison, so any origin containing the trusted string passes, and the message data is passed directly to eval.

Impact

Because the vulnerable page is a login page, an attacker could log and steal login credentials when a victim goes to log in.

What the attacker needed

Victim visits attacker page; attacker controls a domain containing the trusted string

How it was found

  1. Visit the attacker-controlled page hosted on a domain whose name contains the trusted origin string.
  2. Click the link on that page.
  3. Observe the alert box appear on the inventory.upserve.com login page.

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 login page was set up to accept messages from other websites and then run whatever code those messages contained. It tried to check that the message came from a trusted site, but the check was too loose: it only looked for the trusted site's name somewhere inside the sender's address. An attacker could register a similar-looking address that contains the trusted name and use it to send malicious code, which would then run on the login page and could steal what the victim types.

What is XSS?

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

More by gamer7112

View all

9 more disclosed reports, best first.

More from Upserve

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.