Skip to content
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

Used python rsa library brings PKCS#1 decryption vulnerability, is google-auth affected? #646

Closed
attila123 opened this issue Nov 30, 2020 · 2 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@attila123
Copy link

attila123 commented Nov 30, 2020

Environment details

  • OS: not relevant for the issue
  • Python version: not relevant for the issue
  • pip version: not relevant for the issue
  • google-auth version: 1.23.0, currently latest

Steps to reproduce

Security vulnerability scanners pick up an unfixed PKCS#1 decryption code issue with the rsa library 4.6 (see among the dependencies in setup.py in this project): sybrenstuvel/python-rsa#165 => although it is closed, from the comments it seems that it is not fixed, and anyway new version for this library is not released for some time...

One of the proposed solutions would be: sybrenstuvel/python-rsa#165 (comment) :
"3. modify code you depend on so that it uses libraries that do provide side-channel free behaviour for RSA decryption"

Questions:

  1. Could you please confirm that this google-auth library does not use the vulnerable PKCS#1 decrypt() method, so that this rsa library issue can be considered a false-positive for google-auth? I tried to check quickly, for me this seems to be the case.
  2. Would it be needed / feasible for google-auth to use another crypto library which does not have this issue? Is there a crypto library which would have clear advantages over the python rsa library?
@busunkim96
Copy link
Contributor

Hi @attila123, thanks for the report.

  1. Could you please confirm that this google-auth library does not use the vulnerable PKCS#1 decrypt() method, so that this rsa library issue can be considered a false-positive for google-auth? I tried to check quickly, for me this seems to be the case.

python-rsa is used only in https://github.com/googleapis/google-auth-library-python/blob/37141e4dffc2ba3f3f57c5914544fb8b9cf7d017/google/auth/crypt/_python_rsa.py. As you've stated, the decode() method is not called.

Full list of calls to python-rsa:

return rsa.pkcs1.verify(message, signature, self._pubkey)

der = rsa.pem.load_pem(public_key, "CERTIFICATE")

pubkey = rsa.PublicKey.load_pkcs1(key_bytes, "DER")

pubkey = rsa.PublicKey.load_pkcs1(public_key, "PEM")

return rsa.pkcs1.sign(message, self._key, "SHA-256")

private_key = rsa.key.PrivateKey.load_pkcs1(key_bytes, format="DER")

private_key = rsa.key.PrivateKey.load_pkcs1(
private_key_info.asOctets(), format="DER"
)

  1. Would it be needed / feasible for google-auth to use another crypto library which does not have this issue? Is there a crypto library which would have clear advantages over the python rsa library?

If cryptography is installed, it will be preferred overpython-rsa.

try:
# Prefer cryptograph-based RSA implementation.
from google.auth.crypt import _cryptography_rsa
RSASigner = _cryptography_rsa.RSASigner
RSAVerifier = _cryptography_rsa.RSAVerifier
except ImportError: # pragma: NO COVER
# Fallback to pure-python RSA implementation if cryptography is
# unavailable.
from google.auth.crypt import _python_rsa
RSASigner = _python_rsa.RSASigner
RSAVerifier = _python_rsa.RSAVerifier

@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Nov 30, 2020
@busunkim96 busunkim96 self-assigned this Nov 30, 2020
@attila123
Copy link
Author

Thanks @busunkim96 for your kind support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants