Restrict code execution scope and enforce import whitelist#196
Merged
Restrict code execution scope and enforce import whitelist#196
Conversation
1619187 to
30326bc
Compare
Collaborator
|
yea that's a good one. Thanks! |
pancacake
added a commit
that referenced
this pull request
Mar 12, 2026
The eval version of code_executor.py removed DEFAULT_SAFE_IMPORTS which is referenced by research_pipeline.py (from PR #196). Re-add the constant and apply it as default when no whitelist is provided. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed the code execution tool was letting LLM-generated scripts roam around the project root and access all environment variables. To fix this, I restricted the workspace to the user data directory and stripped sensitive keys from the environment before execution.
Enforcing a default whitelist for imports via
ImportGuardensures that only safe libraries like numpy or matplotlib are used, even if the caller forgets to specify constraints. I've also updated the solver and research pipelines to leverage these restricted settings by default.Confirmed that core functionalities like plotting and calculations still work fine under these tighter constraints. This should stop any potential RCE from escaping the sandbox or exfiltrating API keys.