Skip to content

sec(oidc): validate Azure Key Vault Crv field to enforce P-256 on EC key fetch #46

Description

@cristim

Summary

In internal/oidc/azure_signer.go resolveOnce, the signer fetches the EC public key by reading resp.Key.X and resp.Key.Y and constructs an *ecdsa.PublicKey with the curve hardcoded to elliptic.P256(), without validating the resp.Key.Crv field.

If someone misconfigures a P-384 or P-521 key in Key Vault:

  • PublicKey() will return a key with P-256 curve but P-384/P-521 coordinate sizes, which is an invalid point on P-256.
  • The Sign call will return an error (Key Vault rejects ES256 signing with a non-P-256 key), so no silently wrong signatures are produced.

The gap is that the error surfaces at sign-time rather than at key-fetch time, and the public key returned by PublicKey() is structurally invalid.

Fix: check resp.Key.Crv != nil && *resp.Key.Crv == azkeys.CurveNameP256 in resolveOnce and return an error if the curve is absent or not P-256.

This is a correctness issue but low severity in practice because Azure Key Vault enforces the algorithm on Sign. Discovered during adversarial review of PR LeanerCloud/cloud-commitments-cli#882.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions