Skip to content

Security risk of hidden pth files #113659

Closed
Closed
@serhiy-storchaka

Description

@serhiy-storchaka

"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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixes3.13bugs and security fixes3.8 (EOL)end of life3.9only security fixestype-securityA security issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions