Skip to content
Path traversal Advisory Intermediate CVE-2020-29529

GHSL-2020-262: Unsafe handling of symbolic links in go-slug unpacking routine - CVE-2020-29529

The go-slug library's Unpack routine failed to properly validate symbolic links in tar archives, allowing a crafted archive to create a symlink that points outside the extraction directory. An attacker controlling the archive could read or write arbitrary files with the permissions of the unpacking process.

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 check for symlink targets used a simple string prefix comparison after joining paths, which fails to account for symlinks created earlier in the same archive that can redirect the resolved 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 runs Unpack on the archive

The fix

The vulnerability was fixed in go-slug 0.5 by improving the symlink target validation.

How it was found

  1. Create a tar archive containing a symlink named subdir/parent with target ..
  2. Add another symlink named subdir/parent/passwd with target ../../etc/passwd
  3. Add a third symlink named subdir/parent/etc with target ../../etc
  4. Run the Unpack routine on the archive, extracting to a destination 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. Here, a specially crafted archive could trick the program into creating a shortcut (symbolic link) that points to a folder outside, like your system's /etc. This lets an attacker read or overwrite files on your computer, depending on what permissions the extracting program has.

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.