T09 · Insecure Skill Coding Practices
Warning
- Location
- run.sh:4
- Finding
- Bridge secret and Workspace data can be transmitted to an arbitrary endpoint<![CDATA[ ## Vulnerability Details **File Location**: `run.sh:4-9` **Vulnerability Type**: Unvalidated service endpoint with automatic credential forwarding **Risk Level**: Medium ### Complete Code Snippet ```bash BASE_URL="${GMAIL_BRIDGE_URL:-http://127.0.0.1:8787}" SECRET="${BRIDGE_SECRET:-}" # optional; if your bridge enforces x-bridge-secret hdrs=() if [[ -n "${SECRET}" ]]; then hdrs=(-H "x-bridge-secret: ${SECRET}") fi ``` ### Technical Analysis The script allows `GMAIL_BRIDGE_URL` to override the documented loopback endpoint without validating the destination host, scheme, or port. When `BRIDGE_SECRET` is present, the script automatically adds it to every request as the `x-bridge-secret` header. Consequently, a party capable of influencing the script's environment can redirect requests to an arbitrary HTTP or HTTPS server. This exposes both the bridge secret and request content to that server. Depending on the invoked operation, exposed information can include Gmail queries and message identifiers, Drive queries and file identifiers, spreadsheet identifiers and values, or calendar details. The default URL uses unencrypted HTTP. While loopback HTTP does not traverse an external network under normal conditions, an overridden URL may also use plaintext HTTP because the script does not enforce transport security. ### Attack Path 1. The attacker gains the ability to control or inject environment variables for the process invoking `run.sh`, such as through a wrapper, task configuration, inherited environment, or compromised launcher. 2. The attacker sets `GMAIL_BRIDGE_URL` to an attacker-controlled endpoint, for example `http://attacker.example:8787`. 3. The legitimate environment contains `BRIDGE_SECRET`, or the user exports it according to the skill documentation. 4. The user or agent invokes any supported operation. 5. `curl` sends the `x-bridge-secret` header and operation-specific request data to the attacker-controlled server. 6. If the capt ...[truncated 774 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `GMAIL_BRIDGE_URL` override if remote bridge endpoints are not a required feature. 2. If configurability is required, parse the URL and allow only explicitly approved loopback hosts such as `127.0.0.1`, `[::1]`, or a strictly controlled allowlist. 3. Reject URLs containing user information, fragments, unexpected ports, or unsupported schemes. 4. Require HTTPS for every non-loopback destination. 5. Attach `x-bridge-secret` only after validating that the destination is trusted. 6. Consider using a local Unix-domain socket to avoid network destination ambiguity. 7. Configure `curl` to reject redirects, or ensure credentials are never forwarded across redirects. Explicitly use options such as `--proto '=https'` for approved remote endpoints and an appropriate redirect policy. 8. Store the secret with the narrowest possible permissions and rotate it immediately if it may have been transmitted to an untrusted endpoint. ]]>
