T09 · Insecure Skill Coding Practices
- Location
scripts/sync-trust-db.sh:62- Finding
Arbitrary JavaScript Execution Through Trust Database URL Interpolation
- Content
View full analysis
&2; exit 1 ;; esac done if [ -n "$CUSTOM_URL" ]; then CDN_URL="$CUSTOM_URL" elif [ -f "$CONFIG_PATH" ]; then CDN_URL=$(node --input-type=module -e " import { readFileSync } from 'node:fs'; try { const c = JSON.parse(readFileSync('${CONFIG_PATH}', 'utf-8')); console.log(c.trust_db_url || 'https://api.fraud-filter.com/trust.json'); } catch { console.log('https://api.fraud-filter.com/trust.json'); } ") else CDN_URL="https://api.fraud-filter.com/trust.json" fi ``` ```bash if node --input-type=module -e " import { writeFileSync } from 'node:fs'; const res = await fetch('${CDN_URL}', { headers: { 'User-Agent': 'fraud-filter-skill/1.0' }, signal: AbortSignal.timeout(15_000), }); if (!res.ok) throw new Error('HTTP ' + res.status); const data = await res.json(); if (!data.endpoints) throw new Error('missing endpoints field'); writeFileSync('${TEMP_PATH}', JSON.stringify(data)); console.log('Valid: ' + Object.keys(data.endpoints).length + ' endpoints'); " 2>&1; then ``` ### Technical Analysis `CDN_URL` is populated either from the command-line `--url` argument or from the configurable `trust_db_url` field. It is subsequently interpolated directly into a JavaScript program passed to `node -e`. Shell quoting does not make this safe because the interpolation occurs while constructing JavaScript source. A value containing a single quote can terminate the `fetch()` string literal and inject arbitrary JavaScript statements. Node.js exposes filesystem, process, and child-process APIs, so successful injection can perform actions ...[truncated 1538 chars]- Remediation
View remediation
