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-145264: Do not ignore excess Base64 data after the first padded quad by serhiy-storchaka · Pull Request #145267 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Feb 26, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc) no longer ignores excess data after the first padded quad in non-strict (default) mode. Instead, in conformance with RFC 4648, it ignores the pad character, "=", if it is present before the end of the encoded data.

  • Issue: Excess Base64 data ignored after padding by default #145264

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Feb 26, 2026
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 26, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 26, 2026
Excess Base64 data ignored after padding by default #145264
Closed
@serhiy-storchaka
pythongh-145264: Do not ignore excess Base64 data after the first pad…
0229b06
…ded quad

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
@serhiy-storchaka
serhiy-storchaka force-pushed the base64-excess-data branch from 50967e0 to 0229b06 Compare February 26, 2026 18:31
@serhiy-storchaka
Merge branch 'main' into base64-excess-data
1307572
gpshead
gpshead reviewed Feb 28, 2026
View reviewed changes
Comment thread Modules/binascii.c Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Library/2026-02-26-20-13-16.gh-issue-145264.4pggX_.rst Outdated
@@ -0,0 +1,4 @@
Base64 decoder (see :func:`binascii.a2b_base64`, :func:`base64.b64decode`, etc) no
longer ignores excess data after the first padded quad in non-strict
(default) mode. Instead, in conformance with :rfc:`4648`, it ignores

@gpshead gpshead Feb 28, 2026

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.

I guess this is in accordance with the MAY in https://datatracker.ietf.org/doc/html/rfc4648#section-3.3 about ignoring PADs as non-alphabet data? it'd be good to cite the specific section.

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Feb 28, 2026

Copy link
Copy Markdown
Member Author

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.

Done.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/test/test_binascii.py Outdated
# Test excess data exceptions
def assertExcessData(data, non_strict_expected,
ignore_padchar_expected=None):
def assertExcessData(data, non_strict_expected):

@gpshead gpshead Feb 28, 2026

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.

rename this from non_strict_expected to just expected.

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Feb 28, 2026

Copy link
Copy Markdown
Member Author

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.

In strict mode you get an error. You get that value only in non-strict mode, either when strict_mode=False, or when ignorechars contains "=".

But I agree that expected is shorter. The old name was even longer: non_strict_mode_expected_result.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/test/test_binascii.py Resolved

Uh oh!

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

@serhiy-storchaka
Address commit review.
2676401
@serhiy-storchaka

serhiy-storchaka commented Mar 12, 2026

Copy link
Copy Markdown
Member Author

@gpshead, could you please look again at that PR?

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
Merge branch 'main' into base64-excess-data
94cb78e
@serhiy-storchaka

serhiy-storchaka commented Mar 22, 2026

Copy link
Copy Markdown
Member Author

Is it fine for you, @gpshead?

All reactions

Sorry, something went wrong.

Uh oh!

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

gpshead
gpshead approved these changes Mar 22, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 22, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 4561f64 into python:main Mar 22, 2026
54 checks passed

Uh oh!

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

@serhiy-storchaka
serhiy-storchaka deleted the base64-excess-data branch March 22, 2026 21:13
@miss-islington-app

miss-islington-app Bot commented Mar 22, 2026

Copy link
Copy Markdown

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

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 awaiting merge label Mar 22, 2026
@miss-islington-app

miss-islington-app Bot commented Mar 22, 2026

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 4561f6418a691b3e89aef0901f53fe0dfb7f7c0e 3.14
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 serhiy-storchaka Mar 22, 2026
@miss-islington-app

miss-islington-app Bot commented Mar 22, 2026

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 4561f6418a691b3e89aef0901f53fe0dfb7f7c0e 3.13
All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Mar 23, 2026
@serhiy-storchaka
[3.14] pythongh-145264: Do not ignore excess Base64 data after the fi…
a21e7ff
…rst padded quad (pythonGH-145267)

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f64)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app

bedevere-app Bot commented Mar 23, 2026

Copy link
Copy Markdown

GH-146326 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 23, 2026
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Mar 23, 2026
@CuriousLearner
Merge branch 'main' of github.com:python/cpython into fix-pythongh-13…
3e05fa3
…8577

* 'main' of github.com:python/cpython:
  pythongh-146197: Run -m test.pythoninfo on the Emscripten CI (python#146332)
  pythongh-146325: Use `test.support.requires_fork` in test_fastpath_cache_cleared_in_forked_child (python#146330)
  pythongh-146197: Add Emscripten to CI (python#146198)
  pythongh-143387: Raise an exception instead of returning None when metadata file is missing. (python#146234)
  pythongh-108907: ctypes: Document _type_ codes (pythonGH-145837)
  pythongh-146175: Soft-deprecate outdated macros; convert internal usage (pythonGH-146178)
  pythongh-146056: Rework ref counting in treebuilder_handle_end() (python#146167)
  Add a warning about untrusted input to `configparser` docs (python#146276)
  pythongh-145264: Do not ignore excess Base64 data after the first padded quad (pythonGH-145267)
  pythongh-146308: Fix error handling issues in _remote_debugging module (python#146309)
  pythongh-146192: Add base32 support to binascii (pythonGH-146193)
  pythongh-135953: Properly obtain main thread identifier in Gecko Collector (python#146045)
  pythongh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples (pythonGH-144300)
  pythongh-146261: Fix bug in `_Py_uop_sym_set_func_version` (pythonGH-146291)
  pythongh-145144: Add more tests for UserList, UserDict, etc (pythonGH-145145)
  pythongh-143959: Fix test_datetime if _datetime is unavailable (pythonGH-145248)
  pythongh-146245: Fix reference and buffer leaks via audit hook in socket module (pythonGH-146248)
  pythongh-140049: Colorize exception notes in `traceback.py` (python#140051)
  Update docs for pythongh-146056 (pythonGH-146213)
ambv pushed a commit that referenced this pull request Mar 23, 2026
@serhiy-storchaka
[3.14] gh-145264: Do not ignore excess Base64 data after the first pa…
e31c551
…dded quad (GH-145267) (GH-146326)

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f64)
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 23, 2026
@serhiy-storchaka @miss-islington
[3.14] pythongh-145264: Do not ignore excess Base64 data after the fi…
bd4ab52
…rst padded quad (pythonGH-145267) (pythonGH-146326)

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f64)
(cherry picked from commit e31c551)

Co-authored-by: Serhiy Storchaka <[email protected]>
ambv pushed a commit that referenced this pull request Mar 23, 2026
@miss-islington @serhiy-storchaka
[3.13] gh-145264: Do not ignore excess Base64 data after the first pa…
1f9958f
…dded quad (GH-145267) (GH-146326) (GH-146348)

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f64)
(cherry picked from commit e31c551)

Co-authored-by: Serhiy Storchaka <[email protected]>
@StanFromIreland StanFromIreland removed the needs backport to 3.13 only security fixes label Mar 25, 2026
@pablogsal pablogsal mentioned this pull request Apr 4, 2026
gh-130273: Fix traceback color output with unicode characters #142529
Merged
@UTsweetyfish UTsweetyfish mentioned this pull request Apr 13, 2026
python3.12: CVE-2026-1502 deepin-community/sig-deepin-security#321
Closed
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@serhiy-storchaka @ljfp
pythongh-145264: Do not ignore excess Base64 data after the first pad…
3eba3bd
…ded quad (pythonGH-145267)

Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
@serhiy-storchaka serhiy-storchaka removed their assignment Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes

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.

Uh oh!

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

3 participants

@serhiy-storchaka @gpshead @StanFromIreland
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.