Skip to content

Prevent submodules through indirect attribute access in LocalPythonExecutor #1375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

albertvillanova
Copy link
Member

Prevent submodules through indirect attribute access.

@albertvillanova albertvillanova changed the title Prevent submodules through indirect attribute access Prevent submodules through indirect attribute access in LocalPythonExecutor May 23, 2025
Copy link
Collaborator

@aymeric-roucher aymeric-roucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @albertvillanova !

@albertvillanova
Copy link
Member Author

@aymeric-roucher, I just realized that my proposed solution introduces a side effect: since static tools are decorated to enhance their safety, any output result that includes a reference to a static tool will actually use the decorated version instead.

For example:

code = "type_int = int"
result, _ = evaluate_python_code(code, {"int": int}, state={})
result is not int  # result is the decorated version of int

Do you think this could be problematic? Or would you consider this an acceptable edge case?

@aymeric-roucher
Copy link
Collaborator

@albertvillanova I don't see an issue, don't think it is a problem yet. Could you double check that it doesn't disturb current tool use (as in, run some tests with our current tools) ? If that's good, let's merge and we can fix possible issues later on, if they arise.

@albertvillanova albertvillanova merged commit 33a942e into huggingface:main May 26, 2025
3 checks passed
@albertvillanova albertvillanova deleted the fix-vuln-indirect-access branch May 26, 2025 07:24
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