| 1 | # sigverify |
| 2 | |
| 3 | sigverify verifies OpenSSH signatures and refuses any FIDO security-key signature made without a |
| 4 | touch. It reads standard SSHSIG, the format `ssh-keygen -Y sign` writes and git uses for SSH-signed |
| 5 | tags. It is a Go library (`the-valley/sigverify`) and a command (`sigverify`). |
| 6 | |
| 7 | ## Why the verifier must check for a touch |
| 8 | |
| 9 | The operator's approvals and host releases are meant to be authorized by a touch on a hardware key. |
| 10 | Agents and the interactive coordinator run as the operator's Unix user. They can do anything the |
| 11 | operator's files allow, so the touch is the one step they cannot perform. |
| 12 | |
| 13 | A security key signs authenticator data, not the message itself. That data holds the message's hash |
| 14 | and a flags byte. The user-presence bit (UP, `0x01`) is set only when someone touched the key. The |
| 15 | user-verification bit (UV, `0x04`) is set only when the key also checked a PIN or biometric. Both |
| 16 | bits are inside the signed bytes, so nobody can change them after signing. |
| 17 | |
| 18 | Whether the key asks for a touch is decided by a flag in the key stub, the private key file on disk. |
| 19 | Anything running as the operator can clear that flag, either with |
| 20 | `ssh-keygen -p -O no-touch-required` (OpenSSH 10.5) or by editing the stub's bytes. The plugged-in |
| 21 | key then signs without a touch, and the signature records UP as clear. |
| 22 | |
| 23 | Standard verification never looks at the bit: |
| 24 | |
| 25 | - `ssh-keygen -Y verify` logs the flags at debug level and accepts the signature. |
| 26 | - `git verify-tag` with `gpg.format=ssh` calls `ssh-keygen -Y verify`, so it accepts it too. |
| 27 | - An allowed-signers file cannot ask for a touch. Its only options are `cert-authority`, |
| 28 | `namespaces`, `valid-after` and `valid-before`. |
| 29 | |
| 30 | So the presence check has to be in the verifier. sigverify does it on every security-key signature, |
| 31 | and nothing turns it off. |
| 32 | |
| 33 | ## What is verified |
| 34 | |
| 35 | A signature is accepted only if every one of these holds, checked in this order: |
| 36 | |
| 37 | 1. It is a well-formed SSHSIG, armored or raw, with hash `sha256` or `sha512`. |
| 38 | 2. Its namespace is the one the caller names. The git-tag command always uses `git`. |
| 39 | 3. Its key is a security key (`sk-ssh-ed25519@openssh.com` or `sk-ecdsa-sha2-nistp256@openssh.com`). |
| 40 | Software keys (`ssh-ed25519`, ECDSA, and RSA of at least 2048 bits) are accepted only when the |
| 41 | caller allows them. |
| 42 | 4. The signature verifies over the message. |
| 43 | 5. A line of the allowed-signers file lists the key. That line's principals must match the requested |
| 44 | principal, if one is given. Its `namespaces`, if present, must match the namespace. The verify |
| 45 | time must fall between its `valid-after` and `valid-before`. These rules match |
| 46 | `ssh-keygen -Y verify`. |
| 47 | 6. A security-key signature has UP set. |
| 48 | 7. The signature has UV set, if the caller requires it or the key's allowed-signers line carries |
| 49 | `verify-required`. |
| 50 | |
| 51 | A success reports the principal, the key type, the key's SHA256 fingerprint, the authenticator flags |
| 52 | and the signature counter. |
| 53 | |
| 54 | sigverify trusts the allowed-signers file to list security keys that really live in hardware. Anyone |
| 55 | can make a software key in the security-key format, and its signatures would carry whatever flags |
| 56 | its maker chose. sigverify does not check the enrollment attestation that would tell the two apart, |
| 57 | so the file must list only keys the operator enrolled. It also does not track the signature counter, |
| 58 | so it does not detect a replayed signature or a cloned key. |
| 59 | |
| 60 | ## What is refused |
| 61 | |
| 62 | Each refusal has a stable reason that callers can match on. |
| 63 | |
| 64 | | Reason | Meaning | |
| 65 | | ----------------------- | --------------------------------------------------------------------- | |
| 66 | | `malformed` | The signature, or the tag object holding it, cannot be read. | |
| 67 | | `unsigned` | The git tag has no signature, or is a lightweight tag. | |
| 68 | | `wrong-namespace` | The signature was made for another namespace. | |
| 69 | | `unsupported-key` | The key type is not one listed above, such as a certificate. | |
| 70 | | `not-security-key` | A software key signed, and software keys are not allowed. | |
| 71 | | `bad-signature` | The signature does not verify over this message. | |
| 72 | | `unknown-key` | No allowed-signers line lists the key. | |
| 73 | | `principal-not-allowed` | The key is listed, but not for the requested principal. | |
| 74 | | `namespace-not-allowed` | The key's line restricts it to other namespaces. | |
| 75 | | `not-yet-valid` | The verify time is before the key's `valid-after`. | |
| 76 | | `expired` | The verify time is after the key's `valid-before`. | |
| 77 | | `no-user-presence` | A genuine security-key signature made without a touch. | |
| 78 | | `no-user-verification` | UV is required and the signature does not prove it. | |
| 79 | | `tag-name-mismatch` | The tag object was signed under another name than the one it has now. | |
| 80 | |
| 81 | A `no-user-presence` refusal means the key really did sign, without a touch. Something running as |
| 82 | the key's owner is using the key, and the refusal names the key's fingerprint for that reason. |
| 83 | |
| 84 | ## Differences from ssh-keygen |
| 85 | |
| 86 | sigverify is stricter than `ssh-keygen -Y verify` in these ways: |
| 87 | |
| 88 | - It enforces UP, and UV when required. |
| 89 | - It refuses an allowed-signers file with any line it cannot parse, including unknown options. |
| 90 | ssh-keygen skips such a line, so a typo could silently drop a signer's restrictions. |
| 91 | - It refuses an allowed-signers file with a `no-touch-required` option on any line. |
| 92 | - It adds one allowed-signers option, `verify-required`. This is the keyword sshd uses in |
| 93 | `authorized_keys`. ssh-keygen does not know it and skips any line carrying it. |
| 94 | - It does not verify certificates. A `cert-authority` line never matches, so a certificate signature |
| 95 | is refused. |
| 96 | - It refuses RSA keys under 2048 bits. |
| 97 | |
| 98 | The git-tag command also differs from `git verify-tag`: |
| 99 | |
| 100 | - It judges the validity window at the current time, or at `--verify-time`. git uses the tagger |
| 101 | date, which the signer chooses, so a key past its `valid-before` could sign a backdated tag. |
| 102 | - It refuses a tag whose signed name differs from the ref it was found under. Without this check, a |
| 103 | signed tag for an old release could be published again under a new release's name. |
| 104 | - It looks the tag up only as `refs/tags/NAME`. A name git would resolve elsewhere, such as a |
| 105 | remote-tracking ref, is not a tag. |
| 106 | |
| 107 | ## Using the command |
| 108 | |
| 109 | ``` |
| 110 | sigverify verify --namespace NS --signature FILE --allowed-signers FILE \ |
| 111 | [--principal ID] [--require-uv] [--allow-non-sk] [--verify-time TIME] < message |
| 112 | |
| 113 | sigverify git-tag --repo DIR --tag NAME --allowed-signers FILE \ |
| 114 | [--principal ID] [--require-uv] [--allow-non-sk] [--verify-time TIME] |
| 115 | ``` |
| 116 | |
| 117 | The exit status is 0 for verified, 1 for refused, and 2 for an error. An error means nothing was |
| 118 | judged: bad usage, an unreadable or invalid allowed-signers file, a missing tag, or a git failure. |
| 119 | |
| 120 | Stdout starts with `verified` or `refused <reason>`. Lines of the form `name value` follow, and |
| 121 | stderr explains a refusal in a sentence. A verified release tag looks like this: |
| 122 | |
| 123 | ``` |
| 124 | $ sigverify git-tag --repo /srv/git/cosmo.git --tag v2026.10.04 --allowed-signers /etc/cosmo/release-signers |
| 125 | verified |
| 126 | namespace git |
| 127 | principal release@cosmo |
| 128 | key-type sk-ssh-ed25519@openssh.com |
| 129 | fingerprint SHA256:... |
| 130 | security-key yes |
| 131 | flags 0x01 |
| 132 | user-presence yes |
| 133 | user-verification no |
| 134 | counter 42 |
| 135 | tag v2026.10.04 |
| 136 | object 5d1c... |
| 137 | object-type commit |
| 138 | ``` |
| 139 | |
| 140 | A caller should check out the commit in the `object` line, not whatever the tag name resolves to |
| 141 | later. A ref can move between verifying and checking out, but the verified object id cannot change. |
| 142 | |
| 143 | The flake exposes the command as `packages.<system>.sigverify`, with git on its PATH, for |
| 144 | `x86_64-linux` and `aarch64-linux`. |
| 145 | |
| 146 | ## Tests |
| 147 | |
| 148 | `nix flake check` runs two checks. `sigverify-unit` runs the Go tests. `sigverify-e2e` runs the |
| 149 | packaged command over a real signed tag. |
| 150 | |
| 151 | The tests need no hardware. Security-key signatures come from two sources: |
| 152 | |
| 153 | - `internal/skforge` derives keys from seed strings and makes signatures with chosen flags. It |
| 154 | rebuilds the signed bytes independently of the verifier. |
| 155 | - OpenSSH's `sk-dummy` is the software authenticator from OpenSSH's own regression suite. The checks |
| 156 | build it from the same source as the `ssh-keygen` they run. With it, real `ssh-keygen` produces |
| 157 | real touchless signatures, through a key generated with `no-touch-required` and through a stub |
| 158 | whose flag is cleared after the key was made. `ssh-keygen -Y verify` and `git verify-tag` accept |
| 159 | both kinds, and the tests require sigverify to refuse them. |
| 160 | |
| 161 | Outside nix, `go test ./...` skips the `sk-dummy` cases unless `SIGVERIFY_SK_PROVIDER` names the |
| 162 | provider. The tests also compare sigverify's verdict with `ssh-keygen -Y verify` across principal |
| 163 | patterns, namespaces and validity windows. |