GHSL-2020-261: Unsafe handling of symbolic links in oc unpacking routine - CVE-2020-27833
The unpacking routine in oc did not properly handle symbolic links in tar archives, allowing a malicious archive to create links that point outside the extraction directory. An attacker could read or write arbitrary files with the permissions of the unpacking process.
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 routine checked each symbolic link's target against the extraction directory but did not account for previously created symlinks that could redirect the path, allowing a second symlink to escape.
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 with oc
How it was found
- Create a tar archive containing a directory entry.
- Add a symbolic link inside that directory pointing to the parent directory.
- Add another symbolic link inside the first link pointing further up.
- Extract the archive with the vulnerable routine, causing files to be written outside the target folder.
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 file, the program tries to keep all files inside the folder you choose. This report shows that by using a chain of symbolic links (shortcuts), an attacker could trick the program into creating files outside that folder, potentially overwriting important system files or reading sensitive data.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.