Skip to content

fix(security): shredFile must not report a locked/unwritable plaintext copy as shredded#262

Merged
Prekzursil merged 1 commit into
mainfrom
fix/keystore-shred-false-success
Jul 8, 2026
Merged

fix(security): shredFile must not report a locked/unwritable plaintext copy as shredded#262
Prekzursil merged 1 commit into
mainfrom
fix/keystore-shred-false-success

Conversation

@Prekzursil

Copy link
Copy Markdown
Owner

Codex stop-time review found that the v1.4.1 keystore shredFile always returned true (except ENOENT), so a locked/read-only/unwritable plaintext copy still fully intact on disk was reported as shredded and listed in the migration's \shredded[]\ - the user wrongly believes the plaintext is destroyed. Fix returns true only when the bytes were truncated OR the file removed; false when the target stays intact. Lands before v1.4.1 is built/published. keystore 32/32, vitest 100%, tsc+biome clean.

https://claude.ai/code/session_01CaUSwiidebWvpgMs2wQgqL

…t copy as shredded

Codex stop-time review: the shredFile rewrite always returned true except for
ENOENT, so a file that EXISTS but where both the truncate (openSync r+ throws
EACCES/EBUSY, or ftruncate fails) AND the unlink fail — a locked, read-only or
otherwise unwritable plaintext copy, or a directory — was reported as shredded
even though it is still fully recoverable on disk. The migration then lists it in
`shredded[]`, so the user wrongly believes a plaintext key copy is destroyed.

Fix: track whether the plaintext was ACTUALLY made unrecoverable and return that —
true only when the bytes were truncated OR the file was removed; false when the
target stays intact (both arms failed). "Existed" is not "shredded".

Tests: the directory case (deterministic cross-platform "both arms fail": EISDIR on
open + EISDIR/EPERM on unlink — same code path as a locked file) now asserts false;
added a positive test that a real file is truncated+removed -> true. keystore 32/32,
full renderer vitest 100% coverage, tsc + biome clean.

Claude-Session: https://claude.ai/code/session_01CaUSwiidebWvpgMs2wQgqL
@Prekzursil Prekzursil merged commit 5b1f632 into main Jul 8, 2026
6 checks passed
@Prekzursil Prekzursil deleted the fix/keystore-shred-false-success branch July 8, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant