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 — Security and usability improvement for webbrowser.open() on macOS: Replace osascript with /usr/bin/open · Issue #148472 · python/cpython

Security and usability improvement for webbrowser.open() on macOS: Replace osascript with /usr/bin/open #148472

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Security and usability improvement for webbrowser.open() on macOS: Replace osascript with /usr/bin/open#148472
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@secengjeff
secengjeff
opened on Apr 12, 2026
Issue body actions

Feature or enhancement

Proposal:

We should modernize the macOS implementation of webbrowser.open() by replacing the legacy osascript-based code with Apple’s purpose-built /usr/bin/open utility.

Current Issues

The existing MacOSXOSAScript class builds a short AppleScript and executes it via osascript.

Usability Concerns
On managed enterprise Macs (using MDM/EDR tools such as CrowdStrike, SentinelOne, Jamf, or Santa), osascript is often monitored or restricted due to its abuse in malware campaigns. When this happens, webbrowser.open() fails silently or with unclear errors, breaking a simple, commonly used API for developers and applications.

Security Risk
osascript is a general-purpose scripting interpreter and a classic Living-Off-the-Land binary (LOOBin). It was part of the macOS payload in the recent Axios npm supply-chain attack (March 31, 2026). Even after the PATH-lookup fix, it still requires constructing and executing AppleScript, a more powerful mechanism than needed just to open a URL. This increases the stdlib attack surface and ties Python to a binary that security teams frequently treat with caution.

Proposed Change

PR #146439 implements a cleaner alternative:

  • Introduces a new MacOSX class that uses /usr/bin/open (absolute path) via subprocess.run with a safe argument list.
  • Uses open -b <bundle-id> (e.g., com.google.Chrome) for known browsers to explicitly target the intended application.
  • Safely handles non-HTTP(S) URLs to avoid unintended OS file-handler behavior.
  • Completely removes AppleScript construction.
  • Deprecates the old MacOSXOSAScript class with a clear DeprecationWarning.

The change maintains full backward compatibility (including named browser support) and simplifies the code.

Why This Is Worth Doing

This is a low-risk improvement that:

  • Improves reliability for enterprise and security-conscious users.
  • Reduces the security footprint by eliminating dependency on a general-purpose scripting tool.
  • Aligns the stdlib with modern macOS practices.

Next Steps

  • Review and merge PR gh-137586: Replace 'osascript' with 'open' on macOS in webbrowser #146439.
  • Target removal of the deprecated MacOSXOSAScript class in Python 3.15 or 3.16.
  • Update documentation to mention the improved security and enterprise compatibility.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/security-and-usability-improvement-for-webbrowser-open-on-macos-replace-osascript-with-usr-bin-open/106943

Activity

  1. secengjeff
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 12, 2026
  2. picnixz
    closed this as not plannedon Apr 12, 2026
  3. picnixz commented on Apr 12, 2026

    @picnixz
    picnixz
    on Apr 12, 2026
    Member
    More actions

    The discussion is empty, wait for a consensus to be reached.

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

    type-featureA feature request or enhancementA feature request or enhancement

    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.