8000 Forbid access to all dunder attributes by default by albertvillanova · Pull Request #979 · huggingface/smolagents · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Forbid access to all dunder attributes by default #979

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

Conversation

albertvillanova
Copy link
Member
@albertvillanova albertvillanova commented Mar 14, 2025

Forbid access to all dunder attributes by default.

This PR enhances security by forbidding access to all dunder attributes by default. By blocking access to attributes that start and end with double underscores (e.g. __class__), we help to avoid potential exploitation via reflective or introspective code.

  • This update restricts direct attribute access (e.g. a.__class__).
  • Note that indirect access (e.g. using getattr(a, "__class__")) was already forbidden unless explicitly authorizing the getattr function.

A comprehensive suite of tests has been added to ensure that any attempt to access these sensitive attributes triggers an appropriate error.

This measure reduces the attack surface while preserving the legitimate functionality of our Python code evaluation.

@albertvillanova albertvillanova changed the title Forbid all dunder attributes by default Forbid access to all dunder attributes by default Mar 14, 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.

Thank you @albertvillanova !

@aymeric-roucher aymeric-roucher merged commit ba7baee into huggingface:main Mar 14, 2025
3 checks passed
@aymeric-roucher
Copy link
Collaborator

Complemented in this PR by modifying getattr function to disable access to dunder.

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
0