Skip to content

[3.11] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931)#146364

Merged
ambv merged 1 commit intopython:3.11from
tomcruiseqi:backport-82a24a4-3.11
Mar 24, 2026
Merged

[3.11] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931)#146364
ambv merged 1 commit intopython:3.11from
tomcruiseqi:backport-82a24a4-3.11

Conversation

@tomcruiseqi
Copy link

@tomcruiseqi tomcruiseqi commented Mar 24, 2026

Copilot AI review requested due to automatic review settings March 24, 2026 09:40
@tomcruiseqi tomcruiseqi changed the title gh-143930: Reject leading dashes in webbrowser URLs [3.11] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) Mar 24, 2026
@bedevere-app bedevere-app bot added the type-security A security issue label Mar 24, 2026
@tomcruiseqi tomcruiseqi changed the title [3.11] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) [3.11] gh-143930: Reject leading dashes in webbrowser URLs Mar 24, 2026
@tomcruiseqi tomcruiseqi changed the title [3.11] gh-143930: Reject leading dashes in webbrowser URLs [3.11] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931) Mar 24, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Security hardening for webbrowser to prevent option-injection style issues when URLs are forwarded to external browser commands.

Changes:

  • Add URL validation that rejects inputs whose first non-whitespace character is -.
  • Invoke this validation across built-in browser controller implementations before launching/dispatching.
  • Add a regression test for the new rejection behavior and a Security NEWS entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Misc/NEWS.d/next/Security/2026-01-16-12-04-49.gh-issue-143930.zYC5x3.rst Documents the security behavior change for webbrowser.open().
Lib/webbrowser.py Introduces _check_url() and applies it to multiple controllers before executing browser actions.
Lib/test/test_webbrowser.py Adds a regression test ensuring dash-prefixed inputs are rejected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ambv ambv merged commit ceac1ef into python:3.11 Mar 24, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants