Test batch command abuse
(tester)
| 308 | |
| 309 | |
| 310 | def test_batch_abuse(tester): |
| 311 | """Test batch command abuse""" |
| 312 | print("\n[*] Testing batch command abuse...") |
| 313 | |
| 314 | with SerialStudioClient() as client: |
| 315 | # Test 1: Huge batch request |
| 316 | print(" - Testing oversized batch (10000 commands)...") |
| 317 | huge_batch = [{"command": "api.getCommands"} for _ in range(10000)] |
| 318 | |
| 319 | try: |
| 320 | start = time.time() |
| 321 | results = client.batch(huge_batch, timeout=30.0) |
| 322 | elapsed = time.time() - start |
| 323 | |
| 324 | # Check if server rejected the batch (error dict returned) |
| 325 | if isinstance(results, dict) and results.get("error"): |
| 326 | print(f" Server rejected batch: {results.get('message')} (GOOD)") |
| 327 | elif isinstance(results, list) and len(results) > 0: |
| 328 | tester.log_vulnerability( |
| 329 | "MEDIUM", |
| 330 | "Batch Processing", |
| 331 | f"Server processed {len(results)} commands in {elapsed:.2f}s without limit", |
| 332 | f"{len(huge_batch)} commands", |
| 333 | ) |
| 334 | else: |
| 335 | print(" Server rejected batch (GOOD)") |
| 336 | except (APIError, TimeoutError) as e: |
| 337 | print(f" Server rejected or timed out: {e} (GOOD)") |
| 338 | |
| 339 | # Test 2: Nested batch requests (if possible) |
| 340 | print(" - Testing recursive batch commands...") |
| 341 | try: |
| 342 | # Try to create recursive structure |
| 343 | recursive_batch = [ |
| 344 | { |
| 345 | "command": "project.loadJson", |
| 346 | "params": {"config": {"title": f"Level-{i}"}}, |
| 347 | } |
| 348 | for i in range(100) |
| 349 | ] |
| 350 | results = client.batch(recursive_batch) |
| 351 | print(f" Processed {len(results)} nested commands") |
| 352 | except (APIError, TimeoutError): |
| 353 | print(" Rejected (GOOD)") |
| 354 | |
| 355 | |
| 356 | def test_connection_exhaustion(tester): |
no test coverage detected