logo

cve-client

CLI-based client / toolbox for CVE.org
commit: cf83f7d310771200acf1fb9b534ead78812550dd
parent a9b91748db240b82d86b69ed8076bc352510633c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 27 Mar 2023 20:21:27 +0200

Add tests

Diffstat:

MMANIFEST4++++
MMakefile.PL9+++++++--
At/cve_schema50.CVE-2022-24903.json2++
At/cve_schema50.CVE-2022-24903.txt19+++++++++++++++++++
At/cve_schema50.t41+++++++++++++++++++++++++++++++++++++++++
5 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/MANIFEST b/MANIFEST @@ -4,3 +4,7 @@ lib/App/CveClient.pm Makefile.PL MANIFEST This list of files README.md +t/cve_schema50.CVE-2022-24903.json +t/cve_schema50.CVE-2022-24903.txt +t/cve_schema50.CVE-2024-24903.json +t/cve_schema50.t diff --git a/Makefile.PL b/Makefile.PL @@ -32,10 +32,15 @@ my %meta_merge = ( WriteMakefile( NAME => 'App::CveClient', ABSTRACT => 'CLI-based client / toolbox for CVE.org', - AUTHOR => 'Haelwenn (lanodan) Monnier', + AUTHOR => 'Haelwenn (lanodan) Monnier <contact+cve-client@hacktivis.me>', LICENSE => 'agpl_3', EXE_FILES => ['cve-client'], - VERSION_FROM => './cve-client', + + VERSION_FROM => 'cve-client', PREREQ_PM => \%depend, META_MERGE => \%meta_merge, + TEST_REQUIRES => { + 'Test::More' => 0, + 'Test::Output' => 0, + }, ); diff --git a/t/cve_schema50.CVE-2022-24903.json b/t/cve_schema50.CVE-2022-24903.json @@ -0,0 +1 @@ +{"dataType":"CVE_RECORD","dataVersion":"5.0","cveMetadata":{"state":"PUBLISHED","cveId":"CVE-2022-24903","assignerOrgId":"a0819718-46f1-4df5-94e2-005712e83aaa","assignerShortName":"GitHub_M","dateUpdated":"2022-11-14T00:00:00","dateReserved":"2022-02-10T00:00:00","datePublished":"2022-05-05T00:00:00"},"containers":{"cna":{"title":"Buffer overflow in TCP syslog server (receiver) components in rsyslog","providerMetadata":{"orgId":"a0819718-46f1-4df5-94e2-005712e83aaa","shortName":"GitHub_M","dateUpdated":"2022-11-14T00:00:00"},"descriptions":[{"lang":"en","value":"Rsyslog is a rocket-fast system for log processing. Modules for TCP syslog reception have a potential heap buffer overflow when octet-counted framing is used. This can result in a segfault or some other malfunction. As of our understanding, this vulnerability can not be used for remote code execution. But there may still be a slight chance for experts to do that. The bug occurs when the octet count is read. While there is a check for the maximum number of octets, digits are written to a heap buffer even when the octet count is over the maximum, This can be used to overrun the memory buffer. However, once the sequence of digits stop, no additional characters can be added to the buffer. In our opinion, this makes remote exploits impossible or at least highly complex. Octet-counted framing is one of two potential framing modes. It is relatively uncommon, but enabled by default on receivers. Modules `imtcp`, `imptcp`, `imgssapi`, and `imhttp` are used for regular syslog message reception. It is best practice not to directly expose them to the public. When this practice is followed, the risk is considerably lower. Module `imdiag` is a diagnostics module primarily intended for testbench runs. We do not expect it to be present on any production installation. Octet-counted framing is not very common. Usually, it needs to be specifically enabled at senders. If users do not need it, they can turn it off for the most important modules. This will mitigate the vulnerability."}],"affected":[{"vendor":"rsyslog","product":"rsyslog","versions":[{"version":"< 8.2204.1","status":"affected"}]}],"references":[{"url":"https://github.com/rsyslog/rsyslog/security/advisories/GHSA-ggw7-xr6h-mmr8"},{"url":"https://github.com/rsyslog/rsyslog/commit/f211042ecbb472f9d8beb4678a65d272b6f07705"},{"name":"FEDORA-2022-f796a28a7b","tags":["vendor-advisory"],"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GMNNXLCU2UORRVSZO24HL4KMVPK5PHVW/"},{"name":"[debian-lts-announce] 20220520 [SECURITY] [DLA 3016-1] rsyslog security update","tags":["mailing-list"],"url":"https://lists.debian.org/debian-lts-announce/2022/05/msg00028.html"},{"name":"DSA-5150","tags":["vendor-advisory"],"url":"https://www.debian.org/security/2022/dsa-5150"},{"url":"https://security.netapp.com/advisory/ntap-20221111-0002/"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","attackVector":"NETWORK","attackComplexity":"HIGH","privilegesRequired":"NONE","userInteraction":"NONE","scope":"UNCHANGED","confidentialityImpact":"HIGH","integrityImpact":"HIGH","availabilityImpact":"HIGH","baseScore":8.1,"baseSeverity":"HIGH"}}],"problemTypes":[{"descriptions":[{"type":"CWE","lang":"en","description":"CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')","cweId":"CWE-120"}]}],"source":{"advisory":"GHSA-ggw7-xr6h-mmr8","discovery":"UNKNOWN"}}}} +\ No newline at end of file diff --git a/t/cve_schema50.CVE-2022-24903.txt b/t/cve_schema50.CVE-2022-24903.txt @@ -0,0 +1,19 @@ +CVE ID: CVE-2022-24903 +Vendor Name: rsyslog +Product Name: rsyslog +- affected: < 8.2204.1 + +- Score: 8.1 HIGH + +Description Language: en +Description: +Rsyslog is a rocket-fast system for log processing. Modules for TCP syslog reception have a potential heap buffer overflow when octet-counted framing is used. This can result in a segfault or some other malfunction. As of our understanding, this vulnerability can not be used for remote code execution. But there may still be a slight chance for experts to do that. The bug occurs when the octet count is read. While there is a check for the maximum number of octets, digits are written to a heap buffer even when the octet count is over the maximum, This can be used to overrun the memory buffer. However, once the sequence of digits stop, no additional characters can be added to the buffer. In our opinion, this makes remote exploits impossible or at least highly complex. Octet-counted framing is one of two potential framing modes. It is relatively uncommon, but enabled by default on receivers. Modules `imtcp`, `imptcp`, `imgssapi`, and `imhttp` are used for regular syslog message reception. It is best practice not to directly expose them to the public. When this practice is followed, the risk is considerably lower. Module `imdiag` is a diagnostics module primarily intended for testbench runs. We do not expect it to be present on any production installation. Octet-counted framing is not very common. Usually, it needs to be specifically enabled at senders. If users do not need it, they can turn it off for the most important modules. This will mitigate the vulnerability. + + +References: +=> https://github.com/rsyslog/rsyslog/security/advisories/GHSA-ggw7-xr6h-mmr8 +=> https://github.com/rsyslog/rsyslog/commit/f211042ecbb472f9d8beb4678a65d272b6f07705 +=> https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GMNNXLCU2UORRVSZO24HL4KMVPK5PHVW/ +=> https://lists.debian.org/debian-lts-announce/2022/05/msg00028.html +=> https://www.debian.org/security/2022/dsa-5150 +=> https://security.netapp.com/advisory/ntap-20221111-0002/ diff --git a/t/cve_schema50.t b/t/cve_schema50.t @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +# CVE-Client: CLI-based client / toolbox for CVE.org +# Copyright © 2021-2023 CVE-Client Authors <https://hacktivis.me/git/cve-client/> +# SPDX-License-Identifier: AGPL-3.0-only +use strict; +use utf8; + +use Test::More tests => 2; +use Test::Output; + +use JSON::MaybeXS; + +use App::CveClient qw(print_cve); + +my $json = JSON::MaybeXS->new(utf8 => 1); + +open(CVE_IN, '<', 't/cve_schema50.CVE-2022-24903.json') or die "$!"; +open(CVE_OUT, '<', 't/cve_schema50.CVE-2022-24903.txt') or die "$!"; + +my $object = $json->decode(<CVE_IN>) or die "$!"; + +# Read whole files +undef $/; + +output_is { print_cve($object, 'CVE-2022-24903') } <CVE_OUT>, '', + 'Test printing CVE-2022-24903'; + +output_is { print_cve($object, 'CVE-222-24903') } <CVE_OUT>, + "Warning: Got <CVE-2022-24903> instead of <CVE-222-24903>\n", + 'XTest printing CVE-2022-24903 with cve_id being CVE-222-24903'; + +close(CVE_IN); +close(CVE_OUT); + +# TODO: Figure out how to test fails properly +# +#my $nx_object = $json->decode('{"error":"CVE_RECORD_DNE","message":"The cve record for the cve id does not exist."}'); +# +#output_is { print_cve($nx_object, 'CVE-1995-24903') } '', 'Error (CVE_RECORD_DNE): The cve record for the cve id does not exist.', 'Test printing non-existant CVE-1995-24903'; + +done_testing;