# GHSA-WMW5-Q587-GX56: schollz/croc path traversal

- Database: GitHub
- Severity: CVSS 6.4 (Medium)
- Published: 2026-08-21
- Modified: 2026-09-20

## Affected versions

- github.com/schollz/croc/v10 (Go): through 11.0.2

## Description

### Summary
A malicious **sender** can delete arbitrary files (and empty directories) on a **receiver's** machine (anywhere the receiving user has permission ofc) by sending a file named `croc-marked-files.txt`. croc uses that exact filename in the current working directory as its internal "delete these temp files on exit" list, and deletes every path it contains **without any validation**. Because a received file with that name lands in the receiver's working directory (the default receive location), the incoming file *becomes* the deletion list, and its contents are fully attacker-controlled. Deletion runs automatically when the transfer completes and also on Ctrl-C.

### Details
Two functions in `src/utils/utils.go` implement a cleanup mechanism for temporary files:

- `const crocRemovalFile = "croc-marked-files.txt"`  a **fixed, relative** path resolved against the current working directory.
- `RemoveMarkedFiles()` opens that file and runs `os.Remove(line)` for **every line, with no path validation and no confinement to the working directory**, so absolute paths and `../` traversal are honored.

`RemoveMarkedFiles()` is invoked on **normal exit** (`main.go:45`) and on **SIGINT/Ctrl-C** (`main.go:51`) after any receive.

The receiver writes incoming top-level files into the current working directory (`FolderRemote = "./"`), and the name `croc-marked-files.txt` passes `utils.ValidFileName` (it is an ordinary basename with no separators). 

As a result, a sender who sends a file **named** `croc-marked-files.txt` whose **contents** are a newline-separated list of victim paths causes those paths to be deleted on the receiver when croc exits.

Relevant code:
- `src/utils/utils.go` :  `crocRemovalFile`, `MarkFileForRemoval`, `RemoveMarkedFiles`
- `main.go:45` and `main.go:51` : cleanup invocation
- receive path writes top-level files to the CWD

The paths are taken verbatim from attacker-controlled file content, so this is **External Control of File Name or Path** used in a delete operation, combined with **Path Traversal** (absolute / `../`).

### PoC
Using a local relay (nothing leaves the machine). On UNIX the code phrase is passed via `CROC_SECRET`.

1. **Attacker** crafts and sends the payload:
```
   mkdir -p /tmp/attacker && cd /tmp/attacker
   printf 'secret.txt\n../victim-sibling.txt\n/tmp/absolute-target.txt\n' > croc-marked-files.txt
   croc send croc-marked-files.txt
```

2. **Victim** receives into a directory containing valuable files:
```
   mkdir -p /tmp/victim && cd /tmp/victim
   echo A > secret.txt                 # relative (CWD)
   echo B > /tmp/victim-sibling.txt     # wait: place at ../ target
   echo C > /tmp/absolute-target.txt    # absolute
   CROC_SECRET=<SECRET> croc  --yes
```
3. On completion, `secret.txt`, the `../` target, and the absolute-path target
are all deleted. The same occurs if the receiver presses Ctrl-C after the
file has arrived.

Verified: CWD-relative, `../` traversal (escapes the receive directory), and absolute paths all delete; deletion is attributable solely to the receiver.

### Impact
A peer you are **receiving from** can delete arbitrary files and empty directories owned by the receiving user (e.g. `~/.ssh/authorized_keys`, dotfiles, documents, project files). It triggers on normal completion (silently with `--yes`)

This far exceeds the expected "receive a file into this folder" trust boundary.

### Impact escalation -> Remote Code Execution (The Arbitrary File Deletion vulnerability can be chained)

The same primitive (a sender fully controls the basename, dotfiles included, and content of files written into the receive directory) escalates to code execution when the victim receives into their home directory:

1. **Bypass the overwrite prompt (uses the deletion bug above).** Transfer 1
    sends `croc-marked-files.txt` whose contents list the victim's existing shell-init file (e.g. `.bashrc`). On exit, `RemoveMarkedFiles()` deletes it.
<img width="1546" height="292" alt="image" src="https://github.com/user-attachments/assets/614c64d1-c724-4c26-96c7-452be01f1fc7" />



2. **Plant a malicious init file.** Transfer 2 sends a file named `.bashrc`
   Because the original was deleted, no overwrite prompt will fire
<img width="1436" height="364" alt="image" src="https://github.com/user-attachments/assets/2407be38-af2c-4143-98aa-85c5d3a40d1e" />

3. Dilevery : The victim runs `CROC_SECRET=<SECRET> croc … --yes` twice ( the first transfer (`croc-marked-files.txt`) deletes `~/.bashrc` on exit, and the second writes the attacker's malicious `~/.bashrc` with no overwrite prompt.
<img width="1570" height="368" alt="image" src="https://github.com/user-attachments/assets/7c507c4f-0e42-44f5-b0b5-a1e58070f106" />

 


4.  **Execution.** The attacker's code runs as the victim on the next shell / login (for a server, on the next SSH login).
<img width="1438" height="238" alt="image" src="https://github.com/user-attachments/assets/c29fe826-6133-4243-ab9b-cee21b4fa506" />

**Important:** the victim must run `croc` from `$HOME` so its `.bashrc` gets replaced (received *writes* are confined to the working-directory subtree; the *delete* is not confined and accepts absolute/`..` paths), two transfers must be accepted (silent with `--yes`; otherwise the filenames appear in the accept prompt)

## References

- https://github.com/schollz/croc/security/advisories/GHSA-wmw5-q587-gx56

Page: https://cve.now/GHSA-WMW5-Q587-GX56

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
