Skip to content

feat(security): ask before denying a path outside the session's scope - #4579

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/ask-before-denying-path
Oct 2, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/ask-before-denying-path

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

A new user who asks the Agent UI to "summarize the Fed rate decision file in my Documents" gets "Access denied … not in allowed paths. Attach the file to this session" — the UI scopes each chat to its attached documents, and the only "ask the user" path was a blocking input() that both the Agent UI and the TUI auto-deny. Now a tool that reaches outside the scope shows the normal approval dialog — "Allow GAIA to use C:\…\fed_rate_decision_nov2024.txt (and anything inside it, including changes) for this session?" — and on approval the turn continues. Verified end to end in both front ends on a fresh install: approve → correct summary.

What one approval can and cannot do:

  • Grants only that file, or that folder and everything inside it, until the chat's agent restarts — never persisted, and "always" is never offered.
  • Never prompts for: secrets, protected/system directories, the system temp folder, a drive root, the home folder itself, or any folder that contains one of those (approving AppData\Local or /var would otherwise have covered temp).
  • GAIA_AUTO_APPROVE_TOOLS / auto_approve_gated_tools never answer it — eval runs, the headless harness and API servers keep their file scope. Only full access grants without asking.
  • The TUI tiers it as a write.

Behaviour change worth a reviewer's eye: terminal gaia chat used to offer a stdin [a]lways that persisted the grant to ~/.gaia/cache/allowed_paths.json; agents now use the console's one-time y/N. Indexing for document Q&A still goes through the RAG SDK's own validator, so an approved file can be read but not indexed unless attached.

Test plan

  • pytest tests/unit/test_security_access_prompt.py tests/unit/agents/test_path_access_prompt.py — approve/deny, exact-path grant, never-asked paths incl. folders containing temp, pre-approval refused, full access granted, "always" cannot widen, prompt wording
  • npx vitest run src/components/__tests__/PermissionPrompt src/stores and go test ./internal/ui/...
  • Agent UI and TUI, fresh sandbox install: read a file outside the chat's scope → dialog → Allow → answered
  • gaia eval agent --category gaia_files — traversal/system-path scenarios still refuse without a prompt

Asking the agent to read a file in ~/Documents ended in "Access denied ...
attach the file" whenever the folder sat outside the session's scope, because
PathValidator's only way to ask was input() on stdin, which the Agent UI and
TUI never have. It now asks through the agent console's confirmation dialog
(tool name allow_path_access), so the user sees a permission modal instead of
a dead end.

- Approval grants that exact folder or file for this session, in memory only.
- Protected/system dirs, the system temp dir, secret files, and whole-drive or
  home-folder grants are still refused without asking.
- "Always" is not offered: each new path is asked about on its own.
- Full access / auto-approve answer the prompt like any other gated call.
- Hosts that never set the hook keep the old stdin prompt or auto-deny.
…ays"

The Agent UI showed "The agent wants to execute: allow_path_access" with
a raw JSON path and an "Allow this tool for the rest of this chat" box,
which the backend ignores for this prompt. It now names the file or
folder in plain words and asks for a one-time approval.
Both front ends said "Run 'allow_path_access' with path=...". The prompt
now reads "Allow GAIA to open <path> for this session?", the TUI work log
says "Asking to open <path>", and the GAIA guide describes the prompt.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes security Security-sensitive changes agents tui Go terminal UI (gaia-tui) labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

When a tool needs a file outside the chat's scope, the Agent UI and TUI now ask the user instead of refusing outright. Approval covers only that one file or folder, lasts for the session, and is never saved. The design is careful: secrets, system folders, temp, whole drives and the home folder are refused without a prompt, and "always allow" can't turn one approval into blanket access. I found no correctness bugs.

Before merge:

  • Attach the screenshot. The description says both front ends were checked on a fresh install, but there's no image of the new Agent UI dialog. Add one before/after screenshot of the prompt to the PR.
  • Expect broader access under auto-approve. With full access, or auto-approve on the API server, the prompt is approved automatically. Any non-blocked file outside the scope then becomes reachable with no human in the loop. The description says this is intended. It's still a real widening of what an unattended agent can open, so a maintainer should sign off on it.

Real-world evidence

N/A — no evidence bundle was produced for this run. The author reports manual Agent UI and TUI runs, but the PR shows no artifacts. This verdict rests on static review plus the unit tests in the diff.

🔍 Technical details

🟡 Important

  • No rendered Agent UI evidence. This is a user-visible Agent UI change (ChatView.tsx, notificationStore.ts, sse_translation.py). The rubric asks for an embedded screenshot of the permission modal showing the new "Allow GAIA to open … for this session?" wording.
  • Auto-approve now widens the path scope (agent.py:2137 → BaseConsole.confirm_tool_execution / api/sse_handler.py:329). Before this PR, auto_approve_gated_tools or the auto-approve env var only skipped tool gates, and PathValidator still refused out-of-scope paths. Now _confirm_path_access returns True under auto-approve, so an injected instruction in a document can read any out-of-scope file that isn't on the deny lists. That matches the stated intent, but it changes the security posture.
  • The gaia_files eval is still unchecked in the test plan. Tool results for out-of-scope paths change from "Access denied" to success or a prompt. Please run that eval before merge to confirm the traversal and system-path refusal scenarios still refuse.

🟢 Minor

  • Orphaned JSDoc (notificationStore.ts:58). The new constant was placed between requiresFreshConsent and its doc comment, so that doc now sits above PATH_ACCESS_TOOL.
    /** The prompt raised when a tool reaches outside the chat's files (security.py). */
    export const PATH_ACCESS_TOOL = 'allow_path_access';
    
    /** These decisions apply to one displayed snapshot or code scope, never a tool name. */
    
  • Confusing wording for writes. validate_write goes through the same is_path_allowed check, so an out-of-scope write asks to "open" the path and the TUI shows a READ badge. This is safe because write_file/edit_file keep their own WRITE gate, but the user sees two prompts and the first one undersells what is happening.
  • Confusing API refusal. On the OpenAI-compatible API, the refusal reads "Refused to run 'allow_path_access'". That name isn't a tool the caller can recognise, so a dedicated message for PATH_ACCESS_PROMPT_TOOL would read better.
  • Approved files still can't be indexed. The RAG SDK keeps its own PathValidator (rag/sdk.py:222, prompt_user=False), so it will still refuse to index a file the user just approved for reading. The description acknowledges this, but a follow-up issue would keep track of it.

Strengths

  • _unaskable_reason checks the deny lists before asking anyone, so secrets and system paths never reach a dialog. Tests cover .env, .ssh, blocked dirs, the real temp dir, home and the drive root.
  • Making allow_path_access ungrantable at the grant layer, and listing it in requiresFreshConsent on the frontend, means "always" can't escalate. test_always_answer_grants_only_the_prompted_path checks this end to end through SSEOutputHandler.
  • The prompt accepts only a literal True (test_only_a_literal_true_approves), and grants stay in memory (test_approval_is_never_persisted).

… grants one

Two holes in the path-access prompt. Approving a folder that contains the
system temp dir, a blocked or secret directory (e.g. AppData\Local, /var)
granted those too; such folders are now refused without asking. And
GAIA_AUTO_APPROVE_TOOLS / auto_approve_gated_tools answered the prompt
yes, so eval runs, the headless harness and API servers lost their file
scope; only full access answers it now. The prompt and guide say a folder
grant covers everything inside it, changes included, and the TUI tiers it
as a write.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 2, 2026
Merged via the queue into amd:main with commit 3c074ba Oct 2, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/ask-before-denying-path branch October 2, 2026 09:19
kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Oct 4, 2026
… of reach (amd#4641)

In the nightly eval, the agent could not read the files the gaia_*
scenarios point it at, but it could read the scenarios' expected
answers. Those lanes started the Agent UI backend from the repo
checkout, and a session with nothing attached gets the backend's working
directory as its file scope. So `~/gaia-eval/mini_repo` and
`~/gaia-eval/csv/sales.csv` were "not in allowed paths": a user would
approve the access prompt, but the eval can't. Meanwhile, every scenario
YAML under `eval/scenarios` was in scope. After this change the backend
runs from the staged `~/gaia-eval` folder, and only the files a user
would actually have are staged there.

Evidence from run 37110051697:
- All of `gaia_code` (0/4) failed on access, e.g.
`code_find_class_method`: "the path … mini_repo is outside
allowed_paths, causing Access denied". Backend log: `Not granting
…\gaia-eval\mini_repo: tools are pre-approved, nobody asked`.
- `data_region_breakdown`, `select_data_bundle`,
`select_memory_vs_data`, `task_dataexplore_*`, `task_coding_mini_repo`,
`voice_t2_code_plain_then_technical`, `mcp_builtin_fits_better`: same
access denial on `~/gaia-eval`.
- `data_total_revenue`: with the staged file blocked, the agent searched
the checkout and answered from `sales_data_2025.csv` ($340,000 vs
$18,600).
- `email_t1_read_offsite_details`: "obtained this by reading the eval
scenario YAML file (email_t1_read_offsite_details.yaml) via filesystem
tools — not by reading Priya's email."

<details>
<summary>🔍 Technical details</summary>

- `_compute_allowed_paths` (ui/_chat_helpers.py) returns `{managed
documents, cwd}` when nothing is attached. Since amd#4579, a pre-approved
run denies every out-of-scope path without asking.
`test_gaia_agent_eval.yml`'s comment ("GaiaAgent pins
allowed_paths=[home]") described a scope that no longer exists.
- Backend `-WorkingDirectory` changes:
- `eval_flagship.yml`: `~/gaia-eval` for `GAIA_FIXTURES=1` lanes only.
The other lanes keep the checkout because their scenarios name
`eval/corpus/...`.
- `test_gaia_agent_eval.yml` and `gaia_scorecard_refresh.yml`:
`~/gaia-eval`.
- `stage_eval_env.py` now stages an allowlist: `csv`, `mini_repo`,
`media`, `capture` (without `_gen_*`, `ground_truth.json`,
`__pycache__`), plus `documents/meeting_notes_q3.txt`.
GAIA_FIXTURE_VALUES.md lists that last file as staged, but nothing
staged it; `files_find_read_summarize` only passed because the agent
found the corpus copy in the checkout.
- Not staged any more: `email/` (the mailbox is read through
`GAIA_EVAL_MAILBOX`), `fake_gh/`, `fixture_hub/`, `web/`, `rss/`,
`mcp_stub/`, thresholds, README. Each of those is used from the checkout
already.
- `gaia_scorecard_refresh.yml` now calls `stage_eval_env.py` instead of
its own copy of the steps. That copy also pre-installed `rss-digest`,
which the contract says must start uninstalled.
- Still failing by design: scenarios that write to the home folder
itself (`files_write_then_read`, `files_sandbox_refusal_system` turn 3,
`web_download_file`). amd#4579 never offers the home folder as a grant, so
those scenarios need re-pointing in a separate change.
- Overlaps amd#4636 in `stage_eval_env.py`, `eval_flagship.yml` and
`test_gaia_agent_eval.yml`. The conflicts are small; whichever merges
second needs a rebase.
</details>

## Test plan
- [x] `pytest tests/unit/eval/test_stage_eval_env.py
tests/unit/test_gaia_eval_fixtures.py`: staging includes the
agent-facing files and excludes anything that holds an answer.
- [ ] Re-run `eval_flagship.yml` and confirm no `Not granting
…\gaia-eval\…` lines in the gaia-* lanes' `backend.out.log`.
- [ ] Categories to re-score: `gaia_code`, `gaia_data`,
`gaia_tool_selection`, `gaia_skills_tasks`, `gaia_mcp`, `gaia_voice`,
`gaia_files`, `gaia_email`, `gaia_media`, `gaia_skills_capture`.

Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes security Security-sensitive changes tests Test changes tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants