Skip to content

Commit f8d4855

Browse files
author
Mohak Gupta
committed
test: cover wrong JSON types in the MCP robustness layer
The layer varies argument values but always sends the expected type. These nine send a value of the wrong JSON type for the request envelope fields parsed before tool dispatch: tool name, arguments, params and method. All nine pass against the current binary, so this is a regression guard for a class the layer does not currently reach, not a bug report. Signed-off-by: Mohak Gupta <mohakgupta0981@gmail.com>
1 parent 61b3b1b commit f8d4855

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎scripts/security-fuzz.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ test_payload "wrong jsonrpc version" '{"jsonrpc":"1.0","id":2,"method":"tools/ca
115115
test_payload "array instead of object" '[1,2,3]'
116116
test_payload "deeply nested json" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_graph","arguments":{"name_pattern":{"a":{"b":{"c":{"d":{"e":{"f":"deep"}}}}}}}}}'
117117

118+
echo ""
119+
echo "--- Wrong JSON types ---"
120+
121+
test_payload "null tool name" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":null,"arguments":{}}}'
122+
test_payload "numeric tool name" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":42,"arguments":{}}}'
123+
test_payload "object tool name" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":{"a":1},"arguments":{}}}'
124+
test_payload "array arguments" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_graph","arguments":[1,2]}}'
125+
test_payload "string arguments" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_graph","arguments":"nope"}}'
126+
test_payload "null arguments" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_graph","arguments":null}}'
127+
test_payload "array params" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":[1,2]}'
128+
test_payload "numeric params" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":7}'
129+
test_payload "numeric method" '{"jsonrpc":"2.0","id":2,"method":7,"params":{}}'
130+
118131
echo ""
119132
echo "--- Oversized inputs ---"
120133

0 commit comments

Comments
 (0)