Skip to content

Conversation

madhav165
Copy link
Collaborator

🐛 Bug-fix PR


📌 Summary

RPC request method will be validated to check for XSS issues and method being part of valid characters

🐞 Root Cause

No validator for RPC request

💡 Fix Description

  1. Using schemas.py RPCRequest validator to validate method
  2. Included XSS validation in addition to character validation for RPCRequest method

🧪 Verification

Check Command Status
Unit tests make test pass

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

Signed-off-by: Madhav Kandukuri <[email protected]>
@madhav165 madhav165 self-assigned this Jul 23, 2025
@madhav165 madhav165 added this to the Release 0.5.0 milestone Jul 23, 2025
Copy link
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

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

filter worked, passed doctest test

@crivetimihai crivetimihai self-requested a review July 23, 2025 17:31
@crivetimihai
Copy link
Member

Trips up on t his:

18:29:31 - root - INFO - :outbox_tray: RPC request: {
  "jsonrpc": "2.0",
  "id": 1,
  "method": "smoketest-time-server-get-current-time",
  "params": {
    "timezone": "Europe/Dublin"
  }
}
18:29:32 - root - INFO - → POST /rpc 422 17 ms
18:29:32 - root - INFO - :inbox_tray: RPC response: {
  "message": "Method invalid"
}
18:29:32 - root - ERROR - :x:  Failure: Missing 'content' in tool response. Got: {'message': 'Method invalid'}
Traceback (most recent call last):
  File "/home/cmihai/github/mcp-context-forge/./smoketest.py", line 585, in main
    fn()
  File "/home/cmihai/github/mcp-context-forge/./smoketest.py", line 465, in step_8_invoke_tool
    raise RuntimeError(f"Missing 'content' in tool response. Got: {result}")
RuntimeError: Missing 'content' in tool response. Got: {'message': 'Method invalid'}

@madhav165
Copy link
Collaborator Author

@crivetimihai Will rebase after PR #618 is merged and test this.

@madhav165
Copy link
Collaborator Author

@crivetimihai Fixed the issue with smoketest. Looks like methods with - were not being allowed.

@crivetimihai
Copy link
Member

OK, are we good to merge this then?

@crivetimihai crivetimihai merged commit ea4e3aa into main Jul 30, 2025
37 checks passed
@crivetimihai crivetimihai deleted the validate-rpc-method branch July 30, 2025 09:15
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.

[Bug]: Prompt and RPC Endpoints Accept XSS Content Without Validation Error
2 participants