From 7c0f50a23ef3b2a461fba26192d44547ed9f3ecd Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 18 Oct 2026 11:45:41 +0000 Subject: [PATCH] fix(approvals): only the person approves what the assistant asks The assistant's approvals (send_mail, add_event, write_file, entity and topic changes and the rest) could be approved through POST /api/v1/approvals/{id} with an API token or an OAuth app token: approvals.can only refused the "agent" route for approvals that weren't an automation's. Now every assistant approval follows the automation rule: only the person signed in to Lens, or in the chat it was asked in, approves (or samples) it; an API key, an app, MCP and the assistant can only decline (403 otherwise), and each approval's `can` says so. A research plan keeps its admin opt-in, research.agents_skip_review. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QFUNzy1QZy5HhKAyJxTAYJ --- README.md | 2 +- changelog.d/agent-approve.md | 5 ++ docs/api.md | 5 +- docs/assistant.md | 3 +- docs/automations.md | 5 +- docs/requirements.md | 2 +- fastapi_backend/app/api/v1/routes/chats.py | 4 +- fastapi_backend/app/domain/ai_tools.py | 10 ++-- fastapi_backend/app/domain/approvals.py | 17 ++++--- fastapi_backend/tests/api/test_approvals.py | 51 +++++++++++++++++++ nextjs-frontend/app/openapi-client/sdk.gen.ts | 4 +- nextjs-frontend/openapi.json | 2 +- threat-model.json | 2 +- threat-model.md | 2 +- threat-model.yaml | 2 +- 15 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 changelog.d/agent-approve.md diff --git a/README.md b/README.md index ee136c488..e969ddc42 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ listed under [In progress](#in-progress), and what comes next under [Planned](#p of each conversation's own. An admin's assistant searches and reads the mail, calendars and files connected to Lens (Gmail, Google Calendar, Google Drive, S3 and the rest), cites messages and events, and brings them in once you approve; where an admin allows it, it sends mail, adds events and writes files, each only after you read all of it - and say yes. Regenerating an answer or editing a question makes a new version beside the old one, and + and say yes yourself (an API key, an app or an agent can only decline). Regenerating an answer or editing a question makes a new version beside the old one, and nothing is lost. Each answer keeps a record of what produced it (the model, its tools, how long it took and what it cost), opened from its header. It reads answers aloud with a speech provider, macOS `say` or StyleTTS2 on this machine (opt-in), any message in one click. Long conversations are summarised before they fill the model's context, and diff --git a/changelog.d/agent-approve.md b/changelog.d/agent-approve.md new file mode 100644 index 000000000..1a7e9bfe7 --- /dev/null +++ b/changelog.d/agent-approve.md @@ -0,0 +1,5 @@ +- **Only the person approves what the assistant asks.** Sending mail, adding an event, writing a file and the + assistant's other proposals are approved only by the person signed in to Lens, or in the chat they were asked in. + An API key or an app given access can now only decline them (`POST /api/v1/approvals/{id}` answers 403 to an + approve or a sample), as MCP and the assistant already could, and each approval's `can` says so + ([Approvals](docs/automations.md#approvals)). diff --git a/docs/api.md b/docs/api.md index 697f24986..3cc6947ce 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1590,8 +1590,9 @@ automations' actions ([Approvals](automations.md#approvals)); filter by `status` `automation` or `chat_id`, and page with `before` (the last id of the page before) and `limit`. `/approvals/count` gives `{waiting, automations}`. `POST /approvals/{aid} {decision, params?}` decides one: `approve`, `sample` (a batch run on 3 assets first), `decline`, `edit` (an automation's action with `params` changed) or `always` (approved, and -that node runs without asking from now on). Approving, editing and `always` on an automation's action need a signed-in -session (403 for an API key or an app); each approval's `can` says what you may do with it. +that node runs without asking from now on). Approving (and a sample), editing and `always` need a signed-in session, +for the assistant's proposals as for an automation's actions (403 for an API key or an app, which can only decline); +each approval's `can` says what you may do with it. `GET /chats/capabilities` tells anyone signed in whether a language model is set up (`configured`), which (`model`), whether it uses tools (`tools`, `max_steps`, `max_tool_calls`), whether answers can be checked (`check`) and the `models` people may pick diff --git a/docs/assistant.md b/docs/assistant.md index 336f45252..64d8afdff 100644 --- a/docs/assistant.md +++ b/docs/assistant.md @@ -281,7 +281,8 @@ When the configured model supports function calling, chat becomes an agent. and its other names, hiding one, or adding one to a namespace's fixed list) and changing topics (merging, renaming, describing or deleting one; [Topics](topics.md)) don't happen directly. They become approval cards (with the batch estimate) that the person approves, approves on a sample, or declines - (`POST /api/v1/approvals/`). Viewers only get the read tools. When an [automation](automations.md#the-model-and-the-agent) + (`POST /api/v1/approvals/`). Only the person approves one, signed in to Lens or in the chat: an API key, an app, + MCP and the assistant can only decline it. Viewers only get the read tools. When an [automation](automations.md#the-model-and-the-agent) uses the assistant, every change it would make is an approval of yours, notes included, with the run as its origin. - **Check sources** (`POST /api/v1/chats//messages//check`) re-checks every cited claim against the lines it cites, and lists sentences that cite nothing. diff --git a/docs/automations.md b/docs/automations.md index 2caf7cab5..9be192eff 100644 --- a/docs/automations.md +++ b/docs/automations.md @@ -783,7 +783,10 @@ own chat app (below). An API key, an app, MCP and the assistant can list and dec since approving is the person's pick; each approval's `can` says what the caller may do with it. This is the one place where an agent can't do what you can: agents read them with `approvals` and decline with `decline_approval` (over [MCP](mcp.md#tools) and in the [assistant](assistant.md#the-assistants-tools)), and there is no tool to approve. -The assistant's own approvals in a conversation are decided as before. +The assistant's own approvals (sending mail, adding an event, writing a file, changing entities and the rest) follow +the same rule: you approve them signed in to Lens or in the chat they were asked in, and an API key, an app, MCP and +the assistant can only decline them (403). A research plan is the one exception, and only when an admin turns on +`research.agents_skip_review` ([Deep research](assistant.md#deep-research)). **In your chat app.** A reply of "yes" in the private chat you were told in approves an automation's action, under the rules a chat room's approvals follow ([Chat rooms](chat-rooms.md#what-it-does)), and only when all of these hold: diff --git a/docs/requirements.md b/docs/requirements.md index 0f7fb8f72..59783c1a2 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -83,7 +83,7 @@ request, to another check that proves the same thing; loosening a requirement or | It acts with tools, and changes wait for approval | [test_chats.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_chats.py) `test_tools_approvals_and_checking`; [test_approvals.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_approvals.py) `test_the_assistant_lists_and_declines_but_never_approves` | | Web search and reading pages, cited like the archive, off until an admin turns it on | [test_web_search.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_web_search.py) `test_an_answer_cites_the_web_and_the_conversation_keeps_it`, `test_reading_pages_and_pdfs`; [chat-web-citations.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-web-citations.test.tsx) | | An admin's assistant searches and reads connected mail, calendars and files, cites messages and events, and brings them in only once approved | [test_connection_tools.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_connection_tools.py) `test_only_admins_get_them_and_only_for_what_is_connected`, `test_searching_and_reading_gmail`, `test_calendar_events_between_two_times`, `test_finding_and_reading_files_in_storage`, `test_bringing_things_in_waits_for_the_persons_yes`; [chat-web-citations.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-web-citations.test.tsx) `a message from a connected mailbox` | -| Where an admin allows it, the assistant sends mail, adds events and writes files, each only after the person reads all of it and says yes | [test_connection_tools.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_connection_tools.py) `test_sending_mail_waits_for_the_persons_yes`, `test_adding_an_event_waits_for_the_persons_yes`, `test_writing_a_file_waits_for_the_persons_yes`; [approvals-page.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/approvals-page.test.tsx) `shows the assistant's whole message before it is sent`; [add-connection.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/add-connection.test.tsx) `connects Gmail the same way, and asks a service account whose mail it reads` | +| Where an admin allows it, the assistant sends mail, adds events and writes files, each only after the person reads all of it and says yes, signed in or in the chat; an API key, an app or an agent only declines | [test_connection_tools.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_connection_tools.py) `test_sending_mail_waits_for_the_persons_yes`, `test_adding_an_event_waits_for_the_persons_yes`, `test_writing_a_file_waits_for_the_persons_yes`; [test_approvals.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_approvals.py) `test_only_the_person_approves_what_the_assistant_asks`; [approvals-page.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/approvals-page.test.tsx) `shows the assistant's whole message before it is sent`; [add-connection.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/add-connection.test.tsx) `connects Gmail the same way, and asks a service account whose mail it reads` | | Python and bash in a sandbox of each conversation's own, off until an admin turns it on | [test_sandbox.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_sandbox.py) `test_python_and_bash_share_one_sandbox_per_conversation`, `test_the_sandbox_is_off_until_an_admin_turns_it_on_for_the_people_it_names` | | Deep research: a goal gets a plan to approve, runs in the background and comes back as a cited report, saved as a note or a podcast episode | [test_research.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_research.py) `test_a_goal_gets_a_plan_that_waits_for_approval_and_can_be_revised`, `test_an_approved_plan_runs_and_its_report_comes_back_checked`, `test_a_report_becomes_a_note_and_a_podcast`; [chat-research.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-research.test.tsx) `approves the plan with Enter, sending the edits`, `saves it as a note, asking where when it could go in several namespaces`, `turns the next message into a research goal, and says when it can't`; [journeys.mjs](https://github.com/adeelahmad/lense/blob/main/ci/clicks/journeys.mjs) `chat-research`; [baseline.json](https://github.com/adeelahmad/lense/blob/main/ci/clicks/baseline.json) `chat-research` ≤ 4 clicks | | Regenerating an answer or editing a question makes a new version beside the old one | [test_chat_versions.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_chat_versions.py) `test_regenerate_edit_switch_and_go_on`; [chat-versions.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-versions.test.tsx) `regenerating an answer`, `the version switch`; [journeys.mjs](https://github.com/adeelahmad/lense/blob/main/ci/clicks/journeys.mjs) `chat-regenerate`; [baseline.json](https://github.com/adeelahmad/lense/blob/main/ci/clicks/baseline.json) `chat-regenerate` ≤ 4 clicks | diff --git a/fastapi_backend/app/api/v1/routes/chats.py b/fastapi_backend/app/api/v1/routes/chats.py index db523c7b4..f76dadbef 100644 --- a/fastapi_backend/app/api/v1/routes/chats.py +++ b/fastapi_backend/app/api/v1/routes/chats.py @@ -920,8 +920,8 @@ def get_approval(aid: int, user: CurrentUser, db: Db, cfg: Cfg) -> Approval: def decide_approval(aid: int, body: ApprovalDecision, user: Writer, acl: Acl, db: Db, cfg: Cfg, request: Request) -> ApprovalOutcome: """Approve (or run a sample of, or decline) something the assistant proposed or an automation's action. Each approval is decided once. An automation's action can also be edited (`params`) and then carried out, or allowed - from now on for that automation (`always`); approving one needs you signed in, since it's your pick: an API key - or an app can only decline it.""" + from now on for that automation (`always`). Approving is your pick, so it needs you signed in: an API key or an + app can only decline (403 otherwise).""" a = db.one("SELECT account FROM $r", r=R("approval", aid)) if not a or a["account"] != user.id: raise HTTPException(404, "not found") diff --git a/fastapi_backend/app/domain/ai_tools.py b/fastapi_backend/app/domain/ai_tools.py index 6f7007d60..d77e83ba0 100644 --- a/fastapi_backend/app/domain/ai_tools.py +++ b/fastapi_backend/app/domain/ai_tools.py @@ -2378,9 +2378,9 @@ def approve(db, cfg, aid, user, editable, decision="approve", base=None, admin=F """Carry out an approved action: a batch run (or a sample of it), an entity change, a note an automation's agent proposed, or a change to the server (ops_tools.py: settings, a namespace, importing attached files or web pages, following a news feed). - An automation's action (an approval with an intent) is decided by approvals.decide: `params` are an edit's, `via` - where the pick was made (web, chat, token, oauth or agent; only the person, signed in or in their own chat, - approves it).""" + An automation's action (an approval with an intent) is decided by approvals.decide: `params` are an edit's. `via` + is where the pick was made (web, chat, token, oauth or agent): only the person, signed in or in their own chat, + approves; an API key, an app, MCP and the assistant can only decline (PermissionError).""" from . import approvals # it carries actions out, and actions load the assistant's tools a = approvals.get(db, aid) @@ -2399,6 +2399,10 @@ def approve(db, cfg, aid, user, editable, decision="approve", base=None, admin=F "UPDATE $r SET status = 'declined', decided_at = $t, decided_by = $u", r=R("approval", a["id"]), t=store.now(), u=user["email"] ) return {"status": "declined"} + if not approvals.can(a, via)["approve"]: + raise PermissionError( + "approve what the assistant asks yourself, signed in to Lens or in the chat: an API key or an app can only decline it" + ) with graph_history.acting(actor=user["email"], via="assistant", approval=a["id"]): result = _carry_out(db, cfg, a, user, editable, decision, base, admin, readable, via) db.q( diff --git a/fastapi_backend/app/domain/approvals.py b/fastapi_backend/app/domain/approvals.py index 341d3aa71..36ebb1d65 100644 --- a/fastapi_backend/app/domain/approvals.py +++ b/fastapi_backend/app/domain/approvals.py @@ -8,9 +8,10 @@ first, which the engine hands to `ask`. Approving it performs the intent through `actions.perform`, as the automation and for its person, and records the outcome on the run (`automations.update_intent`). -An automation's approval is the person's pick: approving it (or editing its params, or allowing that node from now on) -needs them signed in to Lens, or a yes in the chat it was told in (bridge.decide_in_room). An API key, an app, MCP and -the assistant can list and decline approvals, never approve them. Undecided ones expire after +Every approval is the person's pick: approving one (or editing an automation's params, or allowing that node from now +on) needs them signed in to Lens, or a yes in their own chat (the assistant's chat, or the chat app it was told in: +bridge.decide_in_room). An API key, an app, MCP and the assistant can list and decline approvals, never approve them; +a research plan is the one exception, and only with research.agents_skip_review on. Undecided ones expire after `automations.approval_days` (default 7) and nothing runs; the assistant's own approvals never expire, as before. Statuses: pending (waiting), running (being carried out), done, failed, declined, expired. @@ -262,9 +263,9 @@ def edited(intent, new): def can(row, via="web", cfg=None): """What the person can do with a waiting approval from where they are (`via`: web for a signed-in session, chat for - their own chat app, token or oauth for an API key or an app, agent for MCP and the assistant, which only decline). - A research plan is approved by the person only (edited in the web app), unless research.agents_skip_review is on - in `cfg`.""" + their own chat app, token or oauth for an API key or an app, agent for MCP and the assistant). Only the person + approves, signed in or in their chat; the others only decline. A research plan is approved by the person only + (edited in the web app), unless research.agents_skip_review is on in `cfg`.""" pending = row.get("status") == "pending" intent = row.get("intent") if row.get("tool") == "research": @@ -275,9 +276,9 @@ def can(row, via="web", cfg=None): "edit": pending and via == "web", "always": False, } - if not intent: - return {"approve": pending and via != "agent", "decline": pending, "edit": False, "always": False} person = via in ("web", "chat") + if not intent: # the assistant's proposal: the person's pick, as an automation's is + return {"approve": pending and person, "decline": pending, "edit": False, "always": False} return { "approve": pending and person, "decline": pending, diff --git a/fastapi_backend/tests/api/test_approvals.py b/fastapi_backend/tests/api/test_approvals.py index 81478831b..51801f156 100644 --- a/fastapi_backend/tests/api/test_approvals.py +++ b/fastapi_backend/tests/api/test_approvals.py @@ -476,3 +476,54 @@ def test_the_assistant_lists_and_declines_but_never_approves(db, cfg, people, po assert json.loads(fresh.call("decline_approval", {"id": second})[0]) == {"approval": second, "status": "declined"} assert "not waiting" in fresh.call("decline_approval", {"id": second})[0] assert "decline_approval" in actions_ai.LEFT_OUT # an automation's agent doesn't get to decline its person's picks + + +def test_only_the_person_approves_what_the_assistant_asks(client, db, cfg, people, monkeypatch): + """Sending mail, adding an event, writing a file: an API key, an app and MCP only decline them; signed in, the + person approves.""" + from app.domain import connection_tools + from tests.api.test_mcp import tool, tool_error + from tests.api.test_oauth import _bearer, _grant + + done = [] + monkeypatch.setattr(connection_tools, "carry_out", lambda db, cfg, name, args, user, admin: done.append(name) or {"sent": name}) + + def asked(name): + aid = db.next_id("approval") + db.q( + "CREATE $r CONTENT $d", + r=store.R("approval", aid), + d={"chat": 5, "account": people["me"], "tool": name, "args": {"to": ["a@x.io"]}, "summary": name, "status": "pending"}, + ) + return aid + + h = login(client, "me@x.io", "my password 1") + _, key = auth.create_token(db, people["me"], "script", scope="write") + hk = {"Authorization": f"Bearer {key}"} + ho = _bearer(_grant(client, h, scope="write")[1]) + mail, event, file = asked("send_mail"), asked("add_event"), asked("write_file") + for hdr in (hk, ho): # an API key and an app see they can only decline, and can't approve or sample + assert client.get(f"/api/v1/approvals/{mail}", headers=hdr).json()["can"] == { + "approve": False, + "decline": True, + "edit": False, + "always": False, + } + for aid in (mail, event, file): + for decision in ("approve", "sample"): + r = client.post(f"/api/v1/approvals/{aid}", headers=hdr, json={"decision": decision}) + assert r.status_code == 403 and "only decline" in r.json()["detail"], (aid, decision, r.text) + with pytest.raises(PermissionError): # nor MCP or the assistant, however they reach it + ai_tools.approve(db, cfg, mail, {"id": people["me"], "email": "me@x.io"}, {people["pods"]}, "approve", via="agent") + assert not done and approvals.get(db, mail)["status"] == "pending" + assert client.get(f"/api/v1/approvals/{mail}", headers=h).json()["can"]["approve"] is True + # declining works from each of them + assert client.post(f"/api/v1/approvals/{event}", headers=hk, json={"decision": "decline"}).json()["status"] == "declined" + assert client.post(f"/api/v1/approvals/{file}", headers=ho, json={"decision": "decline"}).json()["status"] == "declined" + later = asked("send_mail") + assert tool(client, ho, "decline_approval", id=later) == {"approval": later, "status": "declined"} + assert "not waiting" in tool_error(client, ho, "decline_approval", id=later) + # and the person, signed in, approves + out = client.post(f"/api/v1/approvals/{mail}", headers=h, json={"decision": "approve"}) + assert out.status_code == 200 and out.json()["status"] == "done" and done == ["send_mail"] + assert approvals.get(db, mail)["decided_by"] == "me@x.io" diff --git a/nextjs-frontend/app/openapi-client/sdk.gen.ts b/nextjs-frontend/app/openapi-client/sdk.gen.ts index 8e8f158ed..bcb70ccb0 100644 --- a/nextjs-frontend/app/openapi-client/sdk.gen.ts +++ b/nextjs-frontend/app/openapi-client/sdk.gen.ts @@ -10967,8 +10967,8 @@ export class Chats { * * Approve (or run a sample of, or decline) something the assistant proposed or an automation's action. Each * approval is decided once. An automation's action can also be edited (`params`) and then carried out, or allowed - * from now on for that automation (`always`); approving one needs you signed in, since it's your pick: an API key - * or an app can only decline it. + * from now on for that automation (`always`). Approving is your pick, so it needs you signed in: an API key or an + * app can only decline (403 otherwise). */ public static decideApproval( options: Options, diff --git a/nextjs-frontend/openapi.json b/nextjs-frontend/openapi.json index 6863d1fa2..da69b617e 100644 --- a/nextjs-frontend/openapi.json +++ b/nextjs-frontend/openapi.json @@ -26969,7 +26969,7 @@ "chats" ], "summary": "Decide Approval", - "description": "Approve (or run a sample of, or decline) something the assistant proposed or an automation's action. Each\napproval is decided once. An automation's action can also be edited (`params`) and then carried out, or allowed\nfrom now on for that automation (`always`); approving one needs you signed in, since it's your pick: an API key\nor an app can only decline it.", + "description": "Approve (or run a sample of, or decline) something the assistant proposed or an automation's action. Each\napproval is decided once. An automation's action can also be edited (`params`) and then carried out, or allowed\nfrom now on for that automation (`always`). Approving is your pick, so it needs you signed in: an API key or an\napp can only decline (403 otherwise).", "operationId": "decide_approval", "parameters": [ { diff --git a/threat-model.json b/threat-model.json index d10f1a4b5..2e0a2a627 100644 --- a/threat-model.json +++ b/threat-model.json @@ -1275,7 +1275,7 @@ "property": "P-APPROVAL", "violation_symptom": "integrity-bypass", "severity_tier": "security", - "conditions": "assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation", + "conditions": "assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation; only the person approves, signed in or in the chat (API keys, apps, MCP and the assistant only decline)", "provenance": "documented", "source": "docs/assistant.md \"Approvals\"" }, diff --git a/threat-model.md b/threat-model.md index 1019d7795..d2756f0af 100644 --- a/threat-model.md +++ b/threat-model.md @@ -563,7 +563,7 @@ Paths in the Voided by column are relative to `fastapi_backend/app/`. Searches c | P-NO-FETCH | SPARQL refuses SERVICE and FROM and never loads a named graph. RDF import fetches nothing, refuses remote JSON-LD contexts and does not read RDF/XML. | info-leak | security-critical | *(documented, rdf_import.py docstring "Nothing is fetched while reading")* | Voided by: Process-global rdflib flag, set per call — `domain/rdf.py:576`; SERVICE refused — `domain/rdf.py:551`; remote contexts — `domain/rdf_import.py:54-56`. | | P-QUERY | Cypher is read-only and runs on the caller's readable namespaces. A query stops within 3 million steps or 8 seconds; paths run up to 8 hops. Threshold: running past the budget is a bug; slow within it is not. | integrity-bypass (writes, scope); hang (budget) | security-critical (scope, writes); correctness-only (budget) | *(documented, docs/graph.md "3 million steps")* | Voided by: Admins see every namespace; write refusals — `domain/cypher.py:39`; budgets — `domain/cypher.py:35-38`. | | P-RETRIEVAL | Chat, assistant tools and MCP return only what the person can read, within the conversation's scope, and the tool loop stops at `ai.max_steps` (or the tool calls a question allows, at most `ai.max_tool_calls`) and `ai.max_transcript_reads`. A namespace's chat completions answer from that namespace alone, with only the read tools its owners offered. | info-leak (scope); hang (caps) | security-critical (scope); correctness-only (caps) | *(documented, docs/assistant.md "limited to what the person can read")* | Voided by: Admins read everything; an admin setup conversation adds server tools and the `act` flag — `domain/ai_tools.py:287-289`; `ai.extensions: false` turns extensions off. | -| P-APPROVAL | Assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation. Inviting people and changing their access always wait, even there, and the assistant cannot remove an account. | integrity-bypass | security-critical | *(documented, docs/assistant.md "Approvals")* | Voided by: Admins read everything; an admin setup conversation adds server tools and the `act` flag — `domain/ai_tools.py:287-289`; `ai.extensions: false` turns extensions off. | +| P-APPROVAL | Assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation. Inviting people and changing their access always wait, even there, and the assistant cannot remove an account. Only the person approves, signed in to Lens or in the chat it was asked in: an API key, an app, MCP and the assistant can only decline (`domain/approvals.py` `can`). | integrity-bypass | security-critical | *(documented, docs/assistant.md "Approvals")* | Voided by: Admins read everything; an admin setup conversation adds server tools and the `act` flag — `domain/ai_tools.py:287-289`; `ai.extensions: false` turns extensions off. | | P-AUTOMATION-APPROVAL | An automation's action that asks first (effect `out`, or `lens` beyond the event's own object) waits as an approval of the automation's person, and nothing runs until they pick. Approving, editing or allowing a node from now on (`always`) needs them signed in to Lens, or (approving an action that stays inside Lens, effect `lens`) a yes in the private chat Lens told them in, from someone on that channel's `users` list with approving on, while it is the only thing waiting there or named by its number; an action that reaches outside Lens is approved on its card. API keys, apps, MCP and the assistant can only list and decline. A decision is claimed once (two at once can't both carry it out). At most 100 wait per automation and each tells the person once, so a flood of activities can't bury the inbox or their chat; undecided ones expire after `automations.approval_days` and nothing runs. | integrity-bypass | security-critical | *(documented, docs/automations.md "Approvals")* | Voided by: the person setting a node to `auto` (`always`, or the builder's toggle) — that node then runs without asking; an admin raising `automations.approval_days`. The summary and the message the person is told hold text the run read from outside Lens: links in it are broken up (P-INJECTION-EGRESS), and what runs is the intent the card shows. | | P-INJECTION-EGRESS | Once an assistant answer has read text from outside Lens (a tool result other than Lens's own, the page it was asked from, a namespace assistant's memories, a message in a chat room with no `bridge.users`, or an earlier answer in the conversation that read any of these), tools that could carry it out of Lens (the person's own `read` web tools, a web search or page read neither the person nor a tool gave it, other servers' MCP tools, Python tools with the network, code in the code sandbox with its network on) and an admin setup conversation's own changes wait for the person's approval. A chat room's answer keeps a web address linkable only when the person, the archive, a tool or Lens wrote it. A bypass is `VALID-HARDENING` (Q26). An automation's model and agent actions (`ask_model`, `call_tool`, `ask_agent`) run with nobody reading along: the activity and earlier steps reach the model marked as data, every change they would make (notes included) is an approval of the automation's person, and anything that could carry data out of Lens asks first whatever the run read (docs/automations.md "The model and the agent"). A saved variable a run set from outside text stays marked as data in later runs' prompts, and an action whose params read it counts as reading outside text (docs/automations.md "Saved variables"). Within a research run the person approved, the plan's web searches and page reads, and code runs with the network when the plan names the code sandbox, don't ask again: approving the plan approved them (P-RESEARCH). | info-leak | correctness-only | *(documented, docs/assistant.md "it read out of Lens waits for your approval")* | Voided by: `ai.untrusted_asks: false` — `domain/ai_tools.py:519`; `bridge.safe_links: false` — `domain/bridge.py:298`. Notes and memories are written at once: they stay in Lens. Hooks run as their owners set them (P-EXT-SCOPE). An address the read text wrote itself stays linkable in a room. The person's browser asks first as P-BROWSER-GUARD says. | | P-EXT-SCOPE | Your own hooks run in your conversations; another person's hooks run only when an admin shared them. | integrity-bypass | security-critical | *(documented, docs/assistant.md "other people's run only when an admin shared them")* | Voided by: An admin sharing the extension — `domain/extensions.py:595-598`. | diff --git a/threat-model.yaml b/threat-model.yaml index 1cfd9744d..dd1b63ab1 100644 --- a/threat-model.yaml +++ b/threat-model.yaml @@ -1747,7 +1747,7 @@ properties_claimed: kind: integrity components: [assistant] tier: security-critical - conditions: "assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation" + conditions: "assistant tools that change data wait for the person's approval, except notes and an admin's setup conversation; only the person approves, signed in or in the chat (API keys, apps, MCP and the assistant only decline)" violation_symptoms: [integrity-bypass] x-voided-by: "admins read everything; an admin setup conversation adds server tools and the act flag (domain/ai_tools.py:287-289); ai.extensions: false turns extensions off" provenance: {kind: documented, source: 'docs/assistant.md "Approvals"'}