Executive brief
PraisonAI is a TypeScript library that provides an AgentLoop component for building AI agents that can execute tools. The onToolCall callback is documented as an approval mechanism to allow or deny tool execution, but the implementation executes tools before checking approval. This means an administrator or end user who denies a tool call receives a false "tool_rejected" signal while the tool has already run and taken effect, defeating the approval control entirely.
Technical details
The vulnerability is a logic-order flaw in AgentLoop.step() within src/praisonai-ts/src/ai/agent-loop.ts. The code passes executable tools directly to the AI SDK's generateText() function, which automatically executes any tool with an execute handler. Only after the tools have been executed and results collected does PraisonAI invoke the onToolCall approval callback. This inverts the intended approval model: AI SDK's native needsApproval pattern enforces approval before execution, but PraisonAI implements approval as a post-execution audit hook while naming it as a pre-execution approval gate. An attacker or malicious agent can invoke sensitive operations (file writes, API calls, etc.) through tools; the approval callback's rejection comes too late to prevent side effects. The vulnerability affects versions 1.4.0 through 1.7.1 and is fixed in 1.7.2 by moving approval checks before tool execution.
Affected products
- PraisonAI praisonai >=1.4.0, <=1.7.1
Timeline
- 2026-06-18: disclosed
- 2026-06-18: patched: Version 1.7.2 available with fix