T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/agent-runtime.mjs:134- Finding
Declared permission and hook controls are not enforced
- Content
View full analysis
Vulnerability Details
File Location:
scripts/agent-runtime.mjs:134-147, 193-199, 308-320
Vulnerability Type: Missing authorization and fail-open security hooks
Risk Level: HighVulnerable Code
javascript class SimpleHookRunner { constructor(config = {}) { this.preHooks = config.preToolUse || []; this.postHooks = config.postToolUse || []; } async runPreToolUse(toolName, input) { // Simplified implementation: always permit return { allowed: true, denied: false, messages: [] }; } async runPostToolUse(toolName, input, output, isError) { return { allowed: true, denied: false, messages: [] }; } }javascript this.hookRunner = new SimpleHookRunner();javascript for (const match of matches.slice(0, 3)) { const tool = match.tool; // Pre Hook const preResult = await this.hookRunner.runPreToolUse(tool.name, {}); if (preResult.denied) { output += `\n[${tool.name}] blocked by hook\n`; continue; } // Execute const result = await tool.execute({}, {});Technical Analysis
The runtime presents
permissionandagentTypesproperties as access-control metadata, butrunTurn()never validates either property before executing a tool. The configuredagentTypetherefore has no effect on authorization.The pre-execution hook also always returns an allow decision. Although the hook runner stores
preHooksandpostHooks, it never invokes them. The runtime constructs the hook runner without passing hook configuration, and the documentedaddHook()API is not implemented.This creates a fail-open authorization model: any tool selected by the search logic can proceed regardless of its declared permission level or the active agent type. A consuming application may incorrectly assume that an
exploreorplanagent cannot use tools marked as dangerous.Attack Path
- An application creates ...[truncated 971 chars]
- Remediation
View remediation
Remediation Suggestions
- Implement a centralized authorization check before every tool invocation.
- Validate
this.config.agentTypeagainsttool.agentTypes; reject execution unless the active type is explicitly allowed. - Map permission levels to explicit caller capabilities and require authorization for
write,danger, andadmintools. - Implement actual iteration over registered pre- and post-execution hooks.
- Treat malformed hook responses, hook exceptions, missing policies, and unknown permission levels as denials.
- Pass hook configuration into
SimpleHookRunnerand implement the documentedaddHook()interface. - Prevent callers from bypassing policy by directly invoking mutable registry entries. Expose a controlled execution method instead of raw tool configurations.
- Add tests proving that restricted agent types cannot invoke dangerous tools and that hook denials prevent execution.
