CVE-2026-57137: Praisonai Npm PraisonAI AgentLoop OnToolCall Approval Vulnerability

HIGH
Advisory Identifier: GHSA-h2w2-v7j6-xqm4
CVSS 8.8
CWE-693 CWE-862 CWE-863
Published
Advisory Summary

CVE-2026-57137 is a HIGH (CVSS 8.8) npm praisonai agentloop ontoolcall approval vulnerability (CWE-693: Protection Mechanism Failure) affecting Praisonai libraries in the npm ecosystem. The issue involves npm praisonai agentloop ontoolcall approval runs after tool execution. Remediation is available by upgrading affected packages to version 1.7.2.

CVE-2026-57137 at a Glance

CVE Identifier CVE-2026-57137
GHSA Identifier GHSA-h2w2-v7j6-xqm4
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-693: Protection Mechanism Failure
Affected Product Praisonai
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-57137

To remediate this vulnerability, upgrade all affected Praisonai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

praisonai fixed: 1.7.2
npm install praisonai@1.7.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls praisonai

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-57137, inspect your project dependencies using npm:

npm ls praisonai

Analyze the terminal output to locate any version of Praisonai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.7.2), your application is affected.

Note: The npm ls praisonai command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-693: Protection Mechanism Failure, where the product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. In Praisonai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The published npm package `praisonai` exports `createAgentLoop()`, whose `onToolCall` callback is documented and exampled as an approval hook. The implementation calls PraisonAI's `generateText()` wrapper with the caller's executable tools first, receives `toolResults`, and only then calls `onToolCall()`. Because AI SDK `generateText()` executes tools with an `execute` function as part of the generation call, `onToolCall` can deny a tool only after the sensitive side effect has already happened. PraisonAI then returns `finishReason: "tool_rejected"`, which is a false security signal: the rejected tool already ran. The PoV is deterministic and local-only. It uses mock AI SDK modules, no live model call, no API key, and no network target. The tool increments an in-memory counter rather than touching the filesystem or executing commands. ## Technical Details In `src/praisonai-ts/src/ai/agent-loop.ts`, the public config says: ```ts /** On tool call callback (for approval) */ onToolCall?: (toolCall: ToolCallInfo) => Promise<boolean>; ``` The inline approval example also asks a user for approval and returns the decision: ```ts onToolCall: async (toolCall) => { const approved = await askUserForApproval(toolCall); return approved; } ``` However, `AgentLoop.step()` calls `generateText()` with the executable tools before invoking `onToolCall`: ```ts const result = await generateText({ model: this.config.model, messages: this.messages as any, tools: this.config.tools, maxSteps: 1, }); ``` It then materializes `toolResults`: ```ts toolResults: result.toolResults.map(tr => ({ toolCallId: tr.toolCallId, toolName: tr.toolName, result: tr.result, })), ``` Only afterward does the approval callback run: ```ts if (this.config.onToolCall) { for (const toolCall of step.toolCalls) { const approved = await this.config.onToolCall(toolCall); if (!approved) { this.complete = true; step.finishReason = 'tool_rejected'; break; } } } ``` `src/praisonai-ts/src/ai/generate-text.ts` forwards the caller's tools directly to AI SDK: ```ts const result = await sdk.generateText({ model, ... tools: options.tools, maxSteps: options.maxSteps, ... }); ``` AI SDK documents that `generateText()` "generates text and calls tools", and that tools with an `execute` function run automatically unless approval is handled before execution with `needsApproval`. The published `npm:praisonai@1.7.1` dist files preserve the same order: - `dist/ai/agent-loop.js` lines 150-157 call `generateText()` with executable tools. - lines 162-171 materialize `toolResults`. - lines 183-195 call `onToolCall()` and set `tool_rejected` afterward. ### Why This Is Not Intended Behavior This is not a trust-model-only issue. PraisonAI explicitly labels `onToolCall` as an approval callback and shows an approval example. A user who returns `false` from that callback expects the tool not to run. It also conflicts with the AI SDK execution model PraisonAI wraps: - AI SDK `generateText()` executes tools that include an `execute` function. - AI SDK approval is a pre-execution boundary (`needsApproval`), not a post-execution notification. - AI SDK loop control documentation treats "a tool call needs approval" as a condition that stops or pauses the loop before executing the tool. PraisonAI's current behavior instead creates a post-execution audit hook while naming and documenting it as approval. ## PoV Run from a local reproduction checkout: ```bash node poc/pov_poc.js 1.7.1 ``` Expected output includes: ```json { "praisonaiVersion": "1.7.1", "createAgentLoopExported": true, "eventOrder": ["tool-executed", "approval-denied"], "sideEffects": 1, "finishReason": "tool_rejected", "toolCallCount": 1, "toolResultCount": 1, "rejectedAfterExecution": true, "vulnerable": true, "patchedControl": { "order": ["approval-denied"], "sideEffects": 0, "toolCallCount": 1, "toolResultCount": 0, "blocksBeforeExecution": true } } ``` The PoV installs `npm:praisonai@1.7.1` into a temporary project and supplies mock `ai` and `@ai-sdk/openai` modules. The mocked `generateText()` returns one tool-call intent and executes a supplied `execute` handler if present. This keeps the proof deterministic and isolates PraisonAI's ordering bug. The vulnerable run uses `createAgentLoop()` with: - a `dangerousWrite` tool whose `execute()` handler increments an in-memory side-effect counter and records `tool-executed`; - an `onToolCall` approval callback that always returns `false` and records `approval-denied`. The observed order is: ```text tool-executed > approval-denied ``` That proves denial happens after execution. The `toolResults` array contains the tool's result even though PraisonAI reports `finishReason: "tool_rejected"`. The patched-control comparison strips executable handlers before the model step, requests approval on the tool-call intent, and only executes if approval succeeds. With the same denial decision, the control output is: ```text approval-denied sideEffects = 0 toolResultCount = 0 ``` ## PoC The PoV section above contains the local reproduction command, input, and decisive output. ## Impact Any application using npm PraisonAI `createAgentLoop()` with `onToolCall` as a human-in-the-loop or policy approval boundary can execute denied tools. If the application exposes the agent loop to lower-trust prompts or users and registers powerful tools, an attacker can cause the model to call a tool that the approval callback denies. The denial occurs too late. Depending on the registered tool, impact can include file modification, command execution, external API calls, data mutation, credential use, or other side effects with the privileges of the PraisonAI process. The report does not claim that npm PraisonAI exposes this as a default network service. It is a library-level approval-boundary bypass in the exported TypeScript agent-loop API. ### Severity Suggested severity: High. Rationale: - `AV`: common deployment pattern is an application exposing agent prompts over a network. - `AC`: attacker only needs to induce a tool call. - `PR`: conservative base score assumes the attacker can submit prompts to the application. - `UI`: no additional operator action is needed for the tool to execute before denial; even a denial callback is too late. - `S`: impact is in the PraisonAI-hosting application process. - `C/I/A`: depends on registered tools; shell/file/API tools can affect confidentiality, integrity, and availability. If maintainers score only local scripts that process untrusted repositories or prompts, `AV:L` may be reasonable. If they score public unauthenticated prompt endpoints built on this API, `PR:N` may be reasonable. ## Suggested Fix Do not pass executable tool handlers into `generateText()` before approval. One safe shape: 1. Convert configured tools into intent-only tool definitions without `execute`. 2. Call `generateText()` to obtain the model's tool-call intent. 3. Invoke `onToolCall(toolCall)` before any side effect. 4. Execute the selected tool only if approval returns true. 5. Append approved tool results to the conversation and continue the loop. Alternatively, if PraisonAI wants to delegate approval to AI SDK v6, translate `onToolCall` into per-tool `needsApproval` semantics so AI SDK pauses before calling `execute`. Regression tests should include: - `onToolCall` returns false and the tool `execute()` counter remains zero; - `onToolCall` returns true and the tool executes exactly once; - `tool_rejected` is never reported together with a tool result produced by the denied tool; - streaming and non-streaming loop variants use the same approval ordering if added later. ## Affected Package/Versions - Repository: `MervinPraison/PraisonAI` - Package: `npm:praisonai` - Component: TypeScript `AgentLoop` - Current head validated: `1ad58ca02975ff1398efeda694ea2ab78f20cf3e` - Current tag validated: `v4.6.58` - Latest npm package validated: `1.7.1` Suggested affected range: ```text npm:praisonai >= 1.4.0, <= 1.7.1 ``` Selected version sweep: - `1.0.0`: package main cannot be required in the selected test environment. - `1.2.0`: `createAgentLoop` is not exported. - `1.3.6`: `createAgentLoop` is not exported. - `1.4.0`: vulnerable. - `1.5.0`: vulnerable. - `1.5.4`: vulnerable. - `1.6.0`: vulnerable. - `1.7.0`: vulnerable. - `1.7.1`: vulnerable. ## Advisory History This is distinct from known and previously submitted PraisonAI issues: - `GHSA-ffp3-3562-8cv3` covers Python `praisonaiagents` approval cache keyed by tool name rather than invocation arguments. - `GHSA-qwgj-rrpj-75xm` covers Python Chainlit UI overriding configured approval mode with `auto`. - `GHSA-63v4-w882-g4x2` / poc covers Python `HTTPApproval` approval-page XSS. - poc covers npm TypeScript `AgentOS` missing authentication. - poc covers npm TypeScript `codeMode` sandbox escape. - poc covers npm TypeScript `MCPServer` missing authentication. No visible local or GitHub advisory covers npm TypeScript `AgentLoop.onToolCall` executing after tool results already exist.

CVE-2026-57137 Affected Praisonai Versions

1 component(s)
Fixed Versions:
1.7.2
Product / Package Ecosystem Affected Versions Fixed Version
praisonai
npm
≥ 1.4.0
< 1.7.2
1.7.2

References

Frequently Asked Questions

What is CVE-2026-57137?
CVE-2026-57137 is a security vulnerability in Praisonai involving npm PraisonAI AgentLoop onToolCall approval runs after tool execution under CWE-693: Protection Mechanism Failure.
Which Praisonai versions are affected?
Affected versions include releases prior to 1.7.2 across affected packages: praisonai.
What version fixes CVE-2026-57137?
Upgrading to 1.7.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is praisonai affected?
Yes, praisonai is affected in releases prior to 1.7.2. Upgrade your dependency to 1.7.2 or later.
What is the CVSS score of CVE-2026-57137?
CVE-2026-57137 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-57137?
CVE-2026-57137 is classified under CWE-693: Protection Mechanism Failure (The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.).
How can I check npm dependencies for CVE-2026-57137?
Run the dependency tree command: 'npm ls praisonai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-h2w2-v7j6-xqm4",
  "modified" : "2026-07-20T21:27:15Z",
  "published" : "2026-06-18T14:26:51Z",
  "aliases" : [ "CVE-2026-57137" ],
  "summary" : "npm PraisonAI AgentLoop onToolCall approval runs after tool execution",
  "details" : "## Summary\n\nThe published npm package `praisonai` exports `createAgentLoop()`, whose `onToolCall` callback is documented and exampled as an approval hook. The implementation calls PraisonAI's `generateText()` wrapper with the caller's executable tools first, receives `toolResults`, and only then calls `onToolCall()`.\n\nBecause AI SDK `generateText()` executes tools with an `execute` function as part of the generation call, `onToolCall` can deny a tool only after the sensitive side effect has already happened. PraisonAI then returns `finishReason: \"tool_rejected\"`, which is a false security signal: the rejected tool already ran.\n\nThe PoV is deterministic and local-only. It uses mock AI SDK modules, no live model call, no API key, and no network target. The tool increments an in-memory counter rather than touching the filesystem or executing commands.\n\n## Technical Details\n\nIn `src/praisonai-ts/src/ai/agent-loop.ts`, the public config says:\n\n```ts\n/** On tool call callback (for approval) */\nonToolCall?: (toolCall: ToolCallInfo) => Promise<boolean>;\n```\n\nThe inline approval example also asks a user for approval and returns the decision:\n\n```ts\nonToolCall: async (toolCall) => {\n  const approved = await askUserForApproval(toolCall);\n  return approved;\n}\n```\n\nHowever, `AgentLoop.step()` calls `generateText()` with the executable tools before invoking `onToolCall`:\n\n```ts\nconst result = await generateText({\n  model: this.config.model,\n  messages: this.messages as any,\n  tools: this.config.tools,\n  maxSteps: 1,\n});\n```\n\nIt then materializes `toolResults`:\n\n```ts\ntoolResults: result.toolResults.map(tr => ({\n  toolCallId: tr.toolCallId,\n  toolName: tr.toolName,\n  result: tr.result,\n})),\n```\n\nOnly afterward does the approval callback run:\n\n```ts\nif (this.config.onToolCall) {\n  for (const toolCall of step.toolCalls) {\n    const approved = await this.config.onToolCall(toolCall);\n    if (!approved) {\n      this.complete = true;\n      step.finishReason = 'tool_rejected';\n      break;\n    }\n  }\n}\n```\n\n`src/praisonai-ts/src/ai/generate-text.ts` forwards the caller's tools directly to AI SDK:\n\n```ts\nconst result = await sdk.generateText({\n  model,\n  ...\n  tools: options.tools,\n  maxSteps: options.maxSteps,\n  ...\n});\n```\n\nAI SDK documents that `generateText()` \"generates text and calls tools\", and that tools with an `execute` function run automatically unless approval is handled before execution with `needsApproval`.\n\nThe published `npm:praisonai@1.7.1` dist files preserve the same order:\n\n- `dist/ai/agent-loop.js` lines 150-157 call `generateText()` with executable tools.\n- lines 162-171 materialize `toolResults`.\n- lines 183-195 call `onToolCall()` and set `tool_rejected` afterward.\n\n### Why This Is Not Intended Behavior\n\nThis is not a trust-model-only issue. PraisonAI explicitly labels `onToolCall` as an approval callback and shows an approval example. A user who returns `false` from that callback expects the tool not to run.\n\nIt also conflicts with the AI SDK execution model PraisonAI wraps:\n\n- AI SDK `generateText()` executes tools that include an `execute` function.\n- AI SDK approval is a pre-execution boundary (`needsApproval`), not a post-execution notification.\n- AI SDK loop control documentation treats \"a tool call needs approval\" as a condition that stops or pauses the loop before executing the tool.\n\nPraisonAI's current behavior instead creates a post-execution audit hook while naming and documenting it as approval.\n\n## PoV\n\nRun from a local reproduction checkout:\n\n```bash\nnode poc/pov_poc.js 1.7.1\n```\n\nExpected output includes:\n\n```json\n{\n  \"praisonaiVersion\": \"1.7.1\",\n  \"createAgentLoopExported\": true,\n  \"eventOrder\": [\"tool-executed\", \"approval-denied\"],\n  \"sideEffects\": 1,\n  \"finishReason\": \"tool_rejected\",\n  \"toolCallCount\": 1,\n  \"toolResultCount\": 1,\n  \"rejectedAfterExecution\": true,\n  \"vulnerable\": true,\n  \"patchedControl\": {\n    \"order\": [\"approval-denied\"],\n    \"sideEffects\": 0,\n    \"toolCallCount\": 1,\n    \"toolResultCount\": 0,\n    \"blocksBeforeExecution\": true\n  }\n}\n```\n\nThe PoV installs `npm:praisonai@1.7.1` into a temporary project and supplies mock `ai` and `@ai-sdk/openai` modules. The mocked `generateText()` returns one tool-call intent and executes a supplied `execute` handler if present. This keeps the proof deterministic and isolates PraisonAI's ordering bug.\n\nThe vulnerable run uses `createAgentLoop()` with:\n\n- a `dangerousWrite` tool whose `execute()` handler increments an in-memory side-effect counter and records `tool-executed`;\n- an `onToolCall` approval callback that always returns `false` and records `approval-denied`.\n\nThe observed order is:\n\n```text\ntool-executed > approval-denied\n```\n\nThat proves denial happens after execution. The `toolResults` array contains the tool's result even though PraisonAI reports `finishReason: \"tool_rejected\"`.\n\nThe patched-control comparison strips executable handlers before the model step, requests approval on the tool-call intent, and only executes if approval succeeds. With the same denial decision, the control output is:\n\n```text\napproval-denied\nsideEffects = 0\ntoolResultCount = 0\n```\n\n## PoC\n\nThe PoV section above contains the local reproduction command, input, and decisive output.\n\n## Impact\n\nAny application using npm PraisonAI `createAgentLoop()` with `onToolCall` as a human-in-the-loop or policy approval boundary can execute denied tools.\n\nIf the application exposes the agent loop to lower-trust prompts or users and registers powerful tools, an attacker can cause the model to call a tool that the approval callback denies. The denial occurs too late. Depending on the registered tool, impact can include file modification, command execution, external API calls, data mutation, credential use, or other side effects with the privileges of the PraisonAI process.\n\nThe report does not claim that npm PraisonAI exposes this as a default network service. It is a library-level approval-boundary bypass in the exported TypeScript agent-loop API.\n\n### Severity\n\nSuggested severity: High.\n\nRationale:\n\n- `AV`: common deployment pattern is an application exposing agent prompts over a network.\n- `AC`: attacker only needs to induce a tool call.\n- `PR`: conservative base score assumes the attacker can submit prompts to the application.\n- `UI`: no additional operator action is needed for the tool to execute before denial; even a denial callback is too late.\n- `S`: impact is in the PraisonAI-hosting application process.\n- `C/I/A`: depends on registered tools; shell/file/API tools can affect confidentiality, integrity, and availability.\n\nIf maintainers score only local scripts that process untrusted repositories or prompts, `AV:L` may be reasonable. If they score public unauthenticated prompt endpoints built on this API, `PR:N` may be reasonable.\n\n## Suggested Fix\n\nDo not pass executable tool handlers into `generateText()` before approval.\n\nOne safe shape:\n\n1. Convert configured tools into intent-only tool definitions without `execute`.\n2. Call `generateText()` to obtain the model's tool-call intent.\n3. Invoke `onToolCall(toolCall)` before any side effect.\n4. Execute the selected tool only if approval returns true.\n5. Append approved tool results to the conversation and continue the loop.\n\nAlternatively, if PraisonAI wants to delegate approval to AI SDK v6, translate `onToolCall` into per-tool `needsApproval` semantics so AI SDK pauses before calling `execute`.\n\nRegression tests should include:\n\n- `onToolCall` returns false and the tool `execute()` counter remains zero;\n- `onToolCall` returns true and the tool executes exactly once;\n- `tool_rejected` is never reported together with a tool result produced by the denied tool;\n- streaming and non-streaming loop variants use the same approval ordering if added later.\n\n## Affected Package/Versions\n\n- Repository: `MervinPraison/PraisonAI`\n- Package: `npm:praisonai`\n- Component: TypeScript `AgentLoop`\n- Current head validated: `1ad58ca02975ff1398efeda694ea2ab78f20cf3e`\n- Current tag validated: `v4.6.58`\n- Latest npm package validated: `1.7.1`\n\nSuggested affected range:\n\n```text\nnpm:praisonai >= 1.4.0, <= 1.7.1\n```\n\nSelected version sweep:\n\n- `1.0.0`: package main cannot be required in the selected test environment.\n- `1.2.0`: `createAgentLoop` is not exported.\n- `1.3.6`: `createAgentLoop` is not exported.\n- `1.4.0`: vulnerable.\n- `1.5.0`: vulnerable.\n- `1.5.4`: vulnerable.\n- `1.6.0`: vulnerable.\n- `1.7.0`: vulnerable.\n- `1.7.1`: vulnerable.\n\n## Advisory History\n\nThis is distinct from known and previously submitted PraisonAI issues:\n\n- `GHSA-ffp3-3562-8cv3` covers Python `praisonaiagents` approval cache keyed by tool name rather than invocation arguments.\n- `GHSA-qwgj-rrpj-75xm` covers Python Chainlit UI overriding configured approval mode with `auto`.\n- `GHSA-63v4-w882-g4x2` / poc covers Python `HTTPApproval` approval-page XSS.\n- poc covers npm TypeScript `AgentOS` missing authentication.\n- poc covers npm TypeScript `codeMode` sandbox escape.\n- poc covers npm TypeScript `MCPServer` missing authentication.\n\nNo visible local or GitHub advisory covers npm TypeScript `AgentLoop.onToolCall` executing after tool results already exist.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "praisonai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.4.0"
      }, {
        "fixed" : "1.7.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.7.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-h2w2-v7j6-xqm4"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MervinPraison/PraisonAI"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-693", "CWE-862", "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-18T14:26:51Z",
    "nvd_published_at" : null
  }
}