T09 · Insecure Skill Coding Practices
Error
- Location
- references/failure-patterns.md:482
- Finding
- Authentication Tokens Can Be Printed and Disclosed Through Support Artifacts<![CDATA[ ## Vulnerability Details **File Location**: `references/failure-patterns.md`, lines 482–498; related unsafe inspection command at lines 231–232 **Vulnerability Type**: Sensitive information exposure through diagnostic output **Risk Level**: High ### Vulnerable Snippet ```text What to inspect: - the raw bytes of the env line, not just the masked output: ``` node -e 'const fs=require("fs"); const p=process.env.HOME+"/.openclaw/service-env/<service-env-file>"; const l=fs.readFileSync(p,"utf8").split("\n").find(l=>l.startsWith("export <TOKEN_ENV_NAME>=")); console.log(JSON.stringify(l))' ``` - a clean line has a single shell-quoted token value with no inner literal double quotes - a corrupted line has literal `"` characters just inside the shell quotes - check every `*_TOKEN` / `*_API_KEY` line in the env file the same way; the same writer emits all of them Recovery: - back up the env file: `cp <env> <env>.bak-token-fix-<date>` - rewrite the affected lines using the value from `secrets.json` (which is the canonical clean value), shell-single-quoted with no inner JSON wrapping; only safe if the secret itself contains no single quotes (almost always the case for API tokens) - restart the gateway through the host service manager - re-run `openclaw channels status --deep` and confirm the channel reconnects Why it matters: - this is a packaging defect in the env-file writer, not operator drift; the local fix is fragile because the next regeneration will re-corrupt the file - share upstream or with support: exact line bytes, the source `secrets.json` value type (string), and the affected host version ``` A related command directly prints the configured Discord token: ```text - To disambiguate, inspect the actual config field directly: - `node -e 'const c=JSON.parse(require("fs").readFileSync(process.env.HOME+"/.openclaw/openclaw.json","utf8")); console.log(typeof c.channels?.discord?.token, c.channels?.discord?.token)'` ``` ### Technical Analysis ...[truncated 2630 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace value-printing commands with structural checks that never emit secret contents. - Report only whether the variable exists. - Report whether unwanted inner quotes are present. - Report the value length only if operationally necessary. - Avoid hashes unless there is a specific comparison need, since hashes of low-entropy secrets may also be sensitive. 2. Change the configuration inspection command to print only the field type: ```sh node -e 'const c=JSON.parse(require("fs").readFileSync(process.env.HOME+"/.openclaw/openclaw.json","utf8")); console.log(typeof c.channels?.discord?.token)' ``` 3. For environment-line validation, parse the assignment locally and emit a boolean result such as: ```text token variable found: yes unexpected inner double quotes: yes ``` 4. Replace the instruction to share “exact line bytes” with a requirement to share a redacted representation, for example: ```text export CHANNEL_TOKEN='<redacted>' outer shell quotes: present inner literal double quotes: present source value type: string ``` 5. Add an explicit warning that command output generated by older versions of the runbook may contain live credentials and must not be uploaded or pasted into reports. 6. If a token has already appeared in an Agent transcript, terminal recording, support ticket, or other external artifact: - Revoke and rotate it. - Remove the artifact where possible. - Review channel or API logs for unauthorized use. - Update the sanitized handoff notes with the rotation time, but not the replacement value. ]]>
