Discovering and Exploiting a Path Traversal Vulnerability in Chromium’s md_browser Tool
The md_browser.py tool in Chromium serves files from a directory without checking whether a requested file is a symlink pointing outside that directory. An attacker who can place a malicious markdown file (which is actually a symlink) in the hosted directory can read arbitrary files on the victim's system via an HTTP request.
Published on medium.com
While analyzing the source code of Chromium’s repository, I discovered a path traversal vulnerability in one of its tools, mdbrowser.
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 tool fails to resolve symlinks and verify that the real path stays within the served directory before returning file contents.
Impact
An attacker could read arbitrary files on the victim's system, such as SSH private keys, and if the script runs as root, could gain root access.
What the attacker needed
Victim hosts a directory with md_browser; attacker can place a symlink file in that directory; victim runs the script (possibly as root)
The fix
The tool should be fixed by resolving each requested path and rejecting any that fall outside the served root directory.
How it was found
- Create a markdown file that is a symlink to a sensitive file such as /etc/passwd.
- Place that file in a directory you want to serve.
- Run md_browser.py pointing to that directory and a port.
- Request the malicious markdown file over HTTP to retrieve the symlinked file's contents.
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 symlink is like a shortcut that points to another file. The tool lets you share a folder of markdown files over the web, but it does not check if a file in that folder is actually a shortcut to something secret, like your SSH key. So if someone tricks you into putting such a shortcut in the folder, they can download the secret file through the web server.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.