T09 · Insecure Skill Coding Practices
Note
- Location
- scripts/hosted-smoke.mjs:136
- Finding
- Partial API Key Disclosure in Smoke-Test Output## Vulnerability Details **File Location**: `scripts/hosted-smoke.mjs`, lines 136-149 **Vulnerability Type**: Sensitive credential material exposed through logging **Risk Level**: Low **Vulnerable Code**: ```js console.log( JSON.stringify( { health_ok: Boolean(health?.ok), bootstrap_user: bootstrap.userId ?? null, api_key_prefix: apiKey.slice(0, 9), me_user: me.userId ?? null, me_api_keys: Array.isArray(me.apiKeys) ? me.apiKeys.length : null, run_dir: path.relative(repoRoot, runDir), }, null, 2, ), ); ``` ### Technical Analysis The script prints the first nine characters of a newly generated API key to standard output. This credential fragment is not required to establish that bootstrap or authenticated endpoint validation succeeded. Standard output is commonly retained in CI job logs, terminal transcripts, build artifacts, and handoff records. Consequently, the API-key prefix may remain accessible longer and to more users than the credential itself. Although a prefix alone ordinarily does not permit authentication, it reduces credential secrecy and may support correlation, identification, or guessing attacks if the remaining key material has insufficient entropy or is disclosed elsewhere. The API key is otherwise sent only to a loopback endpoint as part of the declared authenticated smoke test. That local transmission is necessary for the test and does not constitute external exfiltration. ### Attack Path 1. A user or CI runner executes the hosted smoke script. 2. The gateway issues an API key during bootstrap. 3. The script writes the first nine characters of that key to standard output. 4. CI infrastructure or another logging system retains the output. 5. An actor with access to those logs obtains the key prefix. 6. The actor correlates the prefix with separately exposed credential material or exploits weak remaining-key entropy, if suc ...[truncated 452 chars]
- Remediation
- ## Remediation Suggestions - Remove the `api_key_prefix` field from smoke-test output. - Log only whether an API key was returned, such as `api_key_received: true`. - If run correlation is operationally necessary, calculate a one-way cryptographic digest of the key and expose only a short digest identifier rather than any literal credential characters. - Ensure smoke-test credentials are short-lived, restricted to test data, and revoked or invalidated after the run. - Configure CI systems to redact credentials and limit access and retention for smoke-test logs.
