Skip to content

Use absolute paths when invoking built-in shell commands #137586

Closed

Description

@fionn

Bug report

Bug description:

On macOS, web browsers are opened via popen calling osascript.

osapipe = os.popen("osascript", "w")

However, if a user has a colliding osascript executable earlier in their PATH, this may fail or cause unwanted behaviour.

Depending on one's environment or level of paranoia, this may be considered a security vulnerability.

CPython versions tested on:

CPython main branch, 3.13

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added 2 commits that reference this issue on Mar 26, 2026
  2. merwok commented on Apr 6, 2026

    @merwok
    Member

    Can the title be changed?

    A shell builtin is a command like exec, help, fg or hash that the shell interprets by itself.

    Commands like which, xdg-open or open are programs, which have a path and are invoked in a sub-process.

    So it doesn’t make sense to talk about paths for shell builtins.

  3. added and removed
    type-bugAn unexpected behavior, bug, or error
    on Apr 6, 2026
  4. merwok commented on Apr 6, 2026

    @merwok
    Member

    Can you explain why this is a potential injection vector for Mac but not other operating systems? (browsers using UnixBrowser also use PATH search, not absolute paths)

  5. added a commit that references this issue on Apr 6, 2026
  6. added a commit that references this issue on Apr 6, 2026
  7. added 5 commits that reference this issue on Apr 6, 2026
  8. added 7 commits that reference this issue on Apr 6, 2026
  9. added 5 commits that reference this issue on Apr 7, 2026
  10. added 5 commits that reference this issue on Apr 23, 2026
  11. added a commit that references this issue on Apr 25, 2026
  12. added 2 commits that reference this issue on May 6, 2026
  13. added 2 commits that reference this issue on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macstdlibStandard Library Python modules in the Lib/ directorytype-securityA security issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions