T09 · Insecure Skill Coding Practices
- Location
scripts/quickstart.py:29- Finding
Unvalidated API Endpoint in Quickstart Script Redirects Authenticated Requests
- Content
View full analysis
Vulnerability Details
File Location:
scripts/quickstart.py:29-40
Vulnerability Type: Unvalidated credential-bearing API endpoint
Risk Level: MediumVulnerable Code
python endpoint = get_env("AGENTRUN_ENDPOINT") access_key_id = get_env("ALICLOUD_ACCESS_KEY_ID") access_key_secret = get_env("ALICLOUD_ACCESS_KEY_SECRET") security_token = os.getenv("ALICLOUD_SECURITY_TOKEN") or os.getenv("ALIBABA_CLOUD_SECURITY_TOKEN") config = open_api_models.Config( access_key_id=access_key_id, access_key_secret=access_key_secret, endpoint=endpoint, ) if security_token: config.security_token = security_tokenTechnical Analysis
The
AGENTRUN_ENDPOINTenvironment variable is passed directly to the Alibaba Cloud SDK client without checking that it identifies an approved Alibaba Cloud AgentRun service. The project documents a finite set of official public and VPC endpoints inreferences/endpoints.md, but the implementation does not enforce that list.The same configuration object contains the AccessKey ID, AccessKey secret, and optional temporary security token used to sign requests. The secret is normally used locally for signing rather than transmitted directly; however, a malicious endpoint can receive signed authentication metadata, the AccessKey ID, an optional security token, request parameters, and resource information. Depending on the signature freshness and SDK behavior, captured signed requests may also present a limited replay risk.
Exploitation requires an attacker to influence the process environment, launch configuration, wrapper script, CI configuration, or agent-generated command that sets
AGENTRUN_ENDPOINT.Attack Path
- The attacker influences
AGENTRUN_ENDPOINTand sets it to an attacker-controlled host. - A user or automation process supplies valid Alibaba Cloud credentials and runs
quickstart.py. - The script constructs an SD ...[truncated 917 chars]
- The attacker influences
- Remediation
View remediation
Remediation Suggestions
- Replace the arbitrary endpoint variable with a validated region identifier and derive the endpoint from a static region-to-host mapping.
- If custom endpoints are required, parse and normalize the value before use and allow only the exact official hosts listed in
references/endpoints.md. - Require TLS and reject plaintext HTTP, embedded user information, unexpected ports, IP literals, malformed hostnames, and hostname suffix tricks.
- Ensure redirects are disabled or restricted so that authenticated requests cannot be redirected to an unapproved host.
- Prefer short-lived RAM credentials with only the
ListAgentRuntimespermission required by this script. - Add automated tests for malicious endpoint values such as look-alike domains, subdomain suffix attacks, user-information syntax, IP addresses, and non-TLS URLs.
