Skip to content
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

Security risk of hidden pth files #113659

Open
serhiy-storchaka opened this issue Jan 2, 2024 · 0 comments
Open

Security risk of hidden pth files #113659

serhiy-storchaka opened this issue Jan 2, 2024 · 0 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes type-security A security issue

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jan 2, 2024

"pth files are evil." (Barry Warsaw, #78125)

There is a special kind of evilness:

  1. pth files allow to execute arbitrary Python code.
  2. pth files are executed automatically, unlike to normal py files which need explicit import or passing as argument to Python interpreter.
  3. Some files are hidden by default (in shell and file managers). In particularly dot-files on Posix.

In sum, it increases the risk of executing malicious code. When you receive a handful of files, you, as a cautious person, check their contents before executing. If Python source files are hidden, it's okay, because you saw that nothing suspicious is imported in the files that you execute. But pth files can be executed even if you do not see them and there are no references in visible files.

This issue was first discussed in comments in #113357.

The severity of this issue is not very large, because it requires user interaction to activate. But it increases the risk. I think we should forbid processing hidden pth files.

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-security A security issue 3.11 bug and security fixes 3.10 only security fixes 3.9 only security fixes 3.8 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes labels Jan 2, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes type-security A security issue
Projects
None yet
Development

No branches or pull requests

1 participant