Skip to content

shred --remove=wipe deletes an unrelated constant-named file and leaves the target in place (data loss); -s size semantics diverge #1348

Closed

Description

@caomengxuan666

shred --remove=wipe deletes an unrelated constant-named file and leaves the target in place (data loss); -s size semantics diverge

1. wipe renames the target onto a hardcoded constant name — and deletes whatever already has that name

shred.cpp's wipe stage renames the operand to the constant file name f6d4b2907e5c3a1 in the same directory, ignores the rename result, and then unconditionally DeleteFileWs that constant path. If a file with the constant name already exists, the rename fails (destination exists), the pre-existing unrelated file is deleted, and the shred target remains — filled with random overwrite bytes but still present under its original name. This is silent: exit is 0 and -v prints nothing about it.

Verified with the same-source harness under Wine, twice (fixture: sub/ containing the sentinel file f6d4b2907e5c3a1 with content keepme, plus sub/victim with content secret):

$ shred --remove=wipe sub/victim     → exit 0
after: sub/ contains ONLY victim (content overwritten with random bytes)
       the sentinel f6d4b2907e5c3a1 ("keepme") is GONE — deleted by shred
$ shred --remove=wipe sub/victim2    (constant name now free)
after: works as intended — victim2 renamed onto the constant name and deleted

GNU shred's wipe generates a fresh random name per file and never touches an unrelated file; the sentinel survives and the target is removed.

2. -s on a file shorter than the size overshoots

shred -s 100 f on a 5-byte file: winx leaves 512 bytes (one 512-byte block rounded past the requested size); GNU leaves exactly 100 bytes.

3. Size/iteration value forms inverted vs GNU

shred -s 1KB f → winx shred: invalid size: '1KB' (exit 1); GNU accepts the suffix. shred -n -1 f → winx accepts silently (exit 0); GNU: shred: invalid number of passes: '-1' (exit 1).

Expected (GNU)

Wipe uses a per-file unpredictable name, checks the rename result, and never deletes a path it did not just create; -s produces exactly the requested size; suffix forms accepted, negative counts rejected with GNU's diagnostic.

Regression seed

In-repo test named with this issue number: the sentinel fixture — after shred --remove=wipe, the sentinel file's content is intact and the target is gone; -s 100 size and the two value-form cases asserted.

Activity

  1. added
    bug
    compat-gap
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions