T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/mealie.js:74
- Finding
- Bearer API Token Can Be Transmitted over Unencrypted HTTP<![CDATA[ ## Vulnerability Details **File Location**: `scripts/mealie.js`, lines 74–96 **Vulnerability Type**: Plaintext transmission of authentication credentials **Risk Level**: Medium ### Vulnerable Code ```js // Parse URL const urlObj = new URL(MEALIE_URL); const isHttps = urlObj.protocol === 'https:'; const httpModule = isHttps ? require('https') : require('http'); // API request helper async function api(method, endpoint, body = null) { return new Promise((resolve, reject) => { const path = endpoint.startsWith('/api') ? endpoint : `/api${endpoint}`; const options = { hostname: urlObj.hostname, port: urlObj.port || (isHttps ? 443 : 80), path: path, method: method, headers: { 'Authorization': `Bearer ${API_TOKEN}`, 'Content-Type': 'application/json' } }; ``` ### Technical Analysis The client selects the plaintext Node.js HTTP module whenever `MEALIE_URL` does not use the `https:` protocol. It nevertheless includes `MEALIE_API_TOKEN` as a bearer credential in every API request. Bearer tokens provide access based solely on possession. When sent over HTTP, neither the authorization header nor the request and response bodies receive transport encryption or server authentication. An attacker able to observe or manipulate traffic between the client and the Mealie server can therefore capture the token, inspect private Mealie data, modify traffic, or impersonate the server. The access to `~/.openclaw/.env` and the skill-level `.env` is consistent with the declared authentication functionality and parsing is limited to `MEALIE_URL` and `MEALIE_API_TOKEN`. The security issue is not the documented credential-file access itself, but the possibility of transmitting the loaded secret over an insecure transport. ### Attack Path 1. The user or deployment configures `MEALIE_URL` with an `http://` endpoint. 2. The Skill reads `MEALIE_API_TOKEN` from the process environment, the skill-level `.env`, or ...[truncated 1401 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Enforce HTTPS before creating any request: ```js const urlObj = new URL(MEALIE_URL); if (urlObj.protocol !== 'https:') { throw new Error('MEALIE_URL must use HTTPS'); } const httpModule = require('https'); ``` 2. If plaintext HTTP is required for local development, make it an explicit opt-in rather than the default fallback. Restrict that exception to verified loopback addresses such as `127.0.0.1`, `::1`, or `localhost`, and display a prominent warning. 3. Reject unsupported URL schemes instead of treating every non-HTTPS scheme as HTTP. 4. Configure the Mealie deployment with a valid TLS certificate and verify certificates using Node.js defaults. Do not disable TLS certificate validation. 5. Use a dedicated, least-privilege Mealie API token for this Skill. Limit its permissions to the operations actually required by the user. 6. Revoke and replace any token that may previously have been transmitted over HTTP. 7. Store the skill-level `.env` with restrictive filesystem permissions and prefer it over a shared agent-level environment file where practical. ]]>
