Skip to content

Capture screenshot of localhost web services (unauthenticated pages)

Low
jasonraimondi published GHSA-342q-2mc2-5gmp Jul 13, 2024

Package

npm @jmondi/url-to-png (npm)

Affected versions

<2.1.0

Patched versions

None

Description

Summary

I have been contemplating whether FTP or other protocols could serve as useful functionalities, but there may not be a practical reason for it since we are utilizing headless Chrome to capture screenshots. My argument is based on the assumption that this package can function as a service.

The package includes an ALLOW_LIST where the host can specify which services the user is permitted to capture screenshots of. By default, capturing screenshots of web services running on localhost, 127.0.0.1, or the [::] is allowed.

I am of the opinion that the package should also have a blacklist due to a potential vulnerability (or rather design oversight). If someone hosts this on a server, users could then capture screenshots of other web services running locally.

Unless this is strictly for web pages. Something similar here: follow-redirects/follow-redirects#235 (localhost is intended for end users or hosts to deny, and the package is for HTTP/HTTPS.)

I am marking this as a LOW since I am not sure if this is a vulnerability, but it's still best to highlight it. :)

PoC

Have a service like so running locally:

const http = require("http")

const server = http.createServer((req, res) => {
  console.log("Received headers:", req.headers)
  res.writeHead(200, { "Content-Type": "text/plain" })
  res.end("Something private! But Hello from Server 2 :)")
})

server.listen(3001, () => {
  console.log("Server two running on http://localhost:3001")
})

Run the package in dev mode, pnpm dev. Feed these URLs:

http://localhost:3089/?url=http://[::]:3001&width=4000
http://localhost:3089/?url=http://localhost:3001&width=4000
http://localhost:3089/?url=http://127.0.01:3001&width=4000
image

Impact

Disclose internal web services?

Severity

Low

CVE ID

CVE-2024-39919

Weaknesses

No CWEs

Credits