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 — gh-42400: Fix buffer overflow in _Py_wrealpath for long paths by ashm-dev · Pull Request #141529 · python/cpython

Conversation

@ashm-dev

@ashm-dev ashm-dev commented Nov 13, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes buffer overflow (CVE-2006-1542) in _Py_wrealpath() when handling paths longer than MAXPATHLEN (4096 bytes).

Changed realpath(path, buffer) to realpath(path, NULL) for dynamic allocation.

Closes #42400

  • Issue: Avoid using unsafe realpath #42400

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added the awaiting review label Nov 13, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 13, 2025
Avoid using unsafe realpath #42400
Closed
@ashm-dev
pythongh-42400: Fix buffer overflow in _Py_wrealpath for long paths
3255a3d
@ashm-dev
ashm-dev force-pushed the fix/cve-realpath branch from 1424245 to 3255a3d Compare November 13, 2025 19:41
@ashm-dev
pythongh-42400: Fix buffer overflow in _Py_wrealpath for long paths
bb4af8a
@ashm-dev
ashm-dev force-pushed the fix/cve-realpath branch from 52f60a5 to bb4af8a Compare November 13, 2025 20:36
ashm-dev added 2 commits November 13, 2025 23:45
@ashm-dev
fix
a12ee2d
@ashm-dev
Use os.samefile in realpath symlink test
238ff0e
Allow platforms where realpath returns different canonical paths (e.g.
Android). Verify resolution with os.samefile and fall back to a length
check if samefile is unavailable.
@ashm-dev

ashm-dev commented Nov 13, 2025

Copy link
Copy Markdown
Contributor Author

I don't think the errors in the UBSAN test are related to this fix, as they occur for a completely different reason and generally in import tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev

ashm-dev commented Nov 14, 2025

Copy link
Copy Markdown
Contributor Author

@vstinner Could you please review this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Nov 14, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Security/2025-11-13-22-31-56.gh-issue-42400.pqB5Kq.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_fileutils.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

ashm-dev and others added 3 commits November 14, 2025 14:04
@ashm-dev
Merge remote-tracking branch 'upstream/main' into fix/cve-realpath
d8a437a
@ashm-dev
remove tests
88368ec
@ashm-dev @vstinner
Update Misc/NEWS.d/next/Security/2025-11-13-22-31-56.gh-issue-42400.p…
1cf6fde
…qB5Kq.rst

Co-authored-by: Victor Stinner <[email protected]>
@ashm-dev
ashm-dev requested a review from vstinner November 14, 2025 11:08
@vstinner
Merge branch 'main' into fix/cve-realpath
f882e26
@vstinner

vstinner commented Nov 14, 2025

Copy link
Copy Markdown
Member

I updated the PR to retrieve the fix for the UBSan CI.

ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 17, 2025
@bedevere-bot

bedevere-bot commented Nov 17, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit f882e26 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F141529%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 17, 2025
@vstinner

vstinner commented Nov 17, 2025

Copy link
Copy Markdown
Member

realpath(path, NULL) seems to be a recent feature. Let me check on buildbots if it's supported by all platforms supported by Python.

ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit daafacf into python:main Nov 18, 2025
112 of 118 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Nov 18, 2025
@vstinner

vstinner commented Nov 18, 2025

Copy link
Copy Markdown
Member

Change merged, thanks.

The change passed on our fleet of stable buildbots.

Even if the change was documented in the Security category, I don't think that it's worth it to backport it to stable branches (yet). I'm afraid of breaking the Python build on some weird platforms where realpath(path, NULL) is not supported. So I prefer to make the change only in the main branch for now.

ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev
ashm-dev deleted the fix/cve-realpath branch November 18, 2025 17:35
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@ashm-dev @vstinner @StanFromIreland
pythongh-42400: Fix buffer overflow in _Py_wrealpath() for very long …
05021ff
…paths (python#141529)

Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner Awaiting requested review from vstinner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Avoid using unsafe realpath

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ashm-dev @vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.