T09 · Insecure Skill Coding Practices
- Location
scripts/rumor_scanner.py:147- Finding
API Credential Can Be Redirected to an Arbitrary Network Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/rumor_scanner.py, lines 147–154 and 174–181
Vulnerability Type: Unvalidated credential destination
Risk Level: HighVulnerable 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)The resulting client transmits an authenticated request here:
python response = client.chat.completions.create( model=model, messages=[ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": prompt}, ], temperature=0.2, )Technical Analysis
The code obtains the sensitive
AISA_API_KEYcredential and supplies it to an OpenAI-compatible client. The request destination is selected through the undocumentedAISA_BASE_URLenvironment variable without validating its scheme, hostname, port, or trust relationship.An attacker who can influence the process environment can set this variable to an attacker-controlled endpoint. The SDK will then use the AISA credential when making a request to that endpoint. The implementation also does not explicitly reject plaintext HTTP, creating a potential credential-disclosure risk if an insecure URL is accepted by the SDK.
The default endpoint,
https://api.aisa.one/v1, is consistent with the Skill's declared remote market-scanning functionality. Sending authentication to that service is necessary. Allowing unrestricted endpoint substitution, however, exceeds the minimum privileges required by the documented behavior.Attack Path
- An attacker, compromised launcher, wrapper script ...[truncated 1233 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the
AISA_BASE_URLoverride if custom endpoints are not required:python return OpenAI( api_key=api_key, base_url="https://api.aisa.one/v1", ) -
If endpoint customization is a legitimate requirement, parse and validate the URL before creating the client:
- Require
https. - Reject embedded credentials.
- Require an exact allowlist of trusted hostnames and ports.
- Reject loopback, link-local, private-network, and unapproved hosts.
- Avoid permissive suffix checks that can accept deceptive domains.
- Require
-
Ensure credentials are not forwarded across redirects to a different origin. Disable redirects where possible or validate every redirect destination before retaining authentication headers.
-
Document the endpoint override and its security implications if it must remain supported.
-
Use a narrowly scoped, revocable API key with usage limits and monitoring. Rotate the key immediately if endpoint manipulation or credential exposure is suspected.
-
Add automated tests confirming that plaintext HTTP and unapproved destinations are rejected before any authenticated network request occurs.
-
