Skip to content
Path traversal Advisory Intermediate

GHSL-2020-252: Unsafe handling of symbolic links in archiver unpacking routine

The archiver library's untar routine fails to properly validate symbolic links, allowing a malicious tarball to create links that escape the extraction directory. An attacker could read or write arbitrary files outside the intended target folder.

ghsecuritylab Follow

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.

ghsecuritylab, on GitHub Security Lab

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 checks each symbolic link's target against the extraction directory but does not account for previously created symlinks that can be used to bypass the check.

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

The fix

The issue was closed as wontfix, so no fix was applied; the library should be fixed by properly resolving symlinks and ensuring they do not escape the extraction directory.

How it was found

  1. Create a tar archive with a symlink entry named 'subdir/parent' pointing to '..'.
  2. Add another symlink entry named 'subdir/parent/passwd' pointing to '../../etc/passwd'.
  3. Add a third symlink entry named 'subdir/parent/etc' pointing to '../../etc'.
  4. Extract the archive using the vulnerable untar routine.
  5. The symlinks are created 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 tries to keep all files inside the folder you choose. This report shows that by using symbolic links (shortcuts that point to other files), an attacker can trick the program into creating links that point outside that folder. Then the attacker could read or overwrite files anywhere the program has permission to access.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by ghsecuritylab

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.