T09 · Insecure Skill Coding Practices
- Location
scripts/setup.js:176- Finding
Shell Command Injection Through X Authentication Cookies
- Content
View full analysis
&1`; const result = execSync(cmd, { encoding: 'utf8', timeout: 15000 }); ``` ```js // monitor.js function fetchBookmarks() { console.log(`[${new Date().toISOString()}] Fetching bookmarks...`); try { // Use environment variables for credentials (safer than command line args) const cmd = `AUTH_TOKEN="${credentials.auth_token}" CT0="${credentials.ct0}" bird bookmarks -n ${config.bookmarkCount} --json`; const output = execSync(cmd, { encoding: 'utf8', maxBuffer: 10 * 1024 * 1024 }); ``` ### Technical Analysis Both authentication cookie values are placed inside command strings passed to `execSync()`. By default, `execSync()` invokes a system shell. Double quotation marks do not make this construction safe because a malicious value can contain a closing quotation mark followed by shell metacharacters or command substitutions. The setup wizard accepts these values directly from terminal input. The monitor later reads them from `.env` or inherited environment variables. Therefore, compromise of either input channel can produce shell execution. The comment that environment variables are safer than command-line arguments is misleading in this implementation: the variables are assigned through shell syntax rather than through the child-process `env` option. ### Attack Path 1. An attacker persuades a user to paste a crafted cookie value, or modifies the local `.env` file. 2. The value contains syntax that terminates the quoted s ...[truncated 801 chars]- Remediation
View remediation
