github.com/schollz/croc/v11
Affected
- introduced
0, fixed11.5.2(semver)
Fixed versions
11.5.2
Fix
- Fixed version
11.5.2go get github.com/schollz/croc/[email protected]
Advisory
Also known as: CVE-2026-119298
croc: Overwrite-confirmation bypass via a crafted "croc-stdin-" filename on receive
Summary
croc is an end-to-end encrypted peer-to-peer file transfer tool. On the receiving side, the confirmation that normally protects an existing file from being overwritten or resumed is skipped whenever the received file's name starts with croc-stdin-, regardless of whether the incoming transfer is actually a text transfer. A sender can therefore name a file croc-stdin-<existing-name> and silently overwrite, truncate, or replace an existing file of that name in the receiver's working directory - including removing the existing file and substituting a symlink - without the Overwrite? prompt that the standard path requires. The exemption was introduced to keep croc's internal text-transfer artifacts from triggering prompts, but it is keyed on the filename prefix rather than on the transfer type, so any ordinary file transfer can claim the exemption.
Vulnerability Details
Affected code at commit b6f27da9401f2c3647c1adb6b77a46bb8c0923d2 (HEAD, v11.5.1+1):
The receive-side file-readiness loop in src/croc/croc.go decides whether to prompt before overwriting or resuming an existing destination file. The decision is made around line 3413:
isStdinName := strings.HasPrefix(path.Base(fileInfo.Name), "croc-stdin-")
...
if destinationExists && !c.Options.Overwrite && !c.Options.Rename && !isStdinName {
resumable := fileInfo.Size > 0 && fileInfo.Symlink == "" && recipientFileInfo.Mode().IsRegular()
overwrite, promptErr := askReceiveOverwrite(c.clientContext(), fileInfo, resumable)
if promptErr != nil {
return promptErr
}
if !overwrite {
continue
}
}
isStdinName is derived purely from the received file's basename. The prompt is suppressed for any such name, even when c.Options.SendingText is false and the transfer is an ordinary file transfer whose name the sender chose.
When the prompt is skipped and the transfer declares fileInfo.Size == 0 or a symlink (fileInfo.Symlink != ""), the loop calls createEmptyFileAndFinish() (src/croc/croc.go:3245), which - before creating the new entry - removes any existing file at the destination:
if fileInfo.Symlink != "" {
if err = validateReceiveSymlinkTarget(fileInfo.FolderRemote, fileInfo.Symlink); err != nil {
return
}
log.Debug("creating symlink")
// remove symlink if it exists
if _, errExists := root.Lstat(pathToFile); errExists == nil {
if err = root.Remove(pathToFile); err != nil {
return err
}
}
err = root.Symlink(fileInfo.Symlink, pathToFile)
...
}
For a normal (non-croc-stdin-) name, the overwrite prompt runs first, so the remove/replace step only happens with the user's explicit y. For a croc-stdin- name the entire prompt is bypassed: an existing croc-stdin-* file is deleted and replaced with the attacker's symlink (or, for Size == 0, truncated to an empty file) with no confirmation.
For a non-empty regular-file transfer with a croc-stdin- name, the same missing prompt lets the receive path proceed through recipientInitializeFile() (src/croc/croc.go:3109; the os.O_RDWR open is at 3136-3138): the existing file is opened O_RDWR (no O_EXCL), truncated to the sender-declared size when the sizes differ, and the sender's chunks are written at the declared offsets - a silent overwrite of the existing file's content.
Why the check is missing: the exemption was added deliberately so that croc's own croc-stdin-* text artifacts (created by os.CreateTemp(".", "croc-stdin-") for croc send --text / piped stdin) do not trigger an overwrite question every time. History: commit b687778d "bug fix: doesn't ask overwrite text Fixes #384" (2021-04-29) introduced the prefix-based skip, keyed on the filename and not on the transfer's SendingText flag. The branch that handles Size == 0 || Symlink != "" via createEmptyFileAndFinish() predates that (6386e4a8, 2019) and at the time ran unconditionally for every received name; the refactor 615af377 "fix: gate overwrites and receive hash algorithms" (2026-08-29, first released in v11.3.6) moved it below the overwrite-prompt gate, so after v11.3.6 the empty-file/symlink replacement reaches the remove-and-replace step without user confirmation only through the croc-stdin- exemption. The refactor extracted the prefix test into isStdinName and kept it filename-only, dropping the explicit !c.Options.SendingText conjunct that the pre-refactor prompt conditions still carried (615af377~1); the original intent was to suppress the prompt only for transfers actually marked as text. Because the exemption is keyed on a filename prefix the sender fully controls, any peer a user receives from can claim it.
The same prefix exemption also suppresses the --rename side of the decision (if destinationExists && !isStdinName && c.Options.Rename), so --rename receivers silently keep the attacker-chosen name and overwrite too.
This is distinct from the previously reported croc-marked-files.txt arbitrary file deletion (oss-sec 2026/Q3 #497, fixed in 11.0.3 by commit c0d51f0, which removed the on-disk cleanup list). That defect reached deletion through RemoveMarkedFiles(); this one reaches silent overwrite/replacement through the filename-keyed prompt exemption in the receive loop, which the 11.0.3 fix did not touch and which remains live at HEAD.
Impact
An attacker who can send a file to a victim (croc's sender-is-untrusted model; the receiver accepts a transfer from them) can silently overwrite, truncate, or delete-and-replace an existing croc-stdin-* file in the receiver's working directory without the confirmation every other received name triggers. The attack needs the colliding file to already exist with an exact name the sender can predict; receiver-side text artifacts get unpredictable os.CreateTemp-style suffixes, so the practical target is a name the attacker knows (e.g. a file the user deliberately kept, or a name pattern from an earlier transfer the same peer sent). With the noisy prompt gone, the substitution is invisible to the user. Severity is bounded because the vulnerable names must start with the croc-stdin- prefix (dotfiles such as .bashrc cannot be named this way), so the attack cannot reach outside that namespace.
CVSS 3.1: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L - base score 5.4 (Medium).
croc-stdin- prefix, and it requires an exact-name collision with a pre-existing file; per CVSS 3.1, "can modify only certain files" is I:L - dotfiles such as .bashrc are unreachable.croc-stdin-* file - Integrity: High yields CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L = 7.1 (High).Medium Basis: The source's own band: MODERATE
0, fixed 11.5.2 (semver)11.5.2
11.5.2go get github.com/schollz/croc/[email protected]0, last affected 10.7.0 (semver)None listed
No fixed version is listed.
0, last affected 9.6.17 (semver)None listed
No fixed version is listed.
0, last affected 8.6.12 (semver)None listed
No fixed version is listed.
0, last affected 6.4.11 (semver)None listed
No fixed version is listed.
0, last affected 3.0.6 (semver)None listed
No fixed version is listed.
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0