Skip to content

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

@andrinoff

Description

@andrinoff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions