Skip to content

Conversation

aymeric-roucher
Copy link
Collaborator

@aymeric-roucher aymeric-roucher commented Mar 29, 2025

@albertvillanova this PR re-adds authorization for submodules whose top module was allowed, like authorizing access to numpy.random if numpy was authorized. We need to be careful to avoid this potentially allowing harmful submodules of authorized modules, but tests/test_local_python_executor.py::TestLocalPythonExecutorSecurity::test_vulnerability_via_submodules should catch this vulnearbility?

Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution and addressing this problematic issue.

Just for the record:

  • Many packages include dangerous submodules
  • Before we restricted some dangerous submodules, but the blacklist was never (and will never be) fully comprehensive
  • To improve security, we implemented a different approach: use a deny-by-default policy and allow the user to whitelist specific submodules that they consider safe for their use case, rather than trying to maintain an incomplete blacklist

Now you propose to revert to the previous approach:

  • I think we should inform the security team: previously reported and fixed vulnerabilities will be exploitable again

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@aymeric-roucher aymeric-roucher merged commit 83e2ce5 into main Mar 31, 2025
5 checks passed
@albertvillanova albertvillanova deleted the fix-submodule-imports branch March 31, 2025 11:00
@thiswillbeyourgithub
Copy link

Just to add my 2 cents: if the choice is to either 1. Extrapolate user imports or 2. Don't extrapolate but allow to specify each import, I am humbly suggesting 3. Don't extrapolate but allow regex to specify include and exclude imports.

Something like:
additional_authorized_imports_include_regex=["numpy(\..*)?"] to allow numpy and its submodule
additional_authorized_imports_exclude_regex=["numpy.random(\..*)?"] ... Except np.random and its submodules

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.

4 participants