Security: TaskManager and DelegateExecutor fail open when confirmation_handler is unset, silently auto-approving WAITING_FOR_CONFIRMATION sub-agent actions
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 20/100
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
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:
-
Fail-open auto-approval when
confirmation_handlerisNone:
TaskToolSet.create(conv_state)(openhands-tools/openhands/tools/task/definition.py:237, 282) defaultsconfirmation_handler=None, and neitherLocalConversationnorEventService(openhands-agent-server) passes aconfirmation_handler. YetTaskManager._run_until_finished(openhands-tools/openhands/tools/task/manager.py:478-484) andDelegateExecutor._run_until_finished(openhands-tools/openhands/tools/delegate/impl.py:135-141) treatself._confirmation_handler is Noneas approval:if self._confirmation_handler is None or self._confirmation_handler( task_id, pending ): conversation.run()Because calling
LocalConversation.run()a second time while inConversationExecutionStatus.WAITING_FOR_CONFIRMATIONis implicit user confirmation (agent.py:870—"Confirmation mode: Executing 1 pending action(s)"), everyWAITING_FOR_CONFIRMATIONaction inside a sub-agent is immediately approved and executed with zero user consent. UnderConfirmRisky, the main agent can delegate aLOW-riskTaskAction(requiring no parent prompt at all), and the spawned sub-agent can then executeHIGH-risk destructive shell commands (rm -rf,curl | sh, credential mutations) completely unprompted. -
Parent
security_analyzeris not propagated to sub-agent conversations:
TaskManager._get_conversation(manager.py:328),TaskManager._resume_task(manager.py:223), andDelegateExecutor._spawn_agents(delegate/impl.py:248) copyconfirmation_policy,secrets, andmcp_tool_providerfrom the parent conversation, but never callsub_conversation.set_security_analyzer(parent.state.security_analyzer). A parent conversation usingConfirmRiskywithLLMSecurityAnalyzer(or a customSecurityAnalyzerBase) leaves sub-agents withsecurity_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
- When a sub-agent enters
ConversationExecutionStatus.WAITING_FOR_CONFIRMATIONandself._confirmation_handler is None,TaskManager._run_until_finishedandDelegateExecutor._run_until_finishedfail closed: they reject the pending actions viaconversation.reject_pending_actions(...)with an actionable reason (explaining that interactive confirmation is unavailable inside sub-agent delegation) rather than callingconversation.run()to auto-execute them. - When an explicit
confirmation_handleris supplied, its boolean return value continues to approve (True) or reject (False) pending actions as today. - Sub-agent conversations created or resumed by
TaskManagerandDelegateExecutorinheritparent.state.security_analyzeralongsideconfirmation_policy. - Sub-agents running under
NeverConfirm()(or explicitpermission_mode: never_confirm) never enterWAITING_FOR_CONFIRMATIONand 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 inTaskToolSet.createandDelegateExecutor), any sub-agent action that triggersWAITING_FOR_CONFIRMATION(via inheritedAlwaysConfirm/ConfirmRiskyor sub-agentpermission_mode: always_confirm/confirm_risky) is rejected viareject_pending_actions(...)rather than executed. - With an explicit
confirmation_handlercallback provided, returningTrueapproves and executes the pending sub-agent actions, and returningFalserejects them with"User rejected the actions". -
TaskManager(both new and resumed tasks) andDelegateExecutorpropagateparent.state.security_analyzeronto sub-agentLocalConversationinstances soConfirmRiskyevaluates risk with the parent's configured security analyzer. - Sub-agents under
NeverConfirm()(default when confirmation mode is off, orpermission_mode: never_confirm) are unaffected. - Unit tests under
tests/tools/task/andtests/tools/delegate/cover fail-closed rejection underAlwaysConfirmandConfirmRisky,security_analyzerinheritance, and explicitconfirmation_handlerapproval/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 inTaskToolSet.createandDelegateExecutor), a sub-agent action that reachesWAITING_FOR_CONFIRMATION(via inheritedAlwaysConfirm/ConfirmRiskyorpermission_mode) is rejected viareject_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, returningTrueexecutes the pending sub-agent actions and returningFalserejects them with the reason"User rejected the actions". - Sub-agents under
NeverConfirm()(default, orpermission_mode: never_confirm) never enterWAITING_FOR_CONFIRMATIONand complete normally, matching current behavior. -
TaskManagersets the parent conversation'ssecurity_analyzeron sub-agent conversations for both newly created and resumed tasks, andDelegateExecutor._spawn_agentsdoes the same, observable assub_conversation.state.security_analyzerequal toparent.state.security_analyzer. - Under
ConfirmRiskywith the inherited analyzer, a sub-agent action evaluated as HIGH risk waits for confirmation and is then rejected (no handler) instead of running, andSecurityAnalysisEvents inside the sub-agent record the analyzer's evaluated risks rather than all-UNKNOWN. - New or updated tests in
tests/tools/task/andtests/tools/delegate/drive realLocalConversationflows (scriptedTestLLM) covering fail-closed rejection underAlwaysConfirmandConfirmRisky, explicit-handler approve/reject, and analyzer inheritance, and pass in CI. -
.agents/skills/verify-sdk/programs/S11/task_confirmation.pyand.agents/skills/verify-sdk/references/feature-map/S11-subagents-delegation.mdno 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenHands/software-agent-sdk
-
[Bug]: `list_directory` reports a complete listing as truncated when a directory has exactly 500 entriesPossibly taken @balabommablock-cpu claimed this 29 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
OpenHands/software-agent-sdk#6133 ·
Maintainers usually reply within 1 day
-
[Bug]: Command hook that exits 1 is treated as blocking when its stdout is a JSON `deny` or `continue: false`Possibly taken A pull request linked to this issue is open or already merged. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/software-agent-sdk#6116 · 3 comments ·
Maintainers usually reply within 1 day
-
[Bug]: TypeScript GET-with-body requests remain pending after a truncated responsePossibly taken @BlueRaddish claimed this 34 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
OpenHands/software-agent-sdk#6059 ·
Maintainers usually reply within 1 day
-
[Bug]: Document whether `prompt_tokens` includes `cache_read_tokens` in accumulated token usagePossibly taken @Jaxon1216 claimed this 36 days ago. Openpriority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5975 ·
Maintainers usually reply within 1 day
-
priority:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5708 · 1 comment ·
Maintainers usually reply within 1 day
All issues in OpenHands/software-agent-sdk
Similar issues
-
[Bug]: reme CLI crashes when the running server used a relative config pathPossibly taken @nurlanmnn claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/ReMe#770 ·
Maintainers usually reply within 1 day
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionPossibly taken @balcsida claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/TokenEconomizer#288 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 67/100
sickn33/agentic-awesome-skills#2437 ·
Maintainers usually reply within 1 day
-
site-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ethereum/consensus-specs#5846 ·
Maintainers usually reply within 1 day