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-144370: Disallow usage of control characters in status in ``Lib/wsgiref/handlers.py`` for security by benediktjohannes · Pull Request #144371 · python/cpython

Conversation

@benediktjohannes

@benediktjohannes benediktjohannes commented Jan 31, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This PR is opened as public as the primary described CVE is already publicated and this only contains one certain point that has to be changed in code in Python and refers to issue #144370 (gh-144370).

In Lib/wsgiref/handlers.py at 260 (def _convert_string_type(self, value, title):) it is necessary to add the same fix as in #143916 requested as well (credits to @sethmlarson 👍). This references #143917 and #144118 and already includes the latest fix for the inclusion of HTAB, additions to this in form of tests will automatically be added by merging #144118.

There are some differences to wsgiref.headers.Headers that I made because I chose the default status of "name" to be "True" instead of false as "True" includes one more disallowed character for safety in future use cases if not defined otherwise, but I also added "name=True" even if not necessary in use cases just for safety for another case (if the default case was changed in order to produce similarity to wsgiref.headers.Headers while I'd recommend to change wsgiref.headers.Headers). I've also made an addition to the raised "ValueError" including "values" (without a further description of the very exact in- and exclusions like HTAB because this doesn't seem to be user-sided relevant to me) and I've used a slightly shorter internal form for the variables (which can be changed if wanted, but it's just style).

Important note: I was / am not quite sure about these changes as they were not tested, but I'm highly confident that this should be correct as it (mostly) bases on changes which were already made in other PRs (or at least in one other PR because this is the only merged one (but this also refers to a "non-merged" PR, so has to be concretized in that way)). And another important aspect is that I was not quite sure about the "status" (whether my classification is correct here as a "non-name value" when considering the handling of the characters, so please correct me if I'm mistaken (and I wasn't quite sure as well at the question whether potentially there should be added some different disallowed characters for this or some disallowed be removed, so please correct me if I'm mistaken)). Please also correct me if I'm mistaken in general anywhere in this PR (maybe this isn't even necessary for this case and I'm completely mistaken because this wasn't tested, but I'm pretty confident just from looking at the code).

Sorry, something went wrong.

Uh oh!

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

All reactions
@benediktjohannes
Disallow usage of control characters in status, headers and values fo…
3b0169b
…r security
@bedevere-app bedevere-app Bot mentioned this pull request Jan 31, 2026
[security] Disallow usage of control characters in status, headers and values for security in Lib/wsgiref/handlers.py #144370
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Jan 31, 2026
benediktjohannes and others added 2 commits January 31, 2026 22:48
@benediktjohannes
Add missing import of "re"
9414df2
@blurb-it
📜🤖 Added by blurb_it.
49ddbca
@benediktjohannes

benediktjohannes commented Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

Important note: This PR needs backport to 3.10, 3.11, 3.12, 3.13 and 3.14 please, thanks! 👍 (I'll probably add these tomorrow if there are no concerns.)

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

@gpshead or @StanFromIreland / @ZeroIntensity please review, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 31, 2026

Copy link
Copy Markdown
Member

What is different from #144118?

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz picnixz closed this Jan 31, 2026
@picnixz

picnixz commented Jan 31, 2026

Copy link
Copy Markdown
Member

I would suggest that you directly comment on Seth's PR instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

@picnixz I guess that this was a misunderstanding, this PR is about a completely different thing that is changes. This is not a duplicate of the other PR because the other one is about adding HTAB again to Lib/wsgiref/headers.py, but this one is about Lib/wsgiref/handlers.py, not headers.py. This is something completely different because the other one only adds one character to be allowed, but this one reguards disallowing several characters in handlers.py (and not headers.py) which wasn‘t mentioned at all in the other PR because this concerns completely different aspects like status and some changes in debug mode in handlers.py and not headers.py. Please reopen. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

@picnixz I guess, I know why this seemed to be a duplicate as I described the „differences“ to the other PR and then you thought that this was about some changes that I suggested for the other PR, but this is not what this PR is about because this is about something completely different in another location, so please reopen. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 1, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

And I think that is would not be a very good idea if we combined these changes in another PR because the first one was already merged two weeks ago and the other one is only about adding allowed phrases again while this one is about the opposit (disallowing phrases) with the only thing in common that this one does not disallow one thing which will be added in the new PR again, but both other PRs concern another location which makes this not even a duplication in that way, so please reopen. Thanks!

cc @gpshead @sethmlarson @StanFromIreland @ZeroIntensity

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead gpshead reopened this Feb 1, 2026
@benediktjohannes

benediktjohannes commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you very much!

All reactions

Sorry, something went wrong.

Uh oh!

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

vstinner
vstinner reviewed Feb 3, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You should write tests for theses changes.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/wsgiref/handlers.py Resolved

Uh oh!

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

Comment thread Lib/wsgiref/handlers.py Resolved

Uh oh!

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

Comment thread Lib/wsgiref/handlers.py Resolved

Uh oh!

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

@vstinner vstinner mentioned this pull request Feb 3, 2026
gh-143916: Allow HTAB in wsgiref header values #144118
Merged
@benediktjohannes @vstinner
Update Lib/wsgiref/handlers.py
5dd863b
Co-authored-by: Victor Stinner <[email protected]>
@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

Hi @vstinner thank you very much for your review! I really like your suggestions and I'll make some commits in order to get them in the PR soon, thank you very much!

All reactions

Sorry, something went wrong.

Uh oh!

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

benediktjohannes and others added 2 commits February 4, 2026 16:47
@benediktjohannes @vstinner
Update Lib/wsgiref/handlers.py
3daaa72
Co-authored-by: Victor Stinner <[email protected]>
@benediktjohannes
Update handlers.py
8b149df
@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

(Added the "re" again because it's included in vstinner's regex and also in sethmlarson's PR so if this will be used in both cases then it's consistent in that way and it would take too much time to change this there as well and the suggestions by seth and vstinner were both with the "re", so I've added it)

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm not quite sure about the status whether it should be handled as a value or a name, so please correct me if I'm mistaken inthis case (or even none of both? but I don't think that)

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

You should write tests for theses changes.

Tests are basically already included by seth's PR, but I can of course add similar ones to handlers as well.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Feb 4, 2026

Copy link
Copy Markdown
Member

Tests are basically already included by seth's PR, but I can of course add similar ones to handlers as well.

Please add new tests on handlers.

benediktjohannes 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.

@benediktjohannes
Update test_wsgiref.py
010fd50
@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

@vstinner please re-review, thanks! (I'm still not quite sure about it because I haven't tested it (also the tests are not tested) or is this automatically done by the lint check?)

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

(but even if this is done by the lint check automatically, I'm not quite sure about the handling of the status)

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

and thanks for the review by the way 👍

All reactions

Sorry, something went wrong.

Uh oh!

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

@benediktjohannes

benediktjohannes commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

Ahh, this seems actually to be checked automatically by the Tests based on what I've seen! Nice! But I'm not quite sure about the correct classification of the status nevertheless, so please have a look there, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app

bedevere-app Bot commented Mar 6, 2026

Copy link
Copy Markdown

GH-145585 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Mar 6, 2026
@bedevere-app

bedevere-app Bot commented Mar 6, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Mar 6, 2026
@benediktjohannes

benediktjohannes commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Mar 6, 2026

Copy link
Copy Markdown
Member

I merged the change and backported it to 3.13 and 3.14 branches. Thanks for the fix.

I'm not sure about backporting the change to 3.10, 3.11 and 3.12 security branches.

benediktjohannes 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 added a commit that referenced this pull request Mar 6, 2026
@miss-islington @benediktjohannes
@blurb-it @vstinner
[3.13] gh-144370: Disallow usage of control characters in status in w…
5db0177
…sgiref.handlers for security (GH-144371) (#145585)

gh-144370: Disallow usage of control characters in status in wsgiref.handlers for security (GH-144371)

Disallow usage of control characters in status in wsgiref.handlers
to prevent HTTP header injections.
(cherry picked from commit d931725)

Co-authored-by: Benedikt Johannes <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this pull request Mar 6, 2026
@miss-islington @benediktjohannes
@blurb-it @vstinner
[3.14] gh-144370: Disallow usage of control characters in status in w…
89b69db
…sgiref.handlers for security (GH-144371) (#145586)

gh-144370: Disallow usage of control characters in status in wsgiref.handlers for security (GH-144371)

Disallow usage of control characters in status in wsgiref.handlers
to prevent HTTP header injections.
(cherry picked from commit d931725)

Co-authored-by: Benedikt Johannes <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
@vstinner vstinner added needs backport to 3.10 needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Mar 9, 2026
@miss-islington-app

miss-islington-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

Thanks @benediktjohannes for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

Thanks @benediktjohannes for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

Thanks @benediktjohannes for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

Sorry, @benediktjohannes and @vstinner, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d931725bc850cd096f6703bc285e885f1e015f05 3.10
All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app miss-islington-app Bot assigned vstinner Mar 9, 2026
@miss-islington-app

miss-islington-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

Sorry, @benediktjohannes and @vstinner, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d931725bc850cd096f6703bc285e885f1e015f05 3.11
All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 9, 2026
@benediktjohannes @blurb-it
@vstinner @miss-islington
pythongh-144370: Disallow usage of control characters in status in ws…
20293be
…giref.handlers for security (pythonGH-144371)

Disallow usage of control characters in status in wsgiref.handlers
to prevent HTTP header injections.
(cherry picked from commit d931725)

Co-authored-by: Benedikt Johannes <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-app

bedevere-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

GH-145671 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 9, 2026
@bedevere-app

bedevere-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

GH-145672 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Mar 9, 2026
@bedevere-app

bedevere-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

GH-145673 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.10 label Mar 9, 2026
@vstinner

vstinner commented Mar 9, 2026

Copy link
Copy Markdown
Member

The _validate_status() method was added to Python 3.12. I had to backport the change manually to 3.10 and 3.11.

All reactions

Sorry, something went wrong.

Uh oh!

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

ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@benediktjohannes @blurb-it
@vstinner @ljfp
pythongh-144370: Disallow usage of control characters in status in ws…
6c37ab9
…giref.handlers for security (python#144371)

Disallow usage of control characters in status in wsgiref.handlers
to prevent HTTP header injections.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
pablogsal pushed a commit that referenced this pull request May 17, 2026
@vstinner
[3.10] gh-144370: Disallow usage of control characters in status in w…
10cf7e2
…sgiref.handlers for security (#144371) (#145673)
pablogsal pushed a commit that referenced this pull request May 17, 2026
@vstinner
[3.11] gh-144370: Disallow usage of control characters in status in w…
3b80905
…sgiref.handlers for security (#144371) (#145672)
Yhg1s pushed a commit that referenced this pull request Aug 4, 2026
@miss-islington @benediktjohannes
@blurb-it @vstinner @StanFromIreland
[3.12] gh-144370: Disallow usage of control characters in status in w…
d45067d
…sgiref.handlers for security (GH-144371) (#145671)

gh-144370: Disallow usage of control characters in status in wsgiref.handlers for security (GH-144371)

Disallow usage of control characters in status in wsgiref.handlers
to prevent HTTP header injections.
(cherry picked from commit d931725)

Co-authored-by: Benedikt Johannes <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
icanhasmath pushed a commit to ActiveState/cpython that referenced this pull request Oct 28, 2026
@vstinner @icanhasmath
[3.10] pythongh-144370: Disallow usage of control characters in statu…
f1a3603
…s in wsgiref.handlers for security (python#144371) (python#145673)

(cherry picked from commit 10cf7e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes

Uh oh!

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

Assignees

@vstinner vstinner

Labels

type-security A security issue

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

5 participants

@benediktjohannes @picnixz @vstinner @sethmlarson @gpshead
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 01402520 — 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.