matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Ignored write errors in PGP signature generation (writeMPI)

Open andrinoff opened this issue 7 months ago • 2 comments

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

  1. Trigger PGP signature generation with Yubikey
  2. If buffer writes fail (simulated via full buffer), signatures corrupt silently
  3. 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

andrinoff avatar Apr 16 '26 20:04 andrinoff

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.

floatpanebot avatar May 17 '26 05:05 floatpanebot

Closing due to inactivity. Reopen if still relevant.

floatpanebot avatar May 31 '26 06:05 floatpanebot