GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use absolute paths when invoking built-in shell commands · Issue #137586 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Use absolute paths when invoking built-in shell commands#137586
Copy link
Labels
OS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue

Description

@fionn
fionn
opened on Aug 9, 2025
Issue body actions

Bug report

Bug description:

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

cpython/Lib/webbrowser.py

Line 647 in 3964f97

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

  • gh-137586: Open external osascript program with absolute path #137584
  • gh-137586: Replace 'osascript' with 'open' on macOS in webbrowser #146439
  • [3.14] gh-137586: Open external osascript program with absolute path (GH-137584) #148173
  • [3.13] gh-137586: Open external osascript program with absolute path (GH-137584) #148174
  • [3.12] gh-137586: Open external osascript program with absolute path (GH-137584) #148175
  • [3.11] gh-137586: Open external osascript program with absolute path (GH-137584) #148176
  • [3.10] gh-137586: Open external osascript program with absolute path (GH-137584) #148177

Activity

Next
  1. fionn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Aug 9, 2025
  2. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    OS-mac
    on Aug 9, 2025
  3. picnixz commented on Aug 9, 2025

    @picnixz
    picnixz
    on Aug 9, 2025
    Member
    More actions

    Note that there's also an occurrence in Lib/turtledemo/__init__.py which uses subprocess.run instead. There is also a similar occurrence in Lib/platform.py where we directly use file instead of /usr/bin/file and uname instead of /usr/bin/uname. Finally, there's another occurrence in webbrowser.py that uses xdg-settings directly.

    Unless I'm mistaken, taking control over the PATH environment variable of another user is quite complex, if not impossible most of the time if we don't have enough privilieges or if the PATH is already misconfigured. Therefore, I wouldn't really count it as a security issue as the attack surface is quite small. However, I think it's better if we use full paths instead, especially for built-in commands.

    It's quite hard to spot all places where we don't use an absolute path though.

    Reacted by Serhiy Storchaka, Fionn, Geoffrey Thomas and Lumír 'Frenzy' Balhar
  4. picnixz
    removed
    OS-mac
    on Aug 9, 2025
  5. picnixz
    changed the title [-]Use absolute path when calling osascript[/-] [+]Use absolute paths when invoking built-in shell commands[/+] on Aug 9, 2025
  6. terryjreedy
    added
    OS-mac
    on Oct 17, 2025
  7. terryjreedy commented on Oct 17, 2025

    @terryjreedy
    terryjreedy
    on Oct 17, 2025
    Member
    More actions

    This is about a simple change of the osascript path on mac for webbrowser, its test, and in turtledemo.
    @ronaldoussoren, @ned-deily can one of you verify/review the few lines of changes in the PR?

  8. secengjeff
    added 3 commits that reference this issue on Mar 26, 2026

    pythongh-137586: Add MacOSX browser class using /usr/bin/open, deprec…

    00fa6c7

    pythongh-137586: Add tests for MacOSX browser class and MacOSXOSAScri…

    f697cd5

    pythongh-137586: Document MacOSXOSAScript deprecation in webbrowser docs

    7781033
  9. secengjeff commented on Mar 26, 2026

    @secengjeff
    secengjeff
    on Mar 26, 2026
    Contributor
    More actions

    #146439 addresses this by replacing MacOSXOSAScript entirely with a new MacOSX class that uses /usr/bin/open via subprocess.run. This eliminates the osascript dependency rather than patching the path, which also resolves the broader usability problem of webbrowser.open() failing silently on managed endpoints where osascript is blocked.

    Reacted by Fionn and Jakub Kuczys
  10. secengjeff
    added 3 commits that reference this issue on Mar 26, 2026

    pythongh-137586: Add NEWS entries for MacOSX webbrowser change

    6066221

    pythongh-137586: Fix NEWS entry class references with ! prefix to sup…

    d54293f

    pythongh-137586: Fix MacOSXOSAScriptTest for MacOSX registration change

    080197e
  11. 22 remaining items

  12. hugovk
    added 3 commits that reference this issue on Apr 7, 2026

    [3.12] gh-137586: Open external osascript program with absolute path (G…

    20b4393

    [3.11] gh-137586: Open external osascript program with absolute path (G…

    0ec71cd

    [3.10] gh-137586: Open external osascript program with absolute path (G…

    e70ff77
  13. secengjeff
    added 5 commits that reference this issue on Apr 23, 2026

    pythongh-137586: Fix MacOS plist fallback, builtins.open shadow, add …

    a6d76d6

    Merge branch 'main' into pythongh-137586-macosx-open

    5a4fdad

    pythongh-137586: Address hugovk review comments

    de9ec77

    pythongh-137586: Address hugovk post-approval concerns

    f874d67

    pythongh-137586: Fix Sphinx ref.class warnings in whatsnew/3.15.rst

    3b390bb
  14. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-137586: Open external osascript program with absolute path (p…

    42984a3
  15. hugovk
    added 2 commits that reference this issue on May 6, 2026

    Merge branch 'main' into pythongh-137586-macosx-open

    21b5499

    gh-137586: Replace 'osascript' with 'open' on macOS in webbrowser (#1…

    aeb02ac
  16. hugovk
    closed this as completedon May 6, 2026
  17. gpshead
    added 2 commits that reference this issue on May 8, 2026

    gh-149496: Fix MacOSTest.test_default regression when BROWSER env var…

    45c47d2

    [3.15] gh-149496: Fix MacOSTest.test_default regression when BROWSER …

    e3fbcc3
  18. icanhasmath
    added a commit that references this issue on Oct 28, 2026

    [3.10] pythongh-137586: Open external osascript program with absolute…

    37f0522
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/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.