Request package upgrade is not updating the certifi package

Hi Team,

There is a vulnerability in certifi package which is tranisitive dependent package of request library.
https://nvd.nist.gov/vuln/detail/CVE-2024-39689

in our application we use request library requests==2.32.3 which is latest as of now. when we use latest request library it is not fetching/updating the latest certifi package. Current certifi package is certifi==2024.2.2 and the vulerability got fixed in certifi==2024.8.30 or above.

so our doubt is on FreeBSD OS when we used request=2.32.3 it is able to update the certifi to latest but on linux/windows when we use the same request version why it is not upgrading to latest version? how can we resolve this high vulnerability issue.

can some one please provide some thoughts on this

Thanks,
Raghu

This will entirely depend on where you’re getting certifi from, if you’re using PyPI (like with pip, poetry, uv, etc) then you’d upgrade using python -m pip --upgrade certifi. If you’re getting certifi from FreeBSD OS’s package manager then you would upgrade using that package management tool. If it’s not available yet there, then you need to contact the FreeBSD maintainers of that package distribution (not the certifi maintainers).

Try the following:

python -m pip install --upgrade-strategy=eager --upgrade "requests==2.32.3"

The key there is --upgrade-strategy=eager; by default, pip will not update transitive dependencies unless the package(s) it is installing have a lower bound that is higher than what is already installed.

1 Like

Thanks Zachary and Larson for the information.

On FreeBSD we are getting latest version as mentioned by you it depends on the package management tool.

problem is on other OS like Windows and Linux .

we use requirements.in file and run the following command to get the list of dependent packages
and create requirements.txt file.

example of req.in

automat==22.10.0
cheroot==8.2.1
CherryPy==18.8.0
requests==2.32.3

and run the below command.

pip-compile --allow-unsafe --no-annotate ‘.\requirements.in’

so should we update the above command to fetch the latest dependent versions?

Thanks

On these OS (Windows, Debian, Fedora, RHEL, etc) the OS manages the TLS certificates for you. Just as you found with FreeBSD.

I think its only macOS where I need to ensure that certifi is up to date. That will be until someone figures out how to use the certificate store managed by Apple on macOS I understand.

Thanks,

actually there is one security vulnerability on certifi ( CVE-2024-39689) where we need to upgrade to 2024 08 30 version. Now we are at 2024 2 2 version.

so as it is transitive dependent package of request package we moved the request package to latest version 2.32.3 but it didnt moved the certifi package on few OS.

our application is not UI based just sdk/API based application and we create executable file.
we dont directly use the certifi module in our application and we do import request alone in our code.

so is this certifi package gets affected if we dont upgrade to latest version?

Thanks

Any inputs on this will be really helpful as we have one release next week please

In your possition I would manage the trust store on an OS by OS basis. That will mean that you need to identify the trust store that is used and update it using the OS specific or PyPI mechanism as appropiate. Do not assume that certifi is the trust store used.
For example on most linux distros the distro manages the trust store and I think certifi may well be ignored.

HI Scott,

Thank u,

we just use the request library and dont use the certifi package but because of dependency certifi is getting installed, so our point is we dont use any trust store in our code and while making https request calls as well we dont specify any certifi imports.

in this case are we affected by this cerifi implictly? are we affected here if we dont upgrade to newer certifi version

I looked at the certifi core that is installed from the Fedora RPM.
Its patched to do this:

$ more /usr/lib/python3.12/site-packages/certifi/core.py
"""
certifi.py
~~~~~~~~~~

This module returns the installation location of cacert.pem or its contents.
"""

# The RPM-packaged certifi always uses the system certificates
def where() -> str:
    return '/etc/pki/tls/certs/ca-bundle.crt'

def contents() -> str:
    with open(where(), encoding='utf=8') as data:
        return data.read()

If you are on a RHEL or Fedora system the certifi dependency is installed, but uses the OS managed trust store.

You will need to check specifics on each OS you use.

1 Like

yeah sure,

when i checked on windows its bit different
_CACERT_CTX = as_file(files(“certifi”).joinpath(“cacert.pem”))
_CACERT_PATH = str(_CACERT_CTX.enter())

But our only concern is if we are not using this explicitly still will it be referred here?
i could see list of root certs in the cacert.pem file. only thing is we are not referring this path (cacert.pem) path in our code when making the request calls

example

requests_session = requests.Session()
verify_ssl = false or path of the certs which is not certifi path
response = requests_session.post(url, headers=rest_headers, cookies=rest_cookies, json=request_body,
verify=verify_ssl, timeout= 10)

We dont use the certifi methods like where / contents / path anywhere when we make a request call
so is it still affected ?

You mean what does requests use for its trust store on Windows?

The answer is in the requests source code, which you have.
I would read the source to be sure of the exact behaviour in your position.

Hi ,

what i m trying to say is in the request calls. we are not specifying the certifi package path explicitly so will that be used by the requests module. and one more thing is we are specifying verify=False where in the documentation of the requests it mentioned as it will not verify the server TLS certs.

param verify: (optional) Either a boolean, in which case it controls whether we verify
the server’s TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True`

Thanks

What we are saying is that you’ll need to audit the code if you want to be certain. You can’t expect to base a security decision on advice from the internet where the people giving the advice don’t have all the information about your app.

I don’t honestly understand why you don’t simply use the latest version of certifi. You’ve been given advice on how to do that. So presumably there’s some constraint you’re not explaining that stops you doing that - which is yet more information that we don’t know about your app…

5 Likes

Yes, you should add --upgrade in that command if you want to force update transitive dependencies even if the specified dependencies are satisfied. See GitHub - jazzband/pip-tools: A set of tools to keep your pinned Python dependencies fresh.

Sure Moore
Thank you

we are not deciding to get away from the fix or something. we need to fix this for sure but we have one release next week and we need to create builds and test again and provide them without any breakfixes. already test cycle is completed for this release. So wanted to check the impact of the issue on our application.

we wanted to understand how the request module, if we dont specify the certifi implicitly and if we use verify=False is this issue still applicable so that we can get sometime for the next release which is in december

Thats the only reason :slight_smile:

Thanks Prakash,

thanks for the argument i did verify that option and was able to upgrade the packages
but only thing is we wanted to know the impact of cerifi module