In internal/secret/crypto.go, DecryptWithIdentity() reads decrypted data into a regular byte slice via io.ReadAll(), then copies it into a memguard.LockedBuffer:
result,err:=io.ReadAll(r)iferr!=nil{returnnil,fmt.Errorf("failed to read decrypted data: %w",err)}resultBuffer:=memguard.NewBufferFromBytes(result)returnresultBuffer,nil
memguard.NewBufferFromBytes copies the data into protected memory, but the original result byte slice remains in regular (swappable, dumpable) memory and is never zeroed. This defeats the purpose of using memguard throughout the codebase.
Impact
Decrypted secrets (private keys, secret values, metadata) linger in unprotected heap memory and could be:
Swapped to disk
Visible in core dumps
Read by memory-scanning malware
Fix
Zero out the result slice after copying into the LockedBuffer:
## Security Issue
In `internal/secret/crypto.go`, `DecryptWithIdentity()` reads decrypted data into a regular byte slice via `io.ReadAll()`, then copies it into a `memguard.LockedBuffer`:
```go
result, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("failed to read decrypted data: %w", err)
}
resultBuffer := memguard.NewBufferFromBytes(result)
return resultBuffer, nil
```
`memguard.NewBufferFromBytes` copies the data into protected memory, but the original `result` byte slice remains in regular (swappable, dumpable) memory and is never zeroed. This defeats the purpose of using `memguard` throughout the codebase.
## Impact
Decrypted secrets (private keys, secret values, metadata) linger in unprotected heap memory and could be:
- Swapped to disk
- Visible in core dumps
- Read by memory-scanning malware
## Fix
Zero out the `result` slice after copying into the `LockedBuffer`:
```go
resultBuffer := memguard.NewBufferFromBytes(result)
for i := range result {
result[i] = 0
}
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Security Issue
In
internal/secret/crypto.go,DecryptWithIdentity()reads decrypted data into a regular byte slice viaio.ReadAll(), then copies it into amemguard.LockedBuffer:memguard.NewBufferFromBytescopies the data into protected memory, but the originalresultbyte slice remains in regular (swappable, dumpable) memory and is never zeroed. This defeats the purpose of usingmemguardthroughout the codebase.Impact
Decrypted secrets (private keys, secret values, metadata) linger in unprotected heap memory and could be:
Fix
Zero out the
resultslice after copying into theLockedBuffer: