Security: TaskManager and DelegateExecutor fail open when confirmation_handler is unset, silently auto-approving WAITING_FOR_CONFIRMATION sub-agent actions

Open
#6,999 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@zsicheng0214 is already working on this.

Since Nov 19, 2026.

  • #7001 by @zsicheng0214 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
ai, backend, security

Research direction

Read openhands-tools/openhands/tools/task/manager.py and openhands-tools/openhands/tools/delegate/impl.py, then inspect the related tests under tests/tools/task/ and tests/tools/delegate/. Check how each runner handles WAITING_FOR_CONFIRMATION and how sub-agent conversations inherit the parent's security analyzer. Done means the acceptance criteria pass, including fail-closed behavior without a handler; linked pull request #7001 is already open.

Written by the indexing model from the issue text.

Description

priority:high ready-for-dev
Is there an existing issue for the same bug?
  • I have searched existing issues and this is not a duplicate.
Bug Description

When a parent conversation is configured with AlwaysConfirm() or ConfirmRisky() (for example, confirmation mode enabled in openhands-agent-server / Agent Canvas, or via LocalConversation.set_confirmation_policy(...)), or when a file-defined sub-agent in .agents/agents/*.md explicitly sets permission_mode: always_confirm or permission_mode: confirm_risky, sub-agent tool calls requiring confirmation silently fail open and execute without approval.

Two compounding defects in TaskManager (openhands-tools/openhands/tools/task/manager.py) and DelegateExecutor (openhands-tools/openhands/tools/delegate/impl.py) cause this bypass:

  1. Fail-open auto-approval when confirmation_handler is None:
    TaskToolSet.create(conv_state) (openhands-tools/openhands/tools/task/definition.py:237, 282) defaults confirmation_handler=None, and neither LocalConversation nor EventService (openhands-agent-server) passes a confirmation_handler. Yet TaskManager._run_until_finished (openhands-tools/openhands/tools/task/manager.py:478-484) and DelegateExecutor._run_until_finished (openhands-tools/openhands/tools/delegate/impl.py:135-141) treat self._confirmation_handler is None as approval:

    if self._confirmation_handler is None or self._confirmation_handler(
        task_id, pending
    ):
        conversation.run()
    

    Because calling LocalConversation.run() a second time while in ConversationExecutionStatus.WAITING_FOR_CONFIRMATION is implicit user confirmation (agent.py:870 — "Confirmation mode: Executing 1 pending action(s)"), every WAITING_FOR_CONFIRMATION action inside a sub-agent is immediately approved and executed with zero user consent. Under ConfirmRisky, the main agent can delegate a LOW-risk TaskAction (requiring no parent prompt at all), and the spawned sub-agent can then execute HIGH-risk destructive shell commands (rm -rf, curl | sh, credential mutations) completely unprompted.

  2. Parent security_analyzer is not propagated to sub-agent conversations:
    TaskManager._get_conversation (manager.py:328), TaskManager._resume_task (manager.py:223), and DelegateExecutor._spawn_agents (delegate/impl.py:248) copy confirmation_policy, secrets, and mcp_tool_provider from the parent conversation, but never call sub_conversation.set_security_analyzer(parent.state.security_analyzer). A parent conversation using ConfirmRisky with LLMSecurityAnalyzer (or a custom SecurityAnalyzerBase) leaves sub-agents with security_analyzer=None.

Discovered during security/governance mechanism auditing with TraceTrial-Bench (arXiv:2610.32285, mechanism nodes G2 — confirmation guardrail enforcement & L — sub-agent delegation lifecycle).

Expected Behavior
  1. When a sub-agent enters ConversationExecutionStatus.WAITING_FOR_CONFIRMATION and self._confirmation_handler is None, TaskManager._run_until_finished and DelegateExecutor._run_until_finished fail closed: they reject the pending actions via conversation.reject_pending_actions(...) with an actionable reason (explaining that interactive confirmation is unavailable inside sub-agent delegation) rather than calling conversation.run() to auto-execute them.
  2. When an explicit confirmation_handler is supplied, its boolean return value continues to approve (True) or reject (False) pending actions as today.
  3. Sub-agent conversations created or resumed by TaskManager and DelegateExecutor inherit parent.state.security_analyzer alongside confirmation_policy.
  4. Sub-agents running under NeverConfirm() (or explicit permission_mode: never_confirm) never enter WAITING_FOR_CONFIRMATION and continue to execute normally.
Actual Behavior

On current main, a sub-agent spawned from an AlwaysConfirm() parent conversation silently auto-confirms and executes shell commands:

uv sync --frozen --dev
uv run python - <<'PY'
import json
from pathlib import Path
from tempfile import TemporaryDirectory
from openhands.sdk import Agent, LocalConversation, Message, TextContent, Tool
from openhands.sdk.llm import MessageToolCall
from openhands.sdk.security.confirmation_policy import AlwaysConfirm
from openhands.sdk.testing import TestLLM
from openhands.sdk.tool import register_tool
from openhands.tools.preset import register_builtins_agents
from openhands.tools.preset.default import register_default_tools
from openhands.tools.task import TaskToolSet
from openhands.tools.task.definition import TaskAction
from openhands.tools.terminal import TerminalTool

register_default_tools(enable_browser=False)
register_tool("TaskToolSet", TaskToolSet)
register_builtins_agents(enable_browser=False)

with TemporaryDirectory() as tmp:
    ws = Path(tmp)
    canary = ws / "executed_without_confirmation.txt"
    llm = TestLLM.from_messages([
        Message(
            role="assistant",
            content=[TextContent(text="")],
            tool_calls=[
                MessageToolCall(
                    id="call_sub_1",
                    name="terminal",
                    arguments=json.dumps({"command": f"echo PWNED > {canary}"}),
                    origin="completion",
                )
            ],
        ),
        Message(role="assistant", content=[TextContent(text="done")]),
    ])
    parent = LocalConversation(
        agent=Agent(llm=llm, tools=[Tool(name="TaskToolSet"), Tool(name=TerminalTool.name)]),
        workspace=str(ws),
        visualizer=None,
    )
    parent.set_confirmation_policy(AlwaysConfirm())

    task_tool = TaskToolSet.create(conv_state=parent.state)[0]
    task_tool(TaskAction(prompt="Run command", subagent_type="bash-runner"), parent)
    assert not canary.exists(), f"Fail-open bypass: {canary} was created under AlwaysConfirm!"
PY

Running the snippet above on main logs Confirmation mode: Executing 1 pending action(s) and fails the assertion because executed_without_confirmation.txt is created with content PWNED.

Acceptance Criteria
  • With confirmation_handler=None (the default in TaskToolSet.create and DelegateExecutor), any sub-agent action that triggers WAITING_FOR_CONFIRMATION (via inherited AlwaysConfirm / ConfirmRisky or sub-agent permission_mode: always_confirm / confirm_risky) is rejected via reject_pending_actions(...) rather than executed.
  • With an explicit confirmation_handler callback provided, returning True approves and executes the pending sub-agent actions, and returning False rejects them with "User rejected the actions".
  • TaskManager (both new and resumed tasks) and DelegateExecutor propagate parent.state.security_analyzer onto sub-agent LocalConversation instances so ConfirmRisky evaluates risk with the parent's configured security analyzer.
  • Sub-agents under NeverConfirm() (default when confirmation mode is off, or permission_mode: never_confirm) are unaffected.
  • Unit tests under tests/tools/task/ and tests/tools/delegate/ cover fail-closed rejection under AlwaysConfirm and ConfirmRisky, security_analyzer inheritance, and explicit confirmation_handler approval/rejection.

OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Verified against main: TaskManager._run_until_finished (openhands-tools/openhands/tools/task/manager.py) and DelegateExecutor._run_until_finished (openhands-tools/openhands/tools/delegate/impl.py) treat confirmation_handler is None as approval, and calling LocalConversation.run() on a WAITING_FOR_CONFIRMATION conversation executes the pending actions (agent.py: "Confirmation mode: Executing N pending action(s)"). TaskToolSet.create defaults the handler to None, and no shipped caller (LocalConversation, EventService/agent-server, presets) passes one, so every confirmation-policy prompt inside a sub-agent is silently auto-approved. The repo's own verify program (.agents/skills/verify-sdk/programs/S11/task_confirmation.py) and feature map (S11.task-confirmation) record this fail-open default; the fix supersedes that expectation, so both must be updated with the new outcome. TaskManager._get_conversation/_resume_task and DelegateExecutor._spawn_agents copy policy, secrets, and MCP but never call set_security_analyzer(...), so sub-agents run with security_analyzer=None; without an analyzer the risk is UNKNOWN, so ConfirmRisky inside sub-agents confirms by default rather than by evaluated risk. The confirmation_handler docstrings do not promise fail-open, and no repository guidance (AGENTS.md, .agents/skills/custom-codereview-guide.md) endorses the fail-open default, so fail-closed is the safe resolution consistent with the SDK's documented confirmation model.

Scope: fail-closed default when no handler is set (reject the pending sub-agent actions with a reason explaining that interactive confirmation is unavailable inside sub-agent delegation); preserve explicit-handler semantics (True approves, False rejects); propagate the parent's security_analyzer to sub-agent conversations created and resumed by TaskManager and to DelegateExecutor-spawned conversations; keep NeverConfirm flows unchanged; update the S11 verify program and feature map; add regression tests under tests/tools/task/ and tests/tools/delegate/.

Non-goals: no new confirmation-policy types and no changes to ConfirmationPolicyBase or the parent-loop confirmation gate in agent.py; no new confirmation_handler plumbing into LocalConversation, EventService, or agent-server request surfaces; no behavior change for conversations under NeverConfirm or with an explicit handler; no condenser/hooks/secret-inheritance changes beyond the analyzer; no work on the scheduled removal of the deprecated DelegateExecutor beyond the shared fail-closed behavior; no documentation changes in the separate OpenHands/docs repository.

Compatibility boundary: behavior changes only where a confirmation policy is active (inherited AlwaysConfirm/ConfirmRisky or permission_mode) and no explicit confirmation_handler is provided — previously such sub-agent actions were silently approved; they will now be rejected. NeverConfirm paths and explicit-handler paths keep today's behavior. The S11 program's "no handler approves" check is intentionally superseded.

Acceptance Criteria
  • With no confirmation_handler (the default in TaskToolSet.create and DelegateExecutor), a sub-agent action that reaches WAITING_FOR_CONFIRMATION (via inherited AlwaysConfirm/ConfirmRisky or permission_mode) is rejected via reject_pending_actions, the rejection reason recorded in the sub-agent events states that interactive confirmation is unavailable for sub-agent actions, and the action's side effect does not occur (e.g., the scripted terminal command's file is not created).
  • With an explicit confirmation_handler, returning True executes the pending sub-agent actions and returning False rejects them with the reason "User rejected the actions".
  • Sub-agents under NeverConfirm() (default, or permission_mode: never_confirm) never enter WAITING_FOR_CONFIRMATION and complete normally, matching current behavior.
  • TaskManager sets the parent conversation's security_analyzer on sub-agent conversations for both newly created and resumed tasks, and DelegateExecutor._spawn_agents does the same, observable as sub_conversation.state.security_analyzer equal to parent.state.security_analyzer.
  • Under ConfirmRisky with the inherited analyzer, a sub-agent action evaluated as HIGH risk waits for confirmation and is then rejected (no handler) instead of running, and SecurityAnalysisEvents inside the sub-agent record the analyzer's evaluated risks rather than all-UNKNOWN.
  • New or updated tests in tests/tools/task/ and tests/tools/delegate/ drive real LocalConversation flows (scripted TestLLM) covering fail-closed rejection under AlwaysConfirm and ConfirmRisky, explicit-handler approve/reject, and analyzer inheritance, and pass in CI.
  • .agents/skills/verify-sdk/programs/S11/task_confirmation.py and .agents/skills/verify-sdk/references/feature-map/S11-subagents-delegation.md no longer assert the no-handler auto-approval and record the fail-closed default; the S11 program emits the new expected outcome when run.
Dominant language
Python
Stars
1.4k
Forks
797
Avg merge
1d 17h
Merged PRs (30d)
354

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenHands/software-agent-sdk

All issues in OpenHands/software-agent-sdk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.