When URL parsers disagree (CVE-2023-38633)
librsvg used two different URL parsers: one to validate a URL and another to load its contents. An attacker could craft an SVG with a file:// URL that passed validation but was interpreted differently by the loader, allowing arbitrary local files to be included in the rendered image.
OverviewSubscribe
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 root cause is that librsvg validated URLs using Rust's url crate but then loaded them using GLib's Gio, and the two parsers handle file:// URLs differently, especially with query strings and path traversal.
Impact
An attacker could include arbitrary files from the local filesystem in the rendered image, but only when the SVG is loaded from a file:// URL; SVGs loaded via data: or resource: schemes are not vulnerable.
What the attacker needed
SVG loaded from a file:// URL; librsvg version before patch
How it was found
- Set up a fuzzing harness that mimics librsvg's URL resolution logic.
- Fuzz inputs to find URLs that pass validation but are interpreted differently by the loader.
- Discover that a URL with a query string containing path traversal passes validation.
- Bypass canonicalization by using '.' as a placeholder for the current directory.
- Craft an SVG with an xi:include element using the malicious URL.
- Render the SVG with rsvg-convert to include /etc/passwd in the output image.
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.
When a program handles a web address (URL), it may use one piece of code to check if the address is safe and a different piece to actually fetch it. If these two pieces disagree about what the address means, a malicious address can sneak past the check. Here, an SVG image could contain a file address that looked safe to the checker but pointed to a sensitive file when loaded, letting the attacker read local files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.