GHSL-2020-258: ZipSlip vulnerability in bblfshd - CVE-2021-32825
The tar extraction routine in bblfshd attempted to prevent symlinks from escaping the target directory, but a crafted archive with nested symlinks could bypass this check. An attacker controlling the archive could write arbitrary files outside the extraction directory and potentially read arbitrary system files.
Originally disclosed on GitHub Security Lab
The unsafe handling of symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations outside the designated target folder.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The symlink check only compared the resolved target path against the destination prefix, but did not account for previously created symlinks that could redirect the path outside the destination.
Impact
This issue may lead to arbitrary file write (with same permissions as the program running the unpack operation) if the attacker can control the archive file. Additionally, if the attacker has read access to the unpacked files, he may be able to read arbitrary system files the parent process has permissions to read.
What the attacker needed
Attacker controls the tar archive; victim extracts the archive
How it was found
- Create a tar archive containing a symlink named subdir/parent pointing to ..
- Add another symlink named subdir/parent/escapes pointing to ..
- Extract the archive using the vulnerable untar routine
- The second symlink resolves outside the intended extraction directory
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.
When you extract a tar archive, the program should keep all files inside the folder you choose. This report shows that a malicious archive could trick the program into creating links that point outside that folder, letting an attacker write or read files anywhere the program has permission.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.