MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / test_no_authentication

Function test_no_authentication

tests/security/test_access_control.py:45–95  ·  view source on GitHub ↗

Test if API requires authentication

(tester)

Source from the content-addressed store, hash-verified

43
44
45def 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
98def test_network_binding(tester):

Callers 1

mainFunction · 0.85

Calls 5

SerialStudioClientClass · 0.90
commandMethod · 0.80
log_vulnerabilityMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected