Skip to content
Path traversal Write-up Intermediate

Busybox cpio directory traversal vulnerability (CVE-2023-39810)

BusyBox cpio extracts archives containing relative file names with ../ traversal patterns, writing files outside the destination directory. An attacker could overwrite files such as shell configuration or SSH authorised keys if an untrusted archive is extracted.

Pentagrid AG Follow

Published on pentagrid.ch

When extracting cpio archives with BusyBox cpio, the cpio archiving tools may write files outside the destination directory and there is no option to prevent this.

Pentagrid AG, on pentagrid.ch

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

BusyBox cpio does not filter or reject relative file names containing ../ traversal patterns during extraction.

Impact

If an untrusted archive is extracted, files outside the destination directory could be overwritten, including shell configuration or SSH authorised keys, potentially enabling remote login.

What the attacker needed

Untrusted cpio archive; extraction with BusyBox cpio; write permission outside destination

The fix

A patch was published to filter relative file names but was not merged into BusyBox at the time of the advisory; the recommendation is to change the default behaviour to ignore ../ patterns and add an opt-in flag.

How it was found

  1. Create a test archive containing a file name with a ../ traversal pattern and an absolute file name.
  2. Remove the original test file to prepare for extraction.
  3. Extract the archive with BusyBox cpio into a subdirectory.
  4. List the files to observe that the test file was written outside the working 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 write-up has not been written yet. The Original tab links to the source.

When you unpack an archive, you expect files to stay in the folder you chose. BusyBox cpio does not check for file names that use '..' to climb up the folder tree, so a malicious archive can write files anywhere the user has permission. This could let an attacker replace your shell startup file or add a key that lets them log in remotely.

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 Pentagrid AG

View all

7 more disclosed reports, best first.

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.