Skip to content

fix(security): upgrade LocalCommandLineCodeExecutor warning to DeprecationWarning#7467

Open
xr843 wants to merge 1 commit intomicrosoft:mainfrom
xr843:fix/local-executor-sandbox-warning
Open

fix(security): upgrade LocalCommandLineCodeExecutor warning to DeprecationWarning#7467
xr843 wants to merge 1 commit intomicrosoft:mainfrom
xr843:fix/local-executor-sandbox-warning

Conversation

@xr843
Copy link
Copy Markdown

@xr843 xr843 commented Mar 26, 2026

Summary

Fixes #7462

The LocalCommandLineCodeExecutor currently emits a UserWarning at construction time to alert developers about unsandboxed code execution. However, UserWarning is easily suppressed in production configurations (e.g., python -W ignore, logging pipelines that filter warnings), which means the security message can be silently swallowed.

This PR makes the warning harder to accidentally suppress by:

  • Upgrading from UserWarning to DeprecationWarning — visible by default in __main__ contexts and not filtered by standard production warning configurations
  • Adding logger.warning() call — ensures the security message is visible in logging pipelines that don't capture Python warnings (dual-channel notification)
  • Improving the warning message — clearer description of the risk with a link to the code executors documentation

Changes

  • python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py:
    • Added module-level logger
    • Changed warning type from UserWarning to DeprecationWarning
    • Added logger.warning() for logging pipeline visibility
    • Improved warning message text with documentation link
  • python/packages/autogen-ext/tests/code_executors/test_commandline_code_executor.py:
    • Added test for the new DeprecationWarning behavior

Backward Compatibility

This change is fully backward compatible:

  • No API changes — constructor signature unchanged
  • No behavioral changes — code execution works identically
  • Warning is still emitted (just with a different type that is harder to suppress)
  • Existing code that catches UserWarning broadly will still work since DeprecationWarning is a separate category

Test plan

  • Existing tests should pass (warning type change does not affect restart test which uses a separate UserWarning)
  • New test verifies DeprecationWarning is emitted on construction
  • Manual verification: instantiate LocalCommandLineCodeExecutor and confirm warning is visible

🤖 Generated with Claude Code

…ationWarning

Addresses microsoft#7462 - The existing UserWarning for unsandboxed code execution
is easily suppressed in production configurations (e.g., `-W ignore`).

Changes:
- Upgrade warning from UserWarning to DeprecationWarning, which is visible
  by default in __main__ contexts and harder to accidentally silence
- Add logger.warning() call so the security message is visible in logging
  pipelines that don't capture Python warnings
- Improve warning message with clearer description of the risk and link
  to documentation
- Add test for the new DeprecationWarning behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xr843
Copy link
Copy Markdown
Author

xr843 commented Mar 28, 2026

@microsoft-github-policy-service agree

@xr843
Copy link
Copy Markdown
Author

xr843 commented Mar 28, 2026

Hi team, just a gentle ping on this PR. CLA has been signed and all CI checks are passing. Happy to make any adjustments if needed. Thanks for your time!

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.

[Security] LocalCommandLineCodeExecutor executes LLM-generated code without sandboxing

1 participant