Skip to content

Python: fix(devui): validate function approval responses in DevUI executor - #4598

Merged
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
hgvfhsrtyvrt456vtg:fix/cwe863-devui-approval-bypass
Mar 12, 2026
Merged

Python: fix(devui): validate function approval responses in DevUI executor#4598
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
hgvfhsrtyvrt456vtg:fix/cwe863-devui-approval-bypass

Conversation

@hgvfhsrtyvrt456vtg

@hgvfhsrtyvrt456vtg Tushar Mudi (hgvfhsrtyvrt456vtg) commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4597 - The DevUI executor accepts potentially forged function_approval_response content, allowing arbitrary tool execution without human approval.

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 can allow unauthenticated arbitrary tool 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
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the python Usage: [Issues, PRs], Target: Python label Mar 10, 2026
@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
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL23586266388% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
5143 20 💤 0 ❌ 0 🔥 1m 20s ⏱️

@moonbox3 Evan Mattson (moonbox3) changed the title Python: Fix vulnerability: Validate function approval responses in DevUI executor (CWE-863) Python: fix(devui): validate function approval responses in DevUI executor Mar 12, 2026
@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Mar 12, 2026
Merged via the queue into microsoft:main with commit 378bee5 Mar 12, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

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)

4 participants