Skip to content
Path traversal Advisory Intermediate

GHSL-2023-120: Arbitrary File Read/Write during TAR extraction in Gradle

Gradle 8.1.1 does not validate paths from TAR archive entries, allowing an attacker who can manipulate a TAR file to write arbitrary files when unpacked or read arbitrary files when read by a Gradle script.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

Gradle 8.1.1 does not ensure that paths constructed from TAR archive entries are validated. This allows attackers who are able to manipulate a TAR file which is unpacked by a Gradle script to overwrite arbitrary files.

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 method safeEntryName returns the entry name without checking for path traversal sequences, and this unvalidated name is used to construct file paths for both writing and reading.

Impact

This may lead to arbitrary file write when TAR entries are unpacked or to information disclosure through an arbitrary file read when TAR entries are read; exploitation is limited to directories where file permissions can be set.

What the attacker needed

Attacker can supply a malicious TAR file; victim runs a Gradle script that extracts or reads the TAR

How it was found

  1. Create a TAR file with an entry name containing path traversal sequences.
  2. Use a Gradle script to extract the TAR file using tarTree.
  3. The file is written outside the intended 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 file, the names inside it are used to decide where files go. If those names contain '../', the files can end up outside the intended folder. This means someone who can give you a malicious TAR file could overwrite important files or read sensitive ones.

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.