T09 · Insecure Skill Coding Practices
- Location
SKILL.md:35- Finding
API Key Exposure Through a Command-Line Query String
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 35–37
Vulnerability Type: API key exposure in command-line arguments and URL query parameters
Risk Level: MediumVulnerable Code
bash claude mcp add --transport http pharma_intelligence \ "https://connect.patsnap.com/096456/Logic-mcp?apiKey=sk-xxxxxxxxxxxx"The same insecure configuration pattern is repeated in
SKILL.md, lines 74–77:bash claude mcp add --transport http pharma_intelligence \ "https://connect.patsnap.com/096456/Logic-mcp?apiKey=你的API_KEY"Technical Analysis
The setup instructions require users to replace the placeholder with a live PatSnap API key and place it directly in a URL passed on the command line. Although HTTPS protects the URL while it is transported over the network, it does not protect the credential at the local endpoint or from application and infrastructure logging.
The complete key-bearing URL may be exposed through:
- Shell history files
- MCP client configuration
- Process inspection or command-line telemetry
- Debug output and diagnostic bundles
- Proxy, gateway, and server access logs
- Terminal transcripts, screenshots, and copied error reports
- Backups containing command history or configuration files
Authentication is necessary for the Skill's declared functionality, and the endpoint belongs to the disclosed PatSnap service. Therefore, the evidence does not establish malicious exfiltration. However, transmitting the credential as a query parameter and command-line argument creates unnecessary exposure and does not follow least-disclosure practices. Authorization headers or protected secret references are safer alternatives.
Attack Path
- A user replaces
sk-xxxxxxxxxxxxor你的API_KEYwith a valid API key. - The user executes the documented command.
- The full command or resulting endpoint is retained in shell history, MCP configuration, process telemetry, or logs.
- An attacker with access to any exposed ...[truncated 1061 chars]
- Remediation
View remediation
Remediation Suggestions
-
Prefer an authorization header
- Use a provider-supported
Authorization: Bearer ...header rather than a URL query parameter. - Ensure the MCP client does not print authentication headers in ordinary logs.
- Use a provider-supported
-
Use protected secret injection
- Read the API key from a protected environment variable, operating-system credential manager, or MCP secret store.
- Store only a secret reference in the MCP configuration, not the credential value.
-
Avoid command-line exposure
- Use an interactive secret prompt or protected configuration input.
- If environment variables are supported, document secure variable expansion without placing the resolved secret into persisted configuration or logs.
-
Harden logging
- Redact
apiKeyand other credential-bearing query parameters from client, proxy, gateway, and server logs. - Exclude credentials from diagnostics, error messages, and telemetry.
- Redact
-
Protect local artifacts
- Restrict permissions on MCP configuration and shell-history files.
- Do not include credential-bearing configuration in source control, support archives, or shared terminal transcripts.
-
Rotate exposed credentials
- Revoke and rotate any production key previously configured using this command.
- Review usage records for unexpected requests or quota consumption.
-
Update both documented examples
- Replace the patterns at lines 35–37 and 74–77 so users are not instructed to insert real credentials into URLs.
-
