T09 · Insecure Skill Coding Practices
- Location
src/export.js:21- Finding
Shareable configuration tokens can disclose plaintext credentials
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is for OpenClaw config safety, but several implementation gaps could expose credentials or unexpectedly change a live configuration.
Review before installing. Do not treat exported `mrconf:v1` tokens as safe to share unless you have verified the decoded payload contains no plaintext secrets. Avoid running the validator or import/normalize flows against important configs without a backup and manual review, because the current scripts may modify live OpenClaw configuration unexpectedly.
src/export.js:21Shareable configuration tokens can disclose plaintext credentials
src/normalize.js:202Normalization silently deletes protected configuration fields
scripts/validate-openclaw-config.sh:229Pre-write validation may run a fixing command against the live configuration
src/doctor-check.js:45Predictable temporary directory enables local symlink and file-manipulation attacks
Referenced artifact was not completely inspected
- `EXPORT-TOKEN-SPEC.md` — token format spec
The module-level security claim says resolved credential values are never logged or exposed, but the implementation resolves credential references and returns the substituted config object to the caller. This creates a confidentiality risk because downstream code may treat the returned object as non-sensitive and log, serialize, or transmit secrets based on the misleading contract.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
const childPath = fieldPath ? `${fieldPath}.${key}` : key;
// Skip env subtrees (opaque)
if (childPath.endsWith(".env") || childPath === "env") continue;
// Skip secret:// refs (opaque) — preserve as-is, don't recurse
if (isString(val) && val.startsWith("secret://")) {
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
// Sync versions for non-TTY contexts
function promptYesNoSync(question, defaultYes = false) {
if (!process.stdin.isTTY) return false;
return promptYesNo(question, defaultYes);
}
function promptTextSync(question, defaultValue = "") {
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
// Sync versions for non-TTY contexts
function promptYesNoSync(question, defaultYes = false) {
if (!process.stdin.isTTY) return false;
return promptYesNo(question, defaultYes);
}
function promptTextSync(question, defaultValue = "") {
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
env: { NODE_ENV: "production", API_KEY: "super-secret" },
});
assertEqual(result.normalized.env, undefined, "env subtree stripped from output (handled specially)");
// Note: env subtree should be passed through, not stripped. Let me check... Actually in normalizeValue, the .env key is handled specially. Let me verify the actual behavior.
// ─── Security: no value exposure in warnings ─────────────────────────────────
The trigger list is very broad for a high-impact configuration skill, covering generic phrases like config edit, validation, imports/exports, updates, and restart-related tasks. Overbroad activation can cause the skill to engage in situations outside its narrowly intended scope, increasing the chance that an agent applies config-changing guidance unnecessarily or in the wrong context.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Exit codes: 0 = success, 1 = failure, 2 = invalid arguments.
### `validate-openclaw-config.sh` — Pre-write validator
Run before any direct edit to openclaw.json:
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
# Protocol: openclaw.json Config Edits
**Applies to:** Any write to `~/.openclaw/openclaw.json` — direct edit, scripted update, doctor --fix auto-commit, config token import.
**Why this exists:** Without a pre-write gate, invalid fields (e.g. `status`, `note` in per-model overrides — fields outside the Zod schema) cause gateway crashes. The validator and wizard are the safety net.
The spec contains a security-significant contradiction: it claims imports are validated before substitution, but the documented flow actually resolves credentials and substitutes ${REF} values into the config before the final schema validation. If any downstream logic, normalization, logging, or provider-specific parsing touches substituted values prior to strict validation, malformed or attacker-controlled token content could trigger unsafe behavior or leak secrets despite the stated security model.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Offer to create an export token:
🔐 Export Token
The non-interactive --import <token> mode is specified to replace the current config without any confirmation, even though the document elsewhere acknowledges import is destructive. In automation or when invoked by another tool, this can allow silent configuration replacement, causing denial of service, unsafe reconfiguration, or unexpected agent behavior if an untrusted token is supplied.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
---
## Post-Write Verification
After any write to `openclaw.json`:
The credential-handling section states the wizard 'Only validates' that ${REF} placeholders are present in the config, which implies no secret resolution behavior. The very next line says that on import it resolves references from environment variables or pass, which is a materially different and more powerful operation than mere presence validation.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
- `src/audit.js` — config summary generator
- `src/prompt.js` — TTY prompt helpers (yes/no, text input, menu)
- `src/config-patch.js` — safe config merge for import
- `src/doctor-check.js` — post-write `openclaw doctor` wrapper
- `src/restore-backup.js` — backup + restore helpers
- `test/onboard.test.js` — non-interactive edge cases
- `test/audit.test.js` — audit output format tests
The script advertises pre-write validation, but later runs openclaw doctor --fix, which is a mutating operation. In a validation context, invoking an auto-fix command can unexpectedly alter files or state, violating the safety boundary between 'check' and 'write' and creating integrity risks, especially in automation or CI where users may trust this script to be side-effect free.
The file promises read-only behavior, but generateAudit passes the caller-supplied config into normalizeOpenClawConfig without defensive cloning. If the normalizer mutates its input, this function can unexpectedly alter live configuration state while only intending to produce an audit summary, creating integrity and trust-boundary issues for callers that rely on non-mutating inspection.
The module header describes behavior limited to running openclaw doctor on a candidate config file after normalization/import. However, the same file also defines restartGateway() and isGatewayUp(), which perform operational gateway control and health probing rather than config validation.
The docstring for exportConfigToken states it returns an object with token and credentialRefs, but the implementation returns only a string token (mrconf:v1:...). This is an active contradiction between documented intent and actual behavior, not merely an omitted detail.
The inline documentation at L229 says custom plugin config blobs are 'pass through untouched', which implies no traversal or modification. However, L231-L232 explicitly recurse into plugin config objects via normalizeValue, allowing nested normalization behavior; this is an active contradiction rather than merely incomplete documentation.
This code file performs a file write that replaces the active config with backup contents, which is a potentially destructive operation. Although the module header describes backup/restore behavior, the restore path itself has no confirmation prompt or user-facing log indicating that the current config is about to be overwritten.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
// baseURL trimmed
result = normalizeOpenClawConfig({
agents: { defaults: {} },
models: { providers: { openai: { baseURL: " https://api.openai.com/v1 " } } },
plugins: { entries: {} },
});
assertEqual(result.normalized.models.providers.openai.baseURL, "https://api.openai.com/v1", "baseURL trimmed");
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
// baseURL trimmed
result = normalizeOpenClawConfig({
agents: { defaults: {} },
models: { providers: { openai: { baseURL: " https://api.openai.com/v1 " } } },
plugins: { entries: {} },
});
assertEqual(result.normalized.models.providers.openai.baseURL, "https://api.openai.com/v1", "baseURL trimmed");
The test at L307 asserts result.normalized.env is undefined, meaning the code expects the env subtree to be removed from normalized output. The following inline note at L308 explicitly says the env subtree should be passed through, which directly contradicts the asserted behavior and documents conflicting intent.
This section states alias handling is informational only, yet the sample input alias deepseek-r1-distill-qwen-32b does not match the listed known aliases for the canonical model, which are deepseek-r1-32b and deepseek-r1. That inconsistency can cause implementers to infer normalization or mapping behavior not supported by the stated alias table.