-
Notifications
You must be signed in to change notification settings - Fork 18
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
A CVE vulnerability that has been fixed by ubuntu, can still be found with trivy scanner. #579
Comments
I think there's a few things going on here. Firstly, we don't ship the python distribution that is provided by canonical - we compile from source (see here). So you'd actually need to look at the upstream source. That being said, I'm assuming that the upstream cpython source has the fix which means we would expect to see that fix in the buildpack. The Python buildpacks provide the latest two patch releases of all supported minors. Which then leads me to ask what version of the python buildpack are you actually using? You can see this information in the output of the build (e.g. Once we have the version of the buildpack we can talk about specific versions of python that are present. |
Relevant part of the build log:
Is this the info you need? |
Yup, that's helpful, thanks. You also answered my next question I was going to ask - the version of python available. So you can see that you're using Python 3.11.5 - the latest available. I think in order to track down this CVE report you'll need to look at your scanner to determine which file on the filesystem is actually contributing to that scan. We see a lot of false positives with scanners. I'm not necessarily saying (yet) that this is one of them, but I don't think the issue is an out of date version of Python. |
From inside the built container, showing the bad version.
As it happens, I also use the poetry buildpack, and in the virtual enviroment that poetry creates the version of setuptools is way higher:
So the vulnerable version is still installed, albeit not used. Hope this helps. |
Ah, The only place in the buildpack toolchain that we explicitly interact with setup tools is in the When I look at the contents of the most recent
So if you're getting |
I don't agree. I'm using the latest version of the Complete builder log:
|
To make things more clear I've created a test repo @ https://github.com/jellehelsen/cpython-buildpack-test . No dependencies, just cpython-3.11. The only code is |
Hi @jellehelsen, I think I see what the issue is here. As you've shown here (& verified by downloading the source distribution for I downloaded |
TL;DR
Why not upgrade setuptools on Python 3.11.x and earlier?We've identified that the source distribution of python 3.1 (1and earlier) contains an old version of setuptools with known CVEs. We build from source, so we provide that version of setuptools. We've identified that python 3.12 contains a newer version of setuptools which doesn't have that CVE. If you zoom out a level, what we're saying is:
When I look at it that way, I don't think there's any action we should take. In general the buildpacks do not attempt to fix CVEs in upstream distributions of the dependencies. The buildpacks provide a lot of value to application developers and platform operators, but patching the upstream dependencies is outside of the scope of what we provide. The fact that Canonical (and other re-distributors like Red Hat) have fixed this CVE in their distributions of python doesn't mean that we can take on a similar burden in the buildpacks. These organizations have far more resources available to them to test the patches they make to software they redistribute. We don't have the bandwidth to make a similar committment. Setuptools on Python 3.12Setuptools was removed from Python 3.12 (source):
Building with Python 3.12 results in the following:
Upgrading setuptools as part of the build process on Python 3.10After quite a bit of hacking around, I was able to run
Unfortunately, this has two problems:
We could potentially work around both of these issues by performing the However, this gets into the question of what should the supported surface area of the buildpacks actually be, and I don't think we can commit to modifying the upstream source distribution. Setuptools 65.5.0 in Python 3.11.5Searching through the source of Python 3.11.5 for the string
Some additional notesIn order to get the
If you open
This In order to invoke For the purposes of this investigation, I edited it during the build phase. We could/should make this change during the actual compilation if we wanted to invoke pip during the cpython build phase. |
I have created a pull request to address this issue because there is no other clean way to address this CVE. The main driver for this is to address a CVE that cannot be fixed by changing dependencies in requirement.txt files. The only way to get around this is issue is to modify the cpython layer with an inline buildpack (at build time) or to modify the container after build. Both are not good solutions.
I agree that generally buildpacks shouldn't address CVEs, but this is a case where the CVE can't be addressed without modifying the buildpack or by modifying the image created with the buildpack. No changes to requirements.txt will prevent the CVE if you are using older versions of python. |
To further demonstrate that this issue can only be addressed in the cpython bulidpack, I have built the following sample app and run the Trivy scan to show the CVE. Note that the sample app I'm building has no external (pip) dependencies and it installs the default version of cpython (3.10.x), which is impacted by the CVE.
Trivy scan output
|
According to my trivy scan CVE-2022-40897 is still present in my newly built image, build with paketobuildpacks/builder-jammy-base. A fix was already released by Canonical a while ago (https://ubuntu.com/security/CVE-2022-40897) but the vulnerability can still be found.
According to you docs security updates are picked up from Canonical on mere hours. Why can this vulnerability can still be found?
The text was updated successfully, but these errors were encountered: