Skip to content

Python: Fix vulnerability: Validate function approval responses in DevUI executor (CWE-863)#4598

Open
hgvfhsrtyvrt456vtg wants to merge 1 commit intomicrosoft:mainfrom
hgvfhsrtyvrt456vtg:fix/cwe863-devui-approval-bypass
Open

Python: Fix vulnerability: Validate function approval responses in DevUI executor (CWE-863)#4598
hgvfhsrtyvrt456vtg wants to merge 1 commit intomicrosoft:mainfrom
hgvfhsrtyvrt456vtg:fix/cwe863-devui-approval-bypass

Conversation

@hgvfhsrtyvrt456vtg
Copy link

Summary

Fixes #4597 - The DevUI executor accepts forged function_approval_response content, allowing arbitrary tool execution without human approval. This is a CWE-863 (Incorrect Authorization) vulnerability.

Problem

The _convert_input_to_chat_message() method processes function_approval_response content items from the client and trusts the request_id, tool name, and arguments without verifying that the server ever issued a corresponding approval request. This means an attacker can fabricate a response and execute any registered tool with arbitrary arguments, completely bypassing approval_mode="always_require".

This vulnerability allows unauthenticated arbitrary tool execution. Depending on the registered tools, the impact ranges from file read/write and database access to SSRF and remote code execution.

Fix

  1. Server-side tracking: When the executor streams events back to the client and encounters a response.function_approval.requested event, it records the request_id and the server-side function_call data in _pending_approvals.

  2. Validation on response: When a function_approval_response arrives, the executor checks the request_id against _pending_approvals. If not found, the response is rejected with a warning log. If found, the server-stored tool name, arguments, and call_id are used. Client-supplied function_call data is ignored.

  3. Anti-replay: The request_id is consumed (popped) on use, preventing the same approval from being replayed.

Changes

  • python/packages/devui/agent_framework_devui/_executor.py - Added _pending_approvals registry, _track_approval_request() method, tracking in execute_streaming(), and validated parsing in _convert_input_to_chat_message()
  • python/packages/devui/tests/devui/test_approval_validation.py - 8 new security regression tests

Testing

  • All 127 existing tests pass (4 skipped, pre-existing integration skips)
  • 8 new tests cover: forged rejection, server-data enforcement, anti-replay, rejection of empty/non-string IDs, multiple independent approvals
  • E2E validated with Azure OpenAI (gpt-4.1): legitimate approval flow works, forged and replayed approvals are rejected
  • ruff check / ruff format / pyright all clean

The DevUI /v1/responses endpoint accepts function_approval_response content
without verifying that the request_id corresponds to a real pending approval
request issued by the server. This allows forged approval responses to
execute arbitrary tools with attacker-controlled arguments, bypassing
approval_mode='always_require'.

Changes:
- Track outgoing approval requests in a server-side registry
  (_pending_approvals) keyed by request_id
- Validate incoming approval responses against this registry; reject
  any response whose request_id was not issued by the server
- Use server-stored function_call data (tool name, arguments, call_id)
  instead of client-supplied data when constructing the approval response
- Consume request_ids on use (pop from registry) to prevent replay attacks

Tests:
- 8 new tests covering forged rejection, server-data enforcement,
  anti-replay, multiple independent approvals, and edge cases
@github-actions github-actions bot changed the title Fix vulnerability: Validate function approval responses in DevUI executor (CWE-863) Python: Fix vulnerability: Validate function approval responses in DevUI executor (CWE-863) Mar 10, 2026
@hgvfhsrtyvrt456vtg
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Vulnerability: DevUI executor accepts forged function_approval_response, bypasses approval_mode='always_require' (CWE-863)

2 participants