Skip to content

Harden constitution validation for JWT, CA, and member keys#7924

Draft
Copilot wants to merge 12 commits into
mainfrom
copilot/fix-constitution-validators-strictness
Draft

Harden constitution validation for JWT, CA, and member keys#7924
Copilot wants to merge 12 commits into
mainfrom
copilot/fix-constitution-validators-strictness

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

Constitution validators accepted weak or malformed security inputs, including unsafe JWKS metadata, non-HTTPS JWT issuers, non-CA TLS trust anchors, and unchecked member encryption keys. This tightens validation using the existing JS crypto surface where available.

  • JWKS validation
    • Require unique kid values.
    • Restrict kty to RSA or EC.
    • Restrict use to sig.
    • Restrict alg to supported signing algorithms (RS256, ES256).
    • Validate RSA/EC public key parameters, including P-256, P-384, and P-521 EC curves, and reject weak RSA keys.
    • Validate x5c certificate chains to the provided root.
checkEnum(jwk.kty, ["RSA", "EC"], `${keyField}.kty`);
checkEnum(jwk.alg, jwk.kty === "RSA" ? ["RS256"] : ["ES256"], `${keyField}.alg`);
checkEnum(jwk.use, ["sig"], `${keyField}.use`);
  • JWT issuer validation

    • Require all JWT issuers to be HTTPS URLs.
    • Reject issuers with query strings or fragments, regardless of auto_refresh.
  • CA bundle validation

    • set_ca_cert_bundle now requires certificates that validate as CA trust anchors, not merely parseable PEM.
  • Member encryption key validation

    • set_member now validates encryption_pub_key as a well-formed RSA public key with minimum strength before storing it.
  • P-521 support

    • Added P-521 JWK/PEM curve mapping support in the existing crypto surface used by validation.
    • Extended related JS crypto and C++ crypto tests for P-521 coverage.
  • Coverage updates

    • Added focused governance validation cases for rejected JWT issuer/JWKS inputs.
    • Added rejection coverage for non-CA certificate bundles.
    • Updated JWT test certificate generation and docs to satisfy stricter validation.

Copilot AI changed the title [WIP] Fix insufficient strictness in constitution validators Harden constitution validation for JWT, CA, and member keys Jun 5, 2026
Copilot AI requested a review from achamayou June 5, 2026 12:40
Comment thread samples/constitutions/default/actions.js Outdated
Comment thread samples/minimal_ccf/app/actions.js Outdated
@achamayou
Copy link
Copy Markdown
Member

@copilot add a relevant changelog entry

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 5, 2026

@copilot add a relevant changelog entry

Added the changelog entry in bdfdd14.

@achamayou achamayou added this to the 7.0.5 milestone Jun 5, 2026
achamayou and others added 3 commits June 5, 2026 18:32
- Use ceiling division when sizing EC coordinate/private-scalar buffers so curves whose bit-size is not a multiple of 8 (P-521 has 521 bits) get the full 66-byte buffer rather than a truncated 65-byte one. This fixes BN_bn2binpad failures and dropped leading-zero bytes when round-tripping P-521 keys through JWK.

- Update test_jwt_auth_raw_key to use an https:// JWT issuer URL so it satisfies the hardened set_jwt_issuer constitution validator added in this PR.

- Run clang-format on curve.h and crypto.cpp.
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.

Constitution validators are insufficiently strict

2 participants