fix(mcp): bound dynamic session and protocol values - #655
Conversation
Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
praxis-bot
left a comment
There was a problem hiding this comment.
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
Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
praxis-bot
left a comment
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
[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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
Summary
Bounds MCP
session_idandprotocol_versionvalues 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 aFilterResultSet::set()error.filters/src/agentic/mcp/mod.rs: applyMAX_DYNAMIC_VALUE_LENat 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
cargo test -p praxis-ai-filters -- agentic::mcpmake lint(not run)Checklist
Signed-off-bytrailer.Breaking changes
None.