T09 · Insecure Skill Coding Practices
- Location
SKILL.md:48- Finding
Unconditional Plaintext Deletion After File Encryption Attempts
- Content
View full analysis
${f}.age" shred -u "$f" fi done ``` ### Technical Analysis The documented workflows invoke `shred -u` immediately after `age`, without checking the encryption command's exit status. The scripts do not use `set -e`, an `if age ...` condition, output-integrity validation, or decryption testing. Shell execution normally continues after a command returns a nonzero status. Consequently, a missing `age` executable, invalid recipient, unavailable destination, full disk, permission failure, interrupted operation, or other encryption error does not prevent deletion of the source. The comments characterize deletion as safe, but secure erasure does not establish that a recoverable encrypted copy exists. On copy-on-write, journaled, virtualized, or SSD storage, `shred` also cannot reliably guarantee physical erasure. ### Attack Path 1. A user asks the Agent to encrypt a sensitive file using the documented workflow. 2. The encryption attempt fails because of an invalid key, permission failure, exhausted storage, missing dependency, or deliberately induced environmental fault. 3. The shell continues to the next statement because no success condition guards it. 4. `shred -u` overwrites or unlinks the original plaintext. 5. The user is left without either the original file or a valid encrypted copy. An attacker able to influence the destination filesystem, recipient value, available disk space, or encryp ...[truncated 564 chars]- Remediation
View remediation
&2 rm -f -- "${f}.age" continue fi ``` - Do not delete the source automatically. Require explicit, informed user confirmation in a separate step. - Verify that the encrypted file can be decrypted with the intended identity before removing the original. - Preserve a protected backup until recovery has been tested. - Use `set -eu` where appropriate, quote all paths, and pass `--` before filename operands. - Explain that `shred` may be ineffective on SSDs, copy-on-write filesystems, snapshots, and network storage. ]]>
