joelhooks / joelhooks/agent-secrets

feat: Secure file deletion for .env wipe

Open
#7 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
109
Forks
7
Avg merge
2h 37m
Merged PRs (30d)
1

Description

Summary

Implement secure deletion for .env files to prevent recovery of sensitive data.

Context

File: internal/envfile/envfile.go:134

// Future: consider secure deletion (overwrite before delete)

Problem

Current Wipe() just calls os.Remove(). On many filesystems, deleted files can be recovered until overwritten.

Security consideration

.env files contain secrets. When wiped (TTL expired or manual cleanup), the data should be unrecoverable.

Implementation

Secure wipe pattern
func Wipe(path string) error {
    info, err := os.Stat(path)
    if err != nil {
        if os.IsNotExist(err) {
            return nil
        }
        return err
    }
    
    // Overwrite with random data
    f, err := os.OpenFile(path, os.O_WRONLY, 0)
    if err != nil {
        return err
    }
    
    size := info.Size()
    random := make([]byte, size)
    rand.Read(random)
    f.Write(random)
    f.Sync()
    f.Close()
    
    // Then delete
    return os.Remove(path)
}
Considerations
  • SSD wear leveling may still leave copies
  • This is defense in depth, not perfect security
  • Could add --secure flag to make it optional (faster default)

Acceptance

  • Wipe() overwrites file contents before deletion
  • Works on files of any size
  • Falls back gracefully if overwrite fails
  • Optional: benchmark impact

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in internal/envfile/envfile.go at Wipe(), especially line 134, and inspect how TTL expiry and manual cleanup call it. Verify behavior for missing, empty, and larger files, including error handling during overwrite. Done means contents are overwritten before deletion, failures are handled gracefully, and the existing cleanup paths still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
security
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.