How Malicious Hackers Can Takeover Your Headless Browser Part 1
A headless browser running on a server without sandboxing and without URL whitelisting can be abused by an attacker to perform server-side request forgery (SSRF). The attacker can make the browser visit a malicious site, which then requests internal resources that the server would normally protect, and the data is exfiltrated back to the attacker.
Headless browsers, such as Puppeteer, Selenium, and Playwright, are extremely useful tools for automation, testing, and web scraping. However, running a headless browser on your server or backend have can have a large risk of getting abused by a malicious hacker.
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
Likely the headless browser runs without sandboxing and accepts arbitrary URLs without whitelisting, allowing it to be used as a proxy to access internal resources.
Impact
An attacker could steal private data that is only accessible to the server, because the headless browser's requests originate from the server and bypass typical authentication.
What the attacker needed
Headless browser on server; no sandboxing; no URL whitelisting; attacker can supply URL
The fix
The headless browser should be run with sandboxing and any user-supplied URL should be whitelisted.
How it was found
- Create a malicious site (attacker.com).
- Send a request to victim.com with URL=attacker.com.
- Victim server launches a headless browser to visit attacker.com.
- Headless browser visits attacker.com.
- attacker.com issues a request for information that should only be accessible to the server.
- Headless browser sends the request to the victim server, which approves it because it originates from the server, and returns the resources to the headless browser, which sends them back to attacker.com.
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.
A headless browser is a web browser without a visible window, often used on servers to load web pages automatically. If such a browser is not properly isolated (sandboxed) and can be told to visit any web address, an attacker can make it visit a malicious site. That site can then ask the browser to fetch private information from the server, which the browser does because it appears to come from the server itself.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.