T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:47
- Finding
- Mattermost bearer token exposed through command-line arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 47–68 **Vulnerability Type**: Insecure credential handling and unnecessary direct access to privileged configuration **Risk Level**: Medium ### Vulnerable Code ```bash SHIRKA_TOKEN=$(python3 -c "import json; print(json.load(open('/root/.openclaw/openclaw.json'))['env']['vars']['JENTIC_MM_SHIRKA_TOKEN'])") # 1. Upload the file FILE_ID=$(curl -s -X POST "https://mattermost.claw.jentic.ai/api/v4/files" \ -H "Authorization: Bearer $SHIRKA_TOKEN" \ -F "channel_id=CHANNEL_ID" \ -F "files=@/tmp/whatsapp_qr.png;filename=whatsapp_qr.png" \ | python3 -c "import json,sys; r=json.load(sys.stdin); print(r['file_infos'][0]['id'])") # 2. Post into the thread curl -s -X POST "https://mattermost.claw.jentic.ai/api/v4/posts" \ -H "Authorization: Bearer $SHIRKA_TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"channel_id\": \"CHANNEL_ID\", \"root_id\": \"TOPIC_ID\", \"message\": \"Scan this now — you have ~60 seconds. WhatsApp → Settings → Linked Devices → Link a Device 👇\", \"file_ids\": [\"$FILE_ID\"] }" ``` ### Technical Analysis The instructions require the Agent to read `JENTIC_MM_SHIRKA_TOKEN` directly from the privileged OpenClaw configuration file at `/root/.openclaw/openclaw.json`. The token is stored in a shell variable and expanded into the `curl` `Authorization` header argument. Because the expanded header is passed as a command-line argument, the bearer token may temporarily be visible through process inspection facilities, debugging tools, shell tracing, execution telemetry, or command logging. Any process or monitoring component with sufficient access to inspect the `curl` command line could recover the credential. The reviewed instructions transmit the token only to the declared Mattermost domain, so there is no evidence of intentional credential exfiltration. Nevertheless, extracting a long-lived credential into the Agent's shell context is broader ...[truncated 1465 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Prefer a credential-brokered Mattermost messaging tool that supports file uploads to threads and does not expose the underlying token to the Agent. 2. If direct API access is unavoidable, provide a dedicated helper that: - Reads the token internally. - Restricts requests to an allowlisted HTTPS origin. - Never places the token in process arguments, standard output, standard error, or logs. - Accepts only validated channel, thread, message, and local file parameters. 3. Assign the token only the minimum Mattermost permissions required to upload the QR image and create a post in authorized channels. 4. Use a short-lived or workload-bound credential rather than a reusable long-lived bearer token. 5. Ensure shell tracing and verbose HTTP diagnostics are disabled around credential-bearing operations. 6. Rotate the existing token if command histories, process telemetry, or execution logs may already contain it. 7. Restrict permissions on `/root/.openclaw/openclaw.json` and avoid instructing general-purpose Agent workflows to parse privileged configuration directly. ]]>
