Test if API requires authentication
(tester)
| 43 | |
| 44 | |
| 45 | def test_no_authentication(tester): |
| 46 | """Test if API requires authentication""" |
| 47 | print("\n[*] Testing authentication requirements...") |
| 48 | |
| 49 | # Test 1: Direct connection without credentials |
| 50 | print(" - Testing unauthenticated access...") |
| 51 | try: |
| 52 | with SerialStudioClient() as client: |
| 53 | result = client.command("api.getCommands") |
| 54 | |
| 55 | tester.log_vulnerability( |
| 56 | "HIGH", |
| 57 | "No Authentication", |
| 58 | "API accepts connections without any authentication", |
| 59 | ) |
| 60 | |
| 61 | # List available commands |
| 62 | commands = result.get("commands", []) |
| 63 | print(f" Accessible commands: {len(commands)}") |
| 64 | |
| 65 | # Check for sensitive commands |
| 66 | sensitive_commands = [] |
| 67 | for cmd in commands: |
| 68 | cmd_name = cmd.get("name", "") |
| 69 | if any( |
| 70 | keyword in cmd_name.lower() |
| 71 | for keyword in [ |
| 72 | "disconnect", |
| 73 | "connect", |
| 74 | "open", |
| 75 | "close", |
| 76 | "write", |
| 77 | "set", |
| 78 | "delete", |
| 79 | "remove", |
| 80 | ] |
| 81 | ): |
| 82 | sensitive_commands.append(cmd_name) |
| 83 | |
| 84 | if sensitive_commands: |
| 85 | tester.log_vulnerability( |
| 86 | "CRITICAL", |
| 87 | "Authorization", |
| 88 | f"Unauthenticated access to {len(sensitive_commands)} sensitive commands", |
| 89 | ) |
| 90 | print(f" Sensitive commands exposed: {len(sensitive_commands)}") |
| 91 | for cmd in sensitive_commands[:10]: |
| 92 | print(f" - {cmd}") |
| 93 | |
| 94 | except Exception as e: |
| 95 | print(f" Authentication may be required: {e}") |
| 96 | |
| 97 | |
| 98 | def test_network_binding(tester): |
no test coverage detected