T09 · Insecure Skill Coding Practices
- Location
scripts/hot_scanner.py:99- Finding
API Credential Can Be Redirected to an Arbitrary Server
- Content
View full analysis
Vulnerability Details
File Location:
scripts/hot_scanner.py:99-106
Vulnerability Type: Arbitrary API endpoint configuration causing credential disclosure
Risk Level: MediumVulnerable Code
python def get_client() -> OpenAI: api_key = os.environ.get("AISA_API_KEY") if not api_key: print("❌ Error: AISA_API_KEY environment variable is not set.", file=sys.stderr) print(" Set it with: export AISA_API_KEY=your_key_here", file=sys.stderr) sys.exit(1) base_url = os.environ.get("AISA_BASE_URL", "https://api.aisa.one/v1") return OpenAI(api_key=api_key, base_url=base_url)Technical Analysis
Network access and use of
AISA_API_KEYare necessary for the Skill's declared market-scanning functionality. However, the code permitsAISA_BASE_URLto select an arbitrary API server without validating its scheme or hostname.The OpenAI-compatible client authenticates requests using the supplied API key. Consequently, changing
AISA_BASE_URLredirects credential-bearing requests away from the declared AISA service. An attacker who can influence the process environment can cause the Skill to disclose the AISA credential to an attacker-controlled endpoint.This configurability exceeds the minimum privilege required to communicate with the declared service because the production credential does not need to be transmitted to arbitrary hosts.
Attack Path
- An attacker gains influence over the environment used to launch the Skill, such as a deployment configuration, shell profile, wrapper script, or environment file.
- The attacker sets
AISA_BASE_URLto an HTTPS endpoint under their control. - A user invokes
scripts/hot_scanner.pywith a validAISA_API_KEY. get_client()constructs the client using the attacker-controlled base URL and the legitimate API key.- The scanner makes a chat-completion request to the attacker's server and includes a ...[truncated 643 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
AISA_BASE_URLoverride if custom endpoints are not an essential supported feature:python return OpenAI( api_key=api_key, base_url="https://api.aisa.one/v1", ) - If endpoint customization is required, parse the URL and enforce:
- An
httpsscheme. - An explicit allowlist of trusted hostnames.
- No embedded user information.
- An approved port.
- An
- Use separate, restricted credentials for development or testing endpoints rather than forwarding the production AISA key.
- Document the endpoint configuration and its credential-disclosure implications.
- Apply least-privilege API scopes, usage limits, credential rotation, and monitoring for suspicious key use.
- Avoid including authorization headers or secrets in errors, diagnostics, or request logs.
- Remove the
