Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-136912: fix handling ofOverflowError inhmac.digest#136917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@picnixz
Copy link
Member

@picnixzpicnixz commentedJul 21, 2025
edited by bedevere-appbot
Loading

@picnixzpicnixz requested a review fromgpshead as acode ownerJuly 21, 2025 10:06
@picnixzpicnixzforce-pushed thefix/hmac/catch-overflow-error-136912 branch 5 times, most recently from99d62fe tod0079c6CompareJuly 21, 2025 10:25
@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commitd0079c6 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixzpicnixz marked this pull request as draftJuly 21, 2025 14:36
@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commitf93e1ba 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixzpicnixz marked this pull request as ready for reviewJuly 21, 2025 16:03
@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commitdf36d7d 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commit74239be 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixzpicnixz marked this pull request as draftJuly 21, 2025 17:26
@picnixz
Copy link
MemberAuthor

I'll rewrite this PR tomorrow to use suggestion 4.

Lib/hmac.py Outdated
return_hashopenssl.hmac_digest(key,msg,digest)
exceptOverflowError:
try:
return_hashopenssl.hmac_new(key,msg,digest).digest()
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@gpshead This will create a real HMAC object using OpenSSL and handles chunks in C. Alternatively, I can just catch the OverflowError directly and ignore it. The pure Python implementation already handles chunks as we just call.update() which is implemented in C as well.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

EDIT: actually OpenSSL still requires a key of size at most INT_MAX and HACL* requires the size to be at most UINT32_MAX. I'll just directly switch to the "slow" python implementation.

@picnixzpicnixzforce-pushed thefix/hmac/catch-overflow-error-136912 branch 4 times, most recently from1188f4a to84ea348CompareJuly 22, 2025 07:22
@picnixzpicnixzforce-pushed thefix/hmac/catch-overflow-error-136912 branch from7e01d44 to1082bd5CompareJuly 22, 2025 07:24
@picnixzpicnixz marked this pull request as ready for reviewJuly 22, 2025 07:25
@picnixzpicnixz added needs backport to 3.14bugs and security fixes and removed awaiting core review labelsJul 22, 2025
@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commit1082bd5 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixzpicnixzforce-pushed thefix/hmac/catch-overflow-error-136912 branch 2 times, most recently from5686d8f to2bb7fb6CompareJuly 22, 2025 14:49
@picnixzpicnixzforce-pushed thefix/hmac/catch-overflow-error-136912 branch from2bb7fb6 to4d412bdCompareJuly 22, 2025 14:50
@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commit4d412bd 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixz
Copy link
MemberAuthor

!buildbot bigmem

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commitac6b983 🤖

Results will be shown at:

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

The command will test the builders whose names match following regular expression:bigmem

The builders matched are:

  • aarch64 Ubuntu 22.04 BigMem PR
  • AMD64 Windows11 Bigmem PR

@picnixzpicnixzenabled auto-merge (squash)July 26, 2025 08:04
@picnixzpicnixz merged commitd658b90 intopython:mainJul 26, 2025
41 checks passed
@miss-islington-app
Copy link

Thanks@picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry,@picnixz, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker d658b9053beaacaae80e318f59a5ddd672aa757a 3.14

@picnixzpicnixz deleted the fix/hmac/catch-overflow-error-136912 branchJuly 26, 2025 08:28
@picnixz
Copy link
MemberAuthor

I'll do the 3.14 backporst in 3.14.1

@picnixzpicnixz removed the needs backport to 3.14bugs and security fixes labelJul 26, 2025
@bedevere-app
Copy link

GH-137116 is a backport of this pull request to the3.14 branch.

picnixz added a commit to picnixz/cpython that referenced this pull requestJul 26, 2025
…st` (pythonGH-136917)The OpenSSL and HACL* implementations of HMAC single-shotdigest computation reject keys whose length exceeds `INT_MAX`and `UINT32_MAX` respectively. The OpenSSL implementationalso rejects messages whose length exceed `INT_MAX`.Using such keys in `hmac.digest` previously raised an `OverflowError`which was propagated to the caller. This commit mitigates this case bymaking `hmac.digest` fall back to HMAC's pure Python implementationwhich accepts arbitrary large keys or messages.This change only affects the top-level entrypoint `hmac.digest`, leaving`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.(cherry picked from commitd658b90)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull requestAug 19, 2025
…thon#136917)The OpenSSL and HACL* implementations of HMAC single-shotdigest computation reject keys whose length exceeds `INT_MAX`and `UINT32_MAX` respectively. The OpenSSL implementationalso rejects messages whose length exceed `INT_MAX`.Using such keys in `hmac.digest` previously raised an `OverflowError`which was propagated to the caller. This commit mitigates this case bymaking `hmac.digest` fall back to HMAC's pure Python implementationwhich accepts arbitrary large keys or messages.This change only affects the top-level entrypoint `hmac.digest`, leaving`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
picnixz added a commit that referenced this pull requestOct 8, 2025
…H-136917) (#137116)The OpenSSL and HACL* implementations of HMAC single-shotdigest computation reject keys whose length exceeds `INT_MAX`and `UINT32_MAX` respectively. The OpenSSL implementationalso rejects messages whose length exceed `INT_MAX`.Using such keys in `hmac.digest` previously raised an `OverflowError`which was propagated to the caller. This commit mitigates this case bymaking `hmac.digest` fall back to HMAC's pure Python implementationwhich accepts arbitrary large keys or messages.This change only affects the top-level entrypoint `hmac.digest`, leaving`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.(cherry picked from commitd658b90)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@picnixz@bedevere-bot@gpshead

[8]ページ先頭

©2009-2025 Movatter.jp