T09 · Insecure Skill Coding Practices
- Location
scripts/realestate_api.py:175- Finding
Environment-Controlled API Endpoint Can Exfiltrate Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/realestate_api.py:175-182
Vulnerability Type: Unvalidated destination override for sensitive requests
Risk Level: HighVulnerable Code
python base_url = os.environ.get("BANA_REALESTATE_BASE_URL", DEFAULT_BASE_URL).rstrip("/") url = f"{base_url}/realestate/{method}" request = urllib.request.Request( url, data=json.dumps(payload, ensure_ascii=False).encode("utf-8"), headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST", )The request payload is constructed with the user's credentials:
python app_id, secure_key = get_credentials(args) spec = METHODS[args.method] payload: dict[str, Any] = {"app_id": app_id, "secure_key": secure_key}Technical Analysis
The destination of every API request can be replaced through the inherited
BANA_REALESTATE_BASE_URLenvironment variable. The implementation does not validate the URL scheme, hostname, port, or origin before transmitting the request.Because every payload includes both
app_idandsecure_key, a process launcher, local configuration, compromised automation environment, or other actor capable of controlling the script's environment can redirect credentials and user query data to an arbitrary server. Anhttp://override is also accepted, allowing credentials to be transmitted without transport encryption.SKILL.mdstates that the override should only be used for a user-provided or trusted test environment, but this is an instructional safeguard rather than an enforced security control.Attack Path
- An attacker obtains control over the environment used to launch the Skill, such as a wrapper script, automation configuration, inherited shell environment, or service definition.
- The attacker sets
BANA_REALESTATE_BASE_URLto an attacker-controlled URL, for examplehttps://attacker.example. - The user invok ...[truncated 886 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin production requests to the expected
https://wxpub.aibana.artorigin. - If endpoint overrides are required for testing, replace the implicit environment override with an explicit command-line option such as
--allow-test-endpoint. - Require an explicit warning or confirmation before sending credentials to a non-production origin.
- Parse the destination with
urllib.parse.urlsplitand enforce:- HTTPS only.
- An allowlisted hostname and port.
- No embedded username or password.
- No unexpected fragments or malformed authority components.
- Use separate, non-production credentials for test endpoints.
- Reject production credentials when the destination differs from the production origin.
- Consider clearing proxy-sensitive environment settings or documenting their trust requirements when the execution environment is not fully controlled.
- Pin production requests to the expected
