Skip to content

gh-137586: Open web browser with absolute path#137584

Open
fionn wants to merge 3 commits intopython:mainfrom
fionn:no-path-injection
Open

gh-137586: Open web browser with absolute path#137584
fionn wants to merge 3 commits intopython:mainfrom
fionn:no-path-injection

Conversation

@fionn
Copy link
Copy Markdown

@fionn fionn commented Aug 9, 2025

On macOS, web browsers are opened via popen calling osascript. 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.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Aug 9, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Aug 9, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@fionn fionn force-pushed the no-path-injection branch from 091f610 to 8700060 Compare August 9, 2025 08:59
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Aug 9, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Aug 9, 2025

Please open an issue first.

@fionn fionn changed the title Open web browser with absolute path gh-137586: Open web browser with absolute path Aug 9, 2025
@frenzymadness
Copy link
Copy Markdown
Contributor

Could you please add a news entry and also fix the osascript invocation in Lib/turtledemo/__main__.py?

@fionn fionn requested a review from terryjreedy as a code owner October 16, 2025 17:08
fionn added 3 commits October 17, 2025 01:09
On macOS, web browsers are opened via popen calling osascript. 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.
@fionn fionn force-pushed the no-path-injection branch from e9ed37f to 00682c5 Compare October 16, 2025 17:10
@fionn
Copy link
Copy Markdown
Author

fionn commented Oct 16, 2025

Yes, done. I wasn't sure if this was significant enough to warrant a news item.

@secengjeff
Copy link
Copy Markdown

#146439 takes a broader approach to this issue by replacing MacOSXOSAScript entirely with a new MacOSX class that uses /usr/bin/open via subprocess.run, rather than switching to /usr/bin/osascript. This eliminates the osascript dependency and the PATH-injection vector completely, and also addresses the related usability problem of webbrowser.open() failing silently on managed endpoints where osascript is blocked. It may be worth considering whether that PR supersedes this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants