FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-151695: Fix use-after-free of the curses screen encoding by serhiy-storchaka · Pull Request #151696 · python/cpython · GitHub

Repository navigation

gh-151695: Fix use-after-free of the curses screen encoding - #151696

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-screen-encoding-uaf
Jun 19, 2026
Merged

serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-screen-encoding-uaf

Conversation

Copy link
Copy Markdown
Member

The module-global curses_screen_encoding stored a borrowed pointer to the encoding string owned by the window object that the first initscr() call returns. That window object can be deallocated while unctrl() and ungetch() — which have no window of their own — still use the pointer to encode non-ASCII characters, so they end up reading freed memory.

This keeps a private copy of the encoding instead, refreshed on every initscr() and released when the module is torn down.

🤖 Generated with Claude Code

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Jun 19, 2026
serhiy-storchaka enabled auto-merge (squash) June 19, 2026 08:25
serhiy-storchaka merged commit 551f8e1 into python:main Jun 19, 2026
106 of 108 checks passed

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 551f8e16f8bb38a1e9c6df259a2a0969493de070 3.14

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 551f8e16f8bb38a1e9c6df259a2a0969493de070 3.13

bedevere-app Bot commented Jun 19, 2026

Copy link
Copy Markdown

GH-151703 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jun 19, 2026

bedevere-app Bot commented Jun 19, 2026

Copy link
Copy Markdown

GH-151706 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 19, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 19, 2026
…H-151696) (GH-151703)

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka deleted the curses-screen-encoding-uaf branch June 19, 2026 09:17
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jun 19, 2026
…ing (pythonGH-151696)

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 19, 2026
…H-151696) (GH-151706)

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 19, 2026
…H-151696) (GH-151706) (GH-151723)

The module-global screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)
(cherry picked from commit 7b55e9a)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
StanFromIreland removed the needs backport to 3.13 only security fixes label Jun 24, 2026
pyctrl pushed a commit to pyctrl/cpython that referenced this pull request Jul 5, 2026
…thonGH-151696)

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka removed their assignment Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL