T09 · Insecure Skill Coding Practices
- Location
scripts/zodiac_pairing_query.py:22- Finding
Configurable API Endpoint Can Disclose the AppKey and Query Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/zodiac_pairing_query.py, lines 22 and 137–139
Vulnerability Type: Unvalidated API endpoint override and credential exposure
Risk Level: MediumVulnerable Code:
python API_BASE_URL = os.environ.get("JIKE_API_BASE_URL", "https://api.jikeapi.cn").rstrip("/")python url = f"{API_BASE_URL}{API_PATH}?{urllib.parse.urlencode({**params, 'appkey': appkey})}" try: with urllib.request.urlopen(url, timeout=15) as response:Technical Analysis
The API base URL is taken from the undocumented
JIKE_API_BASE_URLenvironment variable without validating its scheme or hostname. The script subsequently includes the AppKey in the query string and sends the resulting request to the configured origin.An attacker who can influence the process environment can replace the expected
https://api.jikeapi.cnorigin with an attacker-controlled endpoint. When the skill is invoked, the request discloses the AppKey and zodiac query parameters to that endpoint.Placing the AppKey in the URL also increases its exposure because complete URLs may be retained by HTTP servers, reverse proxies, monitoring systems, or diagnostic logs.
The environment-modification prerequisite limits exploitability: this flaw does not independently grant an attacker local execution or permission to change environment variables.
Attack Path
- The attacker gains the ability to influence the environment used to launch the skill, such as through an unsafe wrapper, deployment configuration, or inherited process environment.
- The attacker sets
JIKE_API_BASE_URLto an endpoint under their control. - A user or AI agent invokes the documented zodiac-pairing script with legitimate query parameters.
- The script reads a valid AppKey from the CLI, environment, or
scripts/.env. - The script constructs a URL containing the AppKey and query parameters.
- `urllib.request.urlop ...[truncated 822 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the runtime endpoint override and use a fixed trusted endpoint:
python API_BASE_URL = "https://api.jikeapi.cn" -
If endpoint configurability is required for testing, parse the URL and enforce an explicit allowlist:
- Require the
httpsscheme. - Require the exact approved hostname.
- Reject embedded credentials, unexpected ports, fragments, and unapproved subdomains.
- Keep testing overrides unavailable in production builds.
- Require the
-
Prefer transmitting the AppKey in an authorization header rather than in the query string if the service supports it. This reduces exposure through URL logging and monitoring infrastructure.
-
Ensure application logs, exceptions, proxy logs, and telemetry redact credentials and sensitive query parameters.
-
Isolate the skill's execution environment so untrusted users or workloads cannot set or override security-sensitive environment variables.
-
Rotate the AppKey if the script may previously have run with an untrusted
JIKE_API_BASE_URL, and review API usage records for unauthorized activity.
-
