Skip to content

fix(mcp): bound dynamic session and protocol values - #655

Open
skamenan7 wants to merge 4 commits into
praxis-proxy:mainfrom
skamenan7:feat/361-mcp-length-bounds
Open

fix(mcp): bound dynamic session and protocol values#655
skamenan7 wants to merge 4 commits into
praxis-proxy:mainfrom
skamenan7:feat/361-mcp-length-bounds

Conversation

@skamenan7

Copy link
Copy Markdown

Summary

Bounds MCP session_id and protocol_version values before writing durable metadata or promoted headers. The protocol-version filter result is also omitted above 256 bytes, rather than turning an optional routing fact into a FilterResultSet::set() error.

  • filters/src/agentic/mcp/mod.rs: apply MAX_DYNAMIC_VALUE_LEN at every affected promotion boundary.
  • filters/src/agentic/mcp/tests.rs: cover 256-byte retention and 257-byte omission for session IDs and protocol versions.

Related issue

Closes #361

Validation

  • Unit tests: cargo test -p praxis-ai-filters -- agentic::mcp
  • Integration or functional tests: not applicable, narrow unit-level boundary validation
  • make lint (not run)

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test. Not applicable, this fixes existing bound validation.
  • User-facing behavior and generated documentation are updated. Not applicable, no config or generated documentation changed.
  • Performance-sensitive changes include appropriate benchmark or load-test evidence. Not applicable, this adds existing bound checks only.
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

None.

Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
@skamenan7
skamenan7 requested review from a team and leseb August 6, 2026 12:30

@praxis-bot praxis-bot 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.

Review Summary

The length-bound additions for session_id and protocol_version are correct and well-tested. One gap: the adjacent name field in promote_filter_results has the same unbounded set() risk that this PR fixes for protocol_version.

Severity Count
Critical 0
Large 0
Medium 1

Automated review by praxis-bot

Comment thread filters/src/agentic/mcp/mod.rs
Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
@skamenan7 skamenan7 changed the title fix(mcp): bound dynamic session and protocol values fix(mcp): bound dynamic session and protocol values Aug 6, 2026

@praxis-bot praxis-bot 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.

Review Summary

The length-bound additions are correct and complete. All dynamic values in write_metadata, promote_mcp_headers, and promote_filter_results now have consistent MAX_DYNAMIC_VALUE_LEN guards. The boundary tests at 256 and 257 bytes are thorough, and the previous finding about the missing name guard in promote_filter_results has been addressed.

Severity Count
Critical 0
Large 0
Medium 1

Automated review by praxis-bot

@@ -1130,6 +1229,106 @@ async fn null_protocol_version_header_skips_header_promotion() {
// Test Utilities

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.

[Medium] These three assert_* helpers are placed before the // Test Utilities separator. Project conventions require test utility functions to live inside the Test Utilities section, after the separator comment. Move assert_dynamic_values_omitted, assert_dynamic_values_promoted, and assert_oversized_value_is_omitted below the separator alongside the existing assert_invalid_params_rejection, make_default_filter, etc.

@praxis-bot praxis-bot 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.

No new findings beyond prior review.

All dynamic value promotion paths (write_metadata, promote_mcp_headers, promote_filter_results) now have consistent MAX_DYNAMIC_VALUE_LEN guards. The validate_single_header synthesize path already had its guard pre-PR. Test coverage is thorough: boundary tests at 256/257 bytes for session ID and protocol version, plus oversized method and resource URI tests. Test utilities are properly placed in the Test Utilities section.


Automated review by praxis-bot

@praxis-bot praxis-bot 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.

No new findings beyond prior reviews.

All dynamic value promotion paths (write_metadata, promote_mcp_headers, promote_filter_results) have consistent MAX_DYNAMIC_VALUE_LEN guards. Fixed-value outputs (enum as_str(), "true"/"false") correctly skip guards. The validate_single_header synthesize path already had its guard pre-PR. Test coverage is thorough: boundary tests at 256/257 bytes for session ID and protocol version, plus oversized method and resource URI tests. Test utilities are correctly placed after the Test Utilities separator.

Severity Count
Critical 0
Large 0
Medium 0

Automated review by praxis-bot

@praxis-bot praxis-bot 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.

No new findings since prior review.

The new commit is a merge of main into the feature branch. The PR-specific files (mod.rs, tests.rs) are unchanged. All dynamic value promotion paths (write_metadata, promote_mcp_headers, promote_filter_results) still have consistent MAX_DYNAMIC_VALUE_LEN guards on every dynamic field (method, name, session_id, protocol_version). Fixed-value outputs (kind, session_present) correctly skip guards. Test coverage remains thorough.

Severity Count
Critical 0
Large 0
Medium 0

Automated review by praxis-bot

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.

fix(mcp): missing length bounds on session_id and protocol_version

3 participants