matcha
matcha copied to clipboard
BUG: Ignored write errors in PGP signature generation (writeMPI)
Describe the bug
In pgp/yubikey.go lines 386-387, the writeMPI() function ignores write errors using //nolint:errcheck:
w.Write(buf) //nolint:errcheck
w.Write(data) //nolint:errcheck
These write operations could fail silently if buffer capacity is reached or I/O errors occur, producing invalid OpenPGP signatures without error indication.
To reproduce
- Trigger PGP signature generation with Yubikey
- If buffer writes fail (simulated via full buffer), signatures corrupt silently
- No error returned to caller
Expected behavior
Write errors should be checked and propagated:
if _, err := w.Write(buf); err != nil {
return err
}
if _, err := w.Write(data); err != nil {
return err
}
Screenshots
N/A
Additional context
- File:
pgp/yubikey.go - Lines: 386-387
- Severity: High - silent signature corruption possible
- Fix complexity: Easy - add error checks and propagate
This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.
Closing due to inactivity. Reopen if still relevant.