T09 · Insecure Skill Coding Practices
- Location
scripts/monitor.js:7- Finding
Unchecked command-line arguments allow monitor denial of service and status-output spoofing
- Content
View full analysis
[quota_remaining_percent]"); process.exit(1); } const current = parseInt(args[0], 10); const max = parseInt(args[1], 10); const model = args[2]; const quota = args[3] || "N/A"; const ratio = (current / max); const percent = Math.round(ratio * 100); // Generate progress bar const barLength = 10; const filledLength = Math.round(ratio * barLength); const bar = "▓".repeat(Math.min(filledLength, barLength)) + "░".repeat(Math.max(0, barLength - filledLength)); ``` ```javascript if (ratio >= 0.95) { riskLevel = "緊急 (Critical)"; color = "🔴"; } else if (ratio >= 0.85) { riskLevel = "警告 (Warning)"; color = "🟡"; } console.log(` --- ### 🛡️ Token Guard 狀態回報 **【風險等級:${riskLevel} ${color}】** - **目前模型:** ${model} - **上下文負載:** \`[${bar}] ${percent}%\` - **剩餘配額:** ${quota}% **⚠️ 診測建議:** ${ratio >= 0.85 ? "建議立即執行 /compact 或換模型以免中斷。" : "目前尚在安全範圍,請繼續任務。"} --- `); ``` ### Technical Analysis The script checks only the number of arguments. It does not verify that `current` and `max` are finite numbers, that `current` is non-negative, or that `max` is greater than zero. A negative `current` value can produce a negative `filledLength`. That value is passed to `String.prototype.repeat()` when constructing the unfilled portion of the progress bar, resulting in a `RangeError` and termination of the monitoring process. Zero, nonnumeric, infinite, or otherwise malformed values can also produce invalid ratios and misleading status calculations. The `model` and `quota` arguments are inserted directly into a formatted terminal and Markdown report. If these values originate from an attacker-controlled or unreliable integratio ...[truncated 1416 chars]- Remediation
View remediation
~-])/g, "\\$1"); } ``` ]]>
