T09 · Insecure Skill Coding Practices
- Location
hooks/guard.js:87- Finding
Non-Atomic Session Counter Allows Concurrent Spawn-Limit Bypass
- Content
View full analysis
0 && state.count + 1 > max) { deny(`frugal-subagents: this session has already spawned ${max} subagents (FRUGAL_SUBAGENTS_MAX_SPAWNS). ` + 'Continue with the results you have, or send a follow-up to an agent that is still running ' + 'instead of starting a new one; if more spawns are genuinely needed, ask the user to raise the limit.'); } // Allowed: count it, then either pass through untouched or inject the default. if (state) { state.count += 1; } if (!defaulted) { saveState(state); process.exit(0); } const result = { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', updatedInput: { ...input, model }, additionalContext: `frugal-subagents: this subagent runs on "${model}" because no model was named. ` + 'Name the model explicitly when a different tier is justified.', }, }; if (state && !state.notified) { state.notified = true; result.systemMessage = `frugal-subagents: subagents spawned without an explicit model run on "${model}" ` + '(FRUGAL_SUBAGENTS_DEFAULT_MODEL). Nested spawns are blocked; ' + `budget ${Number.isFinite(max) && max > 0 ? max : 'unlimited'} spawns per session.`; } saveState(state); out(result); ``` ### Technical Analysis The per-session spawn limit is implemented as a filesystem-backed counter. Each hook process independently: 1. Reads the current counter. 2. Checks whether the next spawn would exceed the limit. 3. Increments its in-m ...[truncated 1831 chars]- Remediation
View remediation
