Skip to content

Restrict builtins in AssertionEvaluator eval fallback path#12

Closed
Copilot wants to merge 2 commits intocodemode_driven_generationfrom
copilot/sub-pr-10-again
Closed

Restrict builtins in AssertionEvaluator eval fallback path#12
Copilot wants to merge 2 commits intocodemode_driven_generationfrom
copilot/sub-pr-10-again

Conversation

Copy link

Copilot AI commented Mar 19, 2026

The AssertionEvaluator fallback eval passed inputs directly as globals/locals, leaving __builtins__ unrestricted and reintroducing arbitrary code execution that the restricted-builtins model was meant to prevent.

Changes

  • Fallback path hardened: replaces eval(self.condition, inputs, inputs) with a restricted env using SAFE_ASSERTION_BUILTINS, matching the primary _eval_assertion_restricted path
  • __builtins__ override prevention: both primary and fallback paths now use {**inputs, "__builtins__": SAFE_ASSERTION_BUILTINS} so a caller-controlled inputs key cannot shadow the restriction
  • pow added to SAFE_ASSERTION_BUILTINS: safe math builtin previously only reachable via the unrestricted fallback; making it explicit maintains backward compatibility
# Before — full builtins exposed in fallback
eval(self.condition, inputs, inputs)

# After — same restriction as primary path
fallback_env = {**inputs, "__builtins__": SAFE_ASSERTION_BUILTINS}
eval(self.condition, fallback_env, fallback_env)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: fswair <62549656+fswair@users.noreply.github.com>
@fswair fswair closed this Mar 19, 2026
Copilot AI changed the title [WIP] [WIP] Address feedback on builtins restriction for eval fallback Restrict builtins in AssertionEvaluator eval fallback path Mar 19, 2026
Copilot AI requested a review from fswair March 19, 2026 17:07
Copilot stopped work on behalf of fswair due to an error March 19, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants