Summary
A flaw in PraisonAI's agent loop allows executable tools to run before the configured approval callback can accept or reject them. Applications that rely on this callback as a human or policy authorization boundary may therefore execute denied file, command, API, or data-modifying operations.
Affected context
The issue occurs in PraisonAI multi-agent applications that use createAgentLoop() with executable tools and an onToolCall approval callback. It becomes risky when the callback is treated as the control that must authorize tool execution, but the underlying generation flow invokes tool handlers before consulting that decision. The affected code path was present in releases from 1.4.0 through 1.7.2.
Exploit preconditions
- Attack surface: Agent-generated tool calls handled by the PraisonAI TypeScript agent loop
- Required access: The ability to influence an agent's task, prompt, or tool-call decision within an application
- Trigger point: Tool execution during text generation before the
onToolCallapproval result is enforced - Why exploitation is possible: Executable tools are passed to the generation process before authorization is applied, allowing a denied tool to produce side effects and populate tool results
Why this happens
The underlying bug is an authorization-ordering failure. The agent loop makes executable tools available to the generation engine before invoking the callback intended to approve or reject each tool call. As a result, the approval mechanism records a rejection after execution rather than preventing execution.
This maps primarily to CWE-862: Missing Authorization, with related characteristics of CWE-863: Incorrect Authorization and CWE-693: Protection Mechanism Failure. The insecure pattern is treating a post-execution callback as an effective authorization boundary.
Potential impact
- Unauthorized file operations may occur
- Shell or command execution may be triggered
- External APIs could be called without approval
- Application or business data may be modified or deleted
- Sensitive information could be exposed through tool results
- Agent workflows could be abused for broader actions permitted by the runtime identity
General mitigation guidance
Mitigation generally focuses on enforcing authorization before any executable tool handler can run.
Common defensive patterns include:
- Place approval and policy evaluation before tool dispatch or generation-time execution
- Expose only explicitly permitted tools to the generation engine for each request
- Use deny-by-default authorization for file, command, network, and data-modifying operations
- Separate tool selection from tool execution so policy checks cannot occur after side effects
- Apply least-privilege identities, restricted filesystem access, and narrowly scoped API credentials
- Treat callback outcomes as mandatory execution gates rather than audit events
- Add transaction, sandboxing, or dry-run controls for operations with irreversible effects
- Reduce trust in agent-generated arguments through schema validation and contextual policy checks
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis that identifies executable tools passed to generation APIs before approval checks
- Code review searches for authorization callbacks invoked after dispatch, handler execution, or result creation
- Tests asserting that rejected tool calls produce no side effects and no tool results
- Policy checks requiring deny-by-default tool registries and pre-dispatch authorization
- Runtime audit correlation between approval decisions and actual tool invocations
- Automated review tools that flag callback-based controls positioned after side-effecting operations

