T09 · Insecure Skill Coding Practices
- Location
SKILL.md:33- Finding
Environment-Controlled API Base URL Can Expose the Bearer Token
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 33–37 and 72–86
Vulnerability Type: Unvalidated destination for authenticated API requests
Risk Level: MediumVulnerable Code
bash export DDT_API_KEY="ddt_live_xxxxxxxx" export DDT_OPEN_BASE="${DDT_OPEN_BASE:-https://gotoshop-ai.com/ddtclaw}"The configurable value is subsequently used in authenticated requests:
bash curl --fail --silent --show-error -G \ -H "Authorization: Bearer $DDT_API_KEY" \ "$DDT_OPEN_BASE/v1/retail/brand/profile" \ --data-urlencode "brand=美宜佳" curl --fail --silent --show-error -G \ -H "Authorization: Bearer $DDT_API_KEY" \ "$DDT_OPEN_BASE/v1/retail/brand/categories" \ --data-urlencode "brand=美宜佳" curl --fail --silent --show-error -G \ -H "Authorization: Bearer $DDT_API_KEY" \ "$DDT_OPEN_BASE/v1/retail/nearby" \ --data-urlencode "lng=121.5" \ --data-urlencode "lat=31.2" \ --data-urlencode "radius=3000"Technical Analysis
The shell parameter expansion preserves any preexisting
DDT_OPEN_BASEvalue without validating its scheme, hostname, port, or path. The documentedcurlcommands then attach the API bearer token to requests sent to that destination.If an attacker can influence the execution environment, such as through a poisoned shell profile, CI/CD variable, wrapper process, or inherited environment configuration, the attacker can redirect authenticated requests to a server under their control. This violates the principle that credentials should only be transmitted to explicitly trusted and authenticated origins.
Although the examples use HTTPS by default, the configuration accepts arbitrary destinations, potentially including an attacker-controlled HTTPS endpoint or a plaintext HTTP endpoint.
Attack Path
- The attacker gains the ability to define or modify an inherited environment variable.
- The attacker sets
DDT_OPEN_BASEto an attacker-controlled URL. - A user or agent executes the initialization ...[truncated 922 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin authenticated requests to the documented origin rather than inheriting an unrestricted environment value:
bash readonly DDT_OPEN_BASE="https://gotoshop-ai.com/ddtclaw"-
If endpoint configurability is required, validate it before sending credentials. Enforce:
- The
httpsscheme. - An explicit hostname allowlist.
- An expected port.
- No embedded user information.
- An approved base path.
- The
-
Refuse the request when validation fails, and never attach the
Authorizationheader to an untrusted origin. -
Separate production and development credentials. If local or staging endpoints must be supported, use distinct limited-scope keys for each approved environment.
-
Apply least privilege, expiration, rotation, and usage monitoring to API keys. Revoke and rotate any key suspected of exposure.
-
Document that proxies, redirects, and inherited environment variables must not move authorization headers outside the approved service origin. Configure the HTTP client to reject unsafe cross-origin redirects.
