Skip to content

fix: harden signing key handling - #1166

Merged
alexhancock merged 2 commits into
mainfrom
fix/1161-signing-key-hardening
Aug 18, 2026
Merged

fix: harden signing key handling#1166
alexhancock merged 2 commits into
mainfrom
fix/1161-signing-key-hardening

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Aug 11, 2026

Copy link
Copy Markdown
Member

Fixes #1161.

Motivation and Context

RequestStateCodec protects opaque MRTR requestState values with an HMAC signing key. However, its existing constructor accepted keys of any length, even though its documentation recommended at least 32 bytes of high-entropy key material. This made it easy for integrations to accidentally configure weak key material.

The codec also kept the key bytes in memory without zeroizing them when dropped. In addition, the derived Debug implementation for ClientCredentialsConfig could expose OAuth client secrets and private signing keys.

This change makes the secure path explicit. The try_new constructor now requires a key of at least 32 bytes. The legacy new constructor is deprecated as of version 3.1.4, while new_unchecked remains available for keys that are validated separately. Stored request-state keys are now zeroized, and credential Debug output redacts secret fields.

How Has This Been Tested?

Added tests

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@github-actions github-actions Bot added T-dependencies Dependencies related changes T-test Testing related changes T-config Configuration file changes T-core Core library changes T-examples Example code changes T-model Model/data structure changes T-transport Transport layer changes labels Aug 11, 2026
@DaleSeo
DaleSeo force-pushed the fix/1161-signing-key-hardening branch from 619a0e8 to 1dfe003 Compare August 11, 2026 23:42
@DaleSeo
DaleSeo marked this pull request as ready for review August 11, 2026 23:55
@DaleSeo
DaleSeo requested a review from a team as a code owner August 11, 2026 23:55
@DaleSeo DaleSeo self-assigned this Aug 13, 2026
alexhancock
alexhancock previously approved these changes Aug 18, 2026
Comment thread conformance/src/bin/server.rs Outdated
log_level: Arc::new(Mutex::new(LoggingLevel::Debug)),
request_state_codec: RequestStateCodec::new(REQUEST_STATE_KEY),
request_state_codec: RequestStateCodec::try_new(REQUEST_STATE_KEY)
.expect("conformance request-state key meets the minimum length"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need the runtime check here for .expect when it's a constant defined in the file, right. Can't we just check it at compile time or leave the check out given we know where it comes from?

@DaleSeo DaleSeo Aug 18, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense, @alexhancock! I changed the fixed-key call sites to use a const assertion and new_unchecked.

@DaleSeo
DaleSeo force-pushed the fix/1161-signing-key-hardening branch 2 times, most recently from 4ff6578 to fad6734 Compare August 18, 2026 05:49
@DaleSeo
DaleSeo force-pushed the fix/1161-signing-key-hardening branch from fad6734 to 0813d97 Compare August 18, 2026 06:00
@DaleSeo
DaleSeo requested a review from alexhancock August 18, 2026 06:10
@alexhancock
alexhancock merged commit d5c46b3 into main Aug 18, 2026
22 checks passed
@alexhancock
alexhancock deleted the fix/1161-signing-key-hardening branch August 18, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-dependencies Dependencies related changes T-examples Example code changes T-model Model/data structure changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request-state and JWT signing key material lacks minimum-length enforcement and zeroization

2 participants