testcontainers-java: [Bug]: Testcontainers uses outdated versions of Snakeyaml & Jackson, which have critical vulnerabilities, flagging testcontainers on security scanning tools
Module
Core
Testcontainers version
1.20.1
Using the latest Testcontainers version?
Yes
Host OS
MacOS
Host Arch
ARM
Docker version
Client:
Version: 26.1.4
API version: 1.45
Go version: go1.21.11
Git commit: 5650f9b
Built: Wed Jun 5 11:26:02 2024
OS/Arch: darwin/arm64
Context: desktop-linux
What happened?
The testcontainers core shades snakeyaml 1.33 into the jar. Snakeyaml 1.33 is vulnerable to CVE-2022-1471. Even though the code does not appear vulnerable to this issue because it uses SafeConstructor, enterprises may blacklist testcontainers for the mere presence of snakeyaml 1.33. Please consider upgrading to snakeyaml 2.0 or higher.
Relevant log output
No response
Additional Information
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (5 by maintainers)
Also for us, Nexus IQ/Sonatype is blocking this
Tools like Nexus IQ/Sonatype which are blocking it aren’t loved by developers in corporates but are a necessary evil due to large number of CVEs in production code through dependencies. Test specific code like this then gets caught crossfire off it.
At some point the project will migrate anyway, you won’t want to always stay on the old version. The question then becomes when should be do it? The advantage for the community is hopefully that some of these corporate users will contribute back.
I can spare some time and can help if needed, assuming it’ll get merged, I saw @eddumelendez saying not to open a PR some time back when I first looked at this issue so didn’t spend any time working on it
Sonatype is a useful tool for identifying the potentiality of vulnerabilities in a project, but it is horrible because enterprises typically equate the potentiality of a vulnerability with the exploitability of one. And even if proven non-exploitable sonatype might still not allow it in the software ecosystem.
Yes, we developers have complaints about the tooling, but the tooling doesn’t claim to assess exploitability. It essentially just scans the dependencies list and shaded classpath, takes a hash of every file and searches their database to see if that version of the file is associated with a CVE or sonatype cataloged exploit and then generates a report based on the presence. Sonatype will never mark this as a false positive because a vulnerable class file is in the classpath which is the extent of their guarantees - regardless of if that class file is actually used anywhere.
As @gquintana said, this is usually pretty easy to “just deal with” instead of arguing when the dependencies are not shaded in. Problem is when it’s shaded in and there’s dependency clashes that make upgrades more difficult and require changing source code. I have forked testcontainers and created a version without these sonatype complaints which serves my specific purposes for the containers my team uses, but it does not pass tests for some containers so I’m not going to be able to raise a PR for it.
@asomov I truly understand your point.
Sadly, being considered as dangerous, nearly all testcontainers releases are considered as “security critical” and quarantined by Nexus dependency proxy. As a result, we can not use it at all, except very old releases.
I wonder whether having a testcontainer artefact without any dependency shaded in it (No Jackson, no SnakeYaml) could be a workaround. In our case most SnakeYaml releases are considered as “security critical” but very few are quarantined (don’t ask me why). Same for Jackson, some releases are marked as “security critical” but none of them is quarantined. In the end the best solution could be to have a “slim” testcontainers Jar and let users manage their dependency hell by their own.
Please, do not open a PR for this. We should take into account when update a dependency to a major version when doing patch and minor releases.