T09 · Insecure Skill Coding Practices
- Location
scripts/search.sh:73- Finding
Bearer Credential Disclosure Through an Unrestricted API Destination
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search.sh, lines 73–77
Vulnerability Type: Unrestricted credential destination
Risk Level: MediumVulnerable Code
bash RESPONSE=$(curl -s -G \ --url "https://${CLOUDSWAYS_BASE_PATH}/search/${CLOUDSWAYS_ENDPOINT}/smart" \ --header "Authorization: Bearer ${CLOUDSWAYS_AK}" \ --header "pragma: no-cache" \ "${CURL_ARGS[@]}")Technical Analysis
The script constructs the request URL from the environment-controlled
CLOUDSWAYS_BASE_PATHvalue and unconditionally sendsCLOUDSWAYS_AKto that destination as a bearer credential. It does not validate the resulting hostname against an allowlist of official Cloudsways service domains.Consequently, any party capable of influencing the script's environment can select an attacker-controlled HTTPS host. The use of TLS does not prevent this disclosure because TLS only protects the connection to the selected host; it does not establish that the selected host is an authorized recipient of the credential.
The accompanying documentation requires users to configure the destination through
CLOUDSWAYS_BASE_PATH, but it does not impose a hostname restriction. AlthoughSKILL.mdprovidessearchmcp.cloudsway.netas an MCP example, the shell script does not enforce that or another documented official domain.Attack Path
- An attacker influences environment configuration, a wrapper script, deployment settings, or copied setup instructions.
- The attacker sets
CLOUDSWAYS_BASE_PATHto an HTTPS host under their control. - A user or agent invokes
scripts/search.shwith a search request. - The script connects to the attacker-selected host.
- The request includes
Authorization: Bearer ${CLOUDSWAYS_AK}. - The attacker captures the access key and the submitted search query.
- Subject to the API key's server-side permissions, the attacker can replay the credential against the legitimate service.
Impact Assessment
Success ...[truncated 516 chars]
- Remediation
View remediation
Remediation Suggestions
- Hardcode the official API hostname when only one service destination is supported.
- If destination configurability is required, validate the canonical hostname against a strict allowlist of documented Cloudsways domains before invoking
curl. - Keep tenant, endpoint, and path identifiers separate from the network hostname; do not accept a complete credential destination through an unrestricted environment variable.
- Reject values containing schemes, user-information components, ports, path separators, query delimiters, fragments, whitespace, control characters, or other URL metacharacters.
- Fail closed when destination validation fails, and never attach the
Authorizationheader to an unapproved host. - Consider using a restrictive curl configuration such as
--proto '=https'and appropriate redirect controls. If redirects are enabled in the future, ensure credentials cannot be forwarded to another origin. - Document the exact approved hostname format and rotate the access key if it may previously have been sent to an untrusted destination.
- Apply server-side least privilege, expiration, usage monitoring, and revocation controls to reduce the impact of credential disclosure.
