-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Reference leaks in _hashlib.hmac_new
and _hashlib.hmac_digest
#130151
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
_hashlib.hmac_new
is leaking if HMAC message object is of incorrect type_hashlib.hmac_new
is missing a Py_DECREF(type)
if HMAC message object is of incorrect type
_hashlib.hmac_new
is missing a Py_DECREF(type)
if HMAC message object is of incorrect type_hashlib.hmac_new
and _hashlib.hmac_digest
gpshead
pushed a commit
that referenced
this issue
Feb 24, 2025
…0152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy`
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Feb 24, 2025
…ythonGH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy` (cherry picked from commit 0718201) Co-authored-by: Bénédikt Tran <[email protected]>
gpshead
pushed a commit
that referenced
this issue
Feb 24, 2025
…GH-130152) (#130491) gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy` (cherry picked from commit 0718201) Co-authored-by: Bénédikt Tran <[email protected]>
picnixz
added a commit
that referenced
this issue
Feb 25, 2025
…GH-130152) (#130539) gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy` (cherry picked from commit 0718201)
seehwan
pushed a commit
to seehwan/cpython
that referenced
this issue
Apr 16, 2025
…ythonGH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
Bug description:
The following leaks:
The issue is in
_hashlib_hmac_new_impl
:More precisely, the issue is that we are only calling
PyObject_Free(self)
and we are not decrefing the type. So we need to callPy_XDECREF(self);
instead and freectx
separately ifself
has not already been allocated. Note that the HMAC context is still cleared so we should not leak anything sensitive.There is also a missing
HMAC_CTX_free
call in_hmac_digest
, if the copy of the HMAC context fails. Again, there shouldn't be a security issue as the temporary context should still not be initialized on failure (and the secret key is not stored within, hopefully).CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
_hashlib.hmac_{new,digest}
#130152_hashlib.hmac_{new,digest}
(GH-130152) #130491_hashlib.hmac_{new,digest}
(GH-130152) #130539The text was updated successfully, but these errors were encountered: