fix(webui): enforce workspace authority across queued inputs

Keep workspace changes at the authenticated owner boundary. Queue follow-up inputs separately when their tool scope differs from the active run.

Co-authored-by: Tenable Research <152317477+tenbbughunters@users.noreply.github.com>
This commit is contained in:
Xubin RenandTenable Research committed 2026-11-04 23:33:49 +08:00
1 parent 4dd3fbecb6
commit 219dd13fd8
12 files changed
+381 -36

No files matched your search

+12 -4
View File
@@ -500,7 +500,8 @@ async def test_access_changes_refresh_only_new_message_and_preserve_prefix(tmp_p
@pytest.mark.asyncio
async def test_injected_channel_input_reports_active_tool_scope(tmp_path: Path) -> None:
@pytest.mark.parametrize("same_scope", [True, False])
async def test_followup_only_joins_matching_tool_scope(tmp_path: Path, same_scope: bool) -> None:
project = tmp_path / "project"
project.mkdir()
(project / "marker.txt").write_text("active project", encoding="utf-8")
@@ -517,7 +518,8 @@ async def test_injected_channel_input_reports_active_tool_scope(tmp_path: Path)
session.add_message("user", "Start")
await loop.sessions.state.prepare_input(session)
pending = asyncio.Queue()
await pending.put(InboundMessage("telegram", "user", "chat", "Read marker.txt"))
followup = InboundMessage("websocket" if same_scope else "telegram", "user", "chat", "Read marker.txt")
await pending.put(followup)
await loop._run_agent_loop(
TranscriptInput(history=session.get_history(), current_message=None),
runtime=loop.llm_runtime(), session=session, pending_queue=pending,
@@ -525,8 +527,14 @@ async def test_injected_channel_input_reports_active_tool_scope(tmp_path: Path)
)
calls = loop.provider.chat_stream_with_retry.await_args_list
context = calls[0].kwargs["messages"][-1]["content"]
assert json.dumps(str(project.resolve())) in context
assert "File access: project and tool-specific allowed paths only." in context
if same_scope:
assert json.dumps(str(project.resolve())) in context
assert "File access: project and tool-specific allowed paths only." in context
assert pending.empty()
else:
assert context == "Start"
assert pending.get_nowait() is followup
assert pending.empty()
assert any(message.get("role") == "tool" and "active project" in message["content"]
for message in calls[1].kwargs["messages"])