Skip to content

Reject typed nil at Verify time - #285

Merged
jsha merged 1 commit into
go-jose:mainfrom
justadityaraj:fix/nil-verification-keys
Sep 3, 2026
Merged

jsha merged 1 commit into
go-jose:mainfrom
justadityaraj:fix/nil-verification-keys

Conversation

@justadityaraj

Copy link
Copy Markdown
Contributor

Problem

Typed-nil public keys satisfy newVerifier's type switch and reach the cryptographic verifier. Ed25519, ECDSA, and RSA then panic instead of returning an error. A nil *JSONWebKey also panics when it is dereferenced during verifier construction.

Changes

  • Reject nil Ed25519, ECDSA, RSA, and JWK verification keys before constructing a verifier.
  • Return a consistent invalid verification key error for these inputs.
  • Add table-driven JWS verification coverage for every affected key form.

User impact

Applications that accidentally pass a typed-nil verification key now receive a normal error instead of crashing the process.

Verification

  • go build ./... — passed
  • go test ./... -count=1 — passed
  • go test . -run '^(TestJWSNilVerificationKey|TestJWSInvalidKey)$' -count=1 — passed
  • go vet . — passed
  • gofmt -l . — clean
  • git diff --check — passed

Repository-wide go vet ./... additionally reports the existing intentionally malformed struct-tag fixtures in json/decode_test.go and json/tagkey_test.go; the changed package is clean.

Fixes #283

@jsha jsha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ergonomic improvement, thanks!

@jsha
jsha merged commit b10771e into go-jose:main Sep 3, 2026
@justadityaraj

Copy link
Copy Markdown
Contributor Author

Nice ergonomic improvement, thanks!

your welcome!

@jsha jsha changed the title Reject nil JWS verification keys before crypto dispatch Reject typed nil at Verify time Sep 3, 2026
Doridian pushed a commit to FoxDenHome/core that referenced this pull request Oct 3, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) | `v4.1.4` → `v4.1.5` | ![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-jose%2fgo-jose%2fv4/v4.1.5?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-jose%2fgo-jose%2fv4/v4.1.4/v4.1.5?slim=true) |

---

### Release Notes

<details>
<summary>go-jose/go-jose (github.com/go-jose/go-jose/v4)</summary>

### [`v4.1.5`](https://github.com/go-jose/go-jose/releases/tag/v4.1.5)

[Compare Source](go-jose/go-jose@v4.1.4...v4.1.5)

### Fixed security issues

- cipher/cbc\_hmac: don't panic on empty ciphertext ([#&#8203;292](go-jose/go-jose#292))
- cipher/cbc\_hmac: don't panic on invalid key ([#&#8203;291](go-jose/go-jose#291))
- json: limit stack depth ([#&#8203;290](go-jose/go-jose#290))
- jwt: reject out-of-range NumericDate values ([#&#8203;278](go-jose/go-jose#278))
- Check alg against pubkey curve during verify. ([#&#8203;293](go-jose/go-jose#293))
- Reject malformed [`Ed25519`](go-jose/go-jose@Ed25519) JWKs ([#&#8203;250](go-jose/go-jose#250))
- jws: choose verification key per-signature ([#&#8203;243](go-jose/go-jose#243))

### Breaking Changes

In [#&#8203;226](go-jose/go-jose#226), we un-exported jose.RandReader. This was used to be able to stub out the randomness function in tests, but is ignored as of Go 1.26 in some APIs, so no longer serves a useful function.

### Changed

- Verify OpaqueSigner's Public() return is public ([#&#8203;260](go-jose/go-jose#260))
- jws: skip signature on ErrJWKSKidNotFound ([#&#8203;248](go-jose/go-jose#248))
- Handle JWE JSON without protected header ([#&#8203;240](go-jose/go-jose#240))
- jws: don't strip internal whitespace before parsing JSON ([#&#8203;239](go-jose/go-jose#239))
- jws: fewer calls to OpaqueSigner.Public() ([#&#8203;224](go-jose/go-jose#224))
- Return a specific error when parsing empty string ([#&#8203;216](go-jose/go-jose#216))
- Reject typed nil at Verify time ([#&#8203;285](go-jose/go-jose#285))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMjEuMyIsInVwZGF0ZWRJblZlciI6IjQ0LjEyMS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.foxden.network/FoxDen/core/pulls/168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in JWS verification when a typed nil *ecdsa.PublicKey is passed as the verification key

2 participants