T09 · Insecure Skill Coding Practices
- Location
realtime-bot.js:43- Finding
Shell Command Injection Through Position Market Data
- Content
View full analysis
p.status === 'open'); for (const pos of openPositions) { const currentPrice = await getPrice(pos.market); const entryPrice = pos.entryPrice || pos.avgPrice; const pnlPercent = (currentPrice - entryPrice) / entryPrice; const prompt = `당신은 암호화폐 트레이딩 봇입니다. 포지션: ${pos.market} 진입가: ${entryPrice}원 현재가: ${currentPrice}원 손익: ${(pnlPercent * 100).toFixed(2)}% 목표: +5%, 손절: -5% 다음 중 하나만 답하세요: 1. HOLD - 유지 2. SELL_NOW - 즉시 매도 (목표/손절 전이라도) 3. ADJUST:새목표,새손절 - 목표/손절 조정 응답 형식: HOLD, SELL_NOW, 또는 ADJUST:5,-3`; const response = askGLM(prompt); ``` ### Technical Analysis `execSync()` receives a dynamically constructed command string and consequently invokes a shell. The code attempts to protect the prompt by escaping double quotes, but this does not make content safe inside a shell double-quoted argument. Shell constructs including command substitution remain active within double quotes. For example, `$(command)` and backtick substitutions can still be evaluated. Because `pos.market` is loaded from the locally writable `positions.json` file and interpolated into the prompt without strict validation, a malicious market value can introduce shell syntax. This is an injection flaw rather than merely malformed argument handling: attacker-controlled te ...[truncated 1597 chars]- Remediation
View remediation
