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

Fix unit test caused by expiring signing certificate #1305

Merged

Conversation

micahsnyder
Copy link
Contributor

The clamscan test "assorted_test.py::TC::test_pe_cert_trust" is about to fail because the "test.exe" test file was signed with a cert set to expire after only 2 years, and it has been 23 months.

While attempting to generate a new one that will last 73000 days (200 years), I discovered that any signing certificate set to expire after 2038 will fail the trust-check because the ca.not_after variable is maxed out time_t incapable of expressing a higher number. To fix this, I've upgraded the variables to uint64_t.

I also had to replace a bunch of generated signatures to match the new "test.exe".

Finally, I noticed that "ca.not_before" was being set to the token[8] instead of token[9], which presumably mean the "NotBefore" field for Trusted and Revoked Certificates was non-functional, as it was treating the "CertSign" boolean as the "NotBefore" value.

Fixes: #1300

libclamav/crtmgr.h Outdated Show resolved Hide resolved
@micahsnyder micahsnyder force-pushed the CLAM-2636-expiring-crb-and-Y2K38 branch from c5b2f3c to e97abab Compare July 11, 2024 14:06
@bmwiedemann
Copy link

Hi, what is missing to get this merged?

@micahsnyder
Copy link
Contributor Author

Hi, what is missing to get this merged?

We've had some issues with our internal Jenkins test pipelines that has slowed down some reviews on Github. I think this is good to go, though.

The clamscan test "assorted_test.py::TC::test_pe_cert_trust" is about to
fail because the "test.exe" test file was signed with a cert set to
expire after only 2 years, and it has been 23 months.

While attempting to generate a new one that will last 73000 days (200
years), I discovered that any signing certificate set to expire after
2038 will fail the trust-check because the `ca.not_after` variable is
maxed out `time_t` incapable of expressing a higher number.
To fix this, I've upgraded the variables to `uint64_t`.

I also had to replace a bunch of generated signatures to match the new
"test.exe".

Finally, I noticed that "ca.not_before" was being set to the token[8]
instead of token[9], which presumably mean the "NotBefore" field for
Trusted and Revoked Certificates was non-functional, as it was treating
the "CertSign" boolean as the "NotBefore" value.

Fixes: Cisco-Talos#1300
@micahsnyder micahsnyder force-pushed the CLAM-2636-expiring-crb-and-Y2K38 branch from e97abab to d11590f Compare July 22, 2024 17:26
@micahsnyder
Copy link
Contributor Author

Rebased with upstream main branch to get CI fixes.

@micahsnyder micahsnyder merged commit 60ade09 into Cisco-Talos:main Jul 22, 2024
23 of 24 checks passed
@micahsnyder micahsnyder deleted the CLAM-2636-expiring-crb-and-Y2K38 branch July 22, 2024 17:48
@micahsnyder micahsnyder added the 🍒cherry-pick-candidate A PR that should be backported once approved. label Jul 22, 2024
@bmwiedemann
Copy link

bmwiedemann commented Jul 29, 2024

Is there a plan to make a release with this? Patching binary files in not so easy with some build systems.

Edit: submitted to openSUSE in https://build.opensuse.org/request/show/1190176 using git apply

@peteanning
Copy link

@micahsnyder we are using 1.0.6 LTS building from source (now failing) will #1305 be released as a patch for 1.0.6

@micahsnyder
Copy link
Contributor Author

@peteanning Sorry for the late response. We will publish 1.0.7 (and 1.3.2) with the fix soon, alongside or shortly after 1.4.0.

mtremer pushed a commit to ipfire/ipfire-2.x that referenced this pull request Sep 5, 2024
- Update from version 1.3.1 to 1.3.2
- Update of rootfile
- 2 CVE Fixes
- Changelog
    1.3.2
	- [CVE-2024-20506](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-20506):
	  Changed the logging module to disable following symlinks on Linux and Unix
	  systems so as to prevent an attacker with existing access to the 'clamd' or
	  'freshclam' services from using a symlink to corrupt system files.
	  This issue affects all currently supported versions. It will be fixed in:
	  - 1.4.1
	  - 1.3.2
	  - 1.0.7
	  - 0.103.12
	  Thank you to Detlef for identifying this issue.
	- [CVE-2024-20505](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-20505):
	  Fixed a possible out-of-bounds read bug in the PDF file parser that could
	  cause a denial-of-service (DoS) condition.
	  This issue affects all currently supported versions. It will be fixed in:
	  - 1.4.1
	  - 1.3.2
	  - 1.0.7
	  - 0.103.12
	  Thank you to OSS-Fuzz for identifying this issue.
	- Removed unused Python modules from freshclam tests including deprecated
	  'cgi' module that is expected to cause test failures in Python 3.13.
	- Fix unit test caused by expiring signing certificate.
	  - Backport of [GitHub pull request](Cisco-Talos/clamav#1305)
	- Fixed a build issue on Windows with newer versions of Rust.
	  Also upgraded GitHub Actions imports to fix CI failures.
	  Fixes courtesy of liushuyu.
	  - Backport of [GitHub pull request](Cisco-Talos/clamav#1307)
	- Fixed an unaligned pointer dereference issue on select architectures.
	  Fix courtesy of Sebastian Andrzej Siewior.
	  - Backport of [GitHub pull request](Cisco-Talos/clamav#1293)
	- Fixes to Jenkins CI pipeline.
	  For details, see [GitHub pull request](Cisco-Talos/clamav#1330)

Signed-off-by: Adolf Belka <[email protected]>
Signed-off-by: Michael Tremer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒cherry-pick-candidate A PR that should be backported once approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_pe_cert_trust fails after 2024-07-28
5 participants