Skip to content
XSS Write-up Intermediate

CVE-2023-1767 - Stored XSS on Snyk Advisor service can allow full fabrication of npm packages health score

A stored cross-site scripting (XSS) vulnerability in Snyk Advisor allowed an attacker to execute JavaScript in the context of the snyk.io domain by embedding malicious HTML in a package's README file. This enabled the attacker to alter the displayed health score and other information, potentially convincing developers to install a malicious npm package.

Gal Weizman Follow

Published on weizman.github.io

Vulnerability Disclosure Report 📝 , Exploit PoC 💻

Gal Weizman, on weizman.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The application rendered Markdown from package READMEs without sanitising the resulting HTML and without a Content Security Policy (CSP) to block script execution.

Impact

An attacker could fabricate a package's health score and other details to make a malicious package appear trustworthy, potentially leading developers to install it and compromise their software.

What the attacker needed

Ability to publish an npm package; victim visits the Snyk Advisor page

The fix

The vulnerability was fixed by Snyk; the report does not detail the exact fix, but proper sanitisation of Markdown and implementation of CSP are recommended.

How it was found

  1. Register a new npm package with a name that seems legitimate.
  2. Add a malicious payload to the package's code.
  3. Create a README file that includes HTML with an event handler to execute JavaScript.
  4. Publish the package and wait for Snyk Advisor to scan it.
  5. Visit the Snyk Advisor page for the package to trigger the XSS.
  6. Use the JavaScript to modify the page content, such as the health score and other details.

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 write-up has not been written yet. The Original tab links to the source.

Snyk Advisor is a website that shows how safe and popular an npm package is. The vulnerability let an attacker run their own code on that website by putting special code in a package's README file. This meant the attacker could change what the website showed, making a bad package look good.

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 Gal Weizman

View all

3 more disclosed reports, best first.

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.