T09 · Insecure Skill Coding Practices
- Location
server.py:12- Finding
Hardcoded Default Bearer Token Allows Unauthorized MCP Access
- Content
View full analysis
AccessToken | None: if token == API_TOKEN: return AccessToken(token=token, client_id="default", scopes=[]) return None ``` ### Technical Analysis The MCP server uses the hardcoded string `yanpan-mcp-secret-2026` whenever the `API_TOKEN` environment variable is absent. The application therefore starts successfully with a publicly known credential instead of failing securely. Because the source code discloses the default token, anyone who can reach the MCP service can authenticate as the shared `default` client. The server also assigns no differentiated scopes or identities, so all clients possessing the token receive access to every registered MCP tool. ### Attack Path 1. An administrator starts `server.py` without explicitly setting `API_TOKEN`. 2. The server silently selects `yanpan-mcp-secret-2026` as its bearer token. 3. The service listens on the configured network interface and port. 4. An attacker obtains the token from the public package or source code. 5. The attacker connects to the MCP endpoint and sends: ```http Authorization: Bearer yanpan-mcp-secret-2026 ``` 6. `StaticTokenVerifier` accepts the token and gives the attacker access to all exposed tools. 7. The attacker queries research reports, news-analysis records, and stock-analysis records through the authenticated MCP interface. ### Impact Assessment An attacker can bypass the intended API-key issuance process and obtain unauthorized read access to all information exposed by the three MCP tools. The affected scope includes broker research report co ...[truncated 364 chars]- Remediation
View remediation
