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 — [3.12] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) by encukou · Pull Request #122599 · python/cpython

Conversation

@encukou

@encukou encukou commented Aug 2, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Encode header parts that contain newlines

Per RFC 2047:

[...] these encoding schemes allow the
encoding of arbitrary octet values, mail readers that implement this
decoding should also ensure that display of the decoded data on the
recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

  • Verify that email headers are well-formed

This should fail for custom fold() implementations that aren't careful
about newlines.

Co-authored-by: Bas Bloemsaat [email protected]
Co-authored-by: Serhiy Storchaka [email protected]
(cherry picked from commit 0976339)


📚 Documentation preview 📚: https://cpython-previews--122599.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
encukou and others added 2 commits August 2, 2024 11:26
@encukou @basbloemsaat @serhiy-storchaka
pythongh-121650: Encode newlines in headers, and verify headers are s…
e58aec9
…ound (pythonGH-122233)

- Encode header parts that contain newlines

Per RFC 2047:

> [...] these encoding schemes allow the
> encoding of arbitrary octet values, mail readers that implement this
> decoding should also ensure that display of the decoded data on the
> recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

- Verify that email headers are well-formed

This should fail for custom fold() implementations that aren't careful
about newlines.

Co-authored-by: Bas Bloemsaat <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 0976339)
@encukou
Document changes as made in 3.12.5
7e3b041
@encukou
encukou requested a review from a team as a code owner August 2, 2024 09:30
This was referenced Aug 2, 2024
email.policy.default - gotcha with re-using parsed headers with embedded newlines #121650
Closed
gh-121650: Encode newlines in headers, and verify headers are sound #122233
Merged
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 2, 2024
@encukou encukou added the release-blocker label Aug 3, 2024
@encukou

encukou commented Aug 3, 2024

Copy link
Copy Markdown
Member Author

Marking this for consideration as a release blocker.
IMO, this should go into 3.12.5. Ideally it would be merged after the 3.13 backport, which requires review.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Yhg1s
Yhg1s merged commit 4766d12 into python:3.12 Aug 6, 2024
@bedevere-app bedevere-app Bot removed the awaiting core review label Aug 6, 2024
@encukou
encukou deleted the backport-0976339-3.12 branch August 7, 2024 12:00
@smoser smoser mentioned this pull request Aug 8, 2024
python-3.12 - Mark CVE-2024-6923 as fixed in 3.12.5 wolfi-dev/advisories#7191
Merged
smoser added a commit to smoser/advisories that referenced this pull request Aug 8, 2024
@smoser
python-3.12 - Mark CVE-2024-6923 as fixed in 3.12.5
d461185
The fix for this issue was included in upstream release of 3.12.5.
python/cpython#122599
github-merge-queue Bot pushed a commit to wolfi-dev/advisories that referenced this pull request Aug 8, 2024
@smoser
python-3.12 - Mark CVE-2024-6923 as fixed in 3.12.5 (#7191)
ec287d5
The fix for this issue was included in upstream release of 3.12.5.
python/cpython#122599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

release-blocker

Projects

Release and Deferred blockers 🚫
Status: Done

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.

2 participants

@encukou @Yhg1s
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.