use super::AttackTest;
use serde_json::json;
pub fn tests() -> Vec<AttackTest> {
vec![
AttackTest {
id: "A10.1",
name: "ReDoS nested quantifier rejection",
class: "DoS & Resource Exhaustion",
payload: json!({
"tool": "vellaveto", "function": "regex_compile",
"parameters": {
"pattern": "^(a+)+b$",
"test_input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}),
check_fn: |body: &serde_json::Value, status: u16| -> bool {
if status == 400 {
return true;
}
if let Some(err) = body.get("error") {
return err.as_str().is_some_and(|s| {
s.contains("quantifier") || s.contains("regex") || s.contains("rejected")
});
}
status == 200
},
},
AttackTest {
id: "A10.2",
name: "Oversized MCP message rejection",
class: "DoS & Resource Exhaustion",
payload: {
let big_value = "X".repeat(1_048_577);
json!({
"tool": "file", "function": "read",
"parameters": {"data": big_value}
})
},
check_fn: |_body: &serde_json::Value, status: u16| -> bool {
status == 413 || status == 400 || status == 429
},
},
AttackTest {
id: "A10.3",
name: "Parameter bomb",
class: "DoS & Resource Exhaustion",
payload: {
let mut params = serde_json::Map::new();
for i in 0..10_000 {
params.insert(format!("param_{i}"), json!("value"));
}
json!({
"tool": "file", "function": "read",
"parameters": params
})
},
check_fn: |_body: &serde_json::Value, status: u16| -> bool {
status != 500
},
},
AttackTest {
id: "A10.4",
name: "Rate limiting enforcement",
class: "DoS & Resource Exhaustion",
payload: json!({
"tool": "file", "function": "read",
"parameters": {"path": "/tmp/test"},
"_test_rapid_requests": 100
}),
check_fn: |body: &serde_json::Value, status: u16| -> bool {
status == 429
|| body.get("rate_limited").and_then(|r| r.as_bool()) == Some(true)
|| body.get("rate_limits_enabled").and_then(|r| r.as_bool()) == Some(true)
},
},
]
}