diff --git a/dojo/tools/nancy/parser.py b/dojo/tools/nancy/parser.py index 52b45bc52ee..2d4f4d986eb 100644 --- a/dojo/tools/nancy/parser.py +++ b/dojo/tools/nancy/parser.py @@ -1,6 +1,7 @@ import json from cvss.cvss3 import CVSS3 +from cvss.cvss4 import CVSS4 from dojo.models import Finding @@ -64,17 +65,18 @@ def get_items(self, vulnerable, test): out_of_scope=False, static_finding=True, dynamic_finding=False, - vuln_id_from_tool=associated_vuln["Id"], + vuln_id_from_tool=associated_vuln.get("Id", associated_vuln.get("ID")), references="\n".join(references), ) - finding.unsaved_vulnerability_ids = vulnerability_ids - + cvss_vector = associated_vuln["CvssVector"] # CVSSv3 vector - if associated_vuln["CvssVector"]: + if cvss_vector and cvss_vector.startswith("CVSS:3."): finding.cvssv3 = CVSS3( associated_vuln["CvssVector"]).clean_vector() - + elif cvss_vector and cvss_vector.startswith("CVSS:4."): + finding.cvssv4 = CVSS4( + associated_vuln["CvssVector"]).clean_vector() # do we have a CWE? if associated_vuln["Title"].startswith("CWE-"): cwe = (associated_vuln["Title"] diff --git a/unittests/scans/nancy/issue_12860.json b/unittests/scans/nancy/issue_12860.json new file mode 100644 index 00000000000..d2b767c2b88 --- /dev/null +++ b/unittests/scans/nancy/issue_12860.json @@ -0,0 +1,147 @@ +{ + "audited": [ + { + "Coordinates": "pkg:golang/github.com/ulikunitz/xz@v0.5.9", + "Reference": "https://ossindex.sonatype.org/component/pkg:golang/github.com/ulikunitz/xz@v0.5.9?utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Vulnerabilities": [ + { + "ID": "CVE-2025-58058", + "Title": "[CVE-2025-58058] CWE-770: Allocation of Resources Without Limits or Throttling", + "Description": "xz is a pure golang package for reading and writing xz-compressed files. Prior to version 0.5.14, it is possible to put data in front of an LZMA-encoded byte stream without detecting the situation while reading the header. This can lead to increased memory consumption because the current implementation allocates the full decoding buffer directly after reading the header. The LZMA header doesn't include a magic number or has a checksum to detect such an issue according to the specification. Note that the code recognizes the issue later while reading the stream, but at this time the memory allocation has already been done. This issue has been patched in version 0.5.14.", + "CvssScore": "5.3", + "CvssVector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", + "Cve": "CVE-2025-58058", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2025-58058?component-type=golang&component-name=github.com%2Fulikunitz%2Fxz&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + } + ], + "InvalidSemVer": false + }, + { + "Coordinates": "pkg:golang/golang.org/x/crypto@v0.0.0-20190227175134-215aa809caaf", + "Reference": "https://ossindex.sonatype.org/component/pkg:golang/golang.org/x/crypto@v0.0.0-20190227175134-215aa809caaf?utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Vulnerabilities": [ + { + "ID": "CVE-2022-27191", + "Title": "[CVE-2022-27191] CWE-noinfo", + "Description": "The golang.org/x/crypto/ssh package before 0.0.0-20220314234659-1baeb1ce4c0b for Go allows an attacker to crash a server in certain circumstances involving AddHostKey.", + "CvssScore": "7.5", + "CvssVector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "Cve": "CVE-2022-27191", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2022-27191?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2023-48795", + "Title": "[CVE-2023-48795] CWE-354: Improper Validation of Integrity Check Value", + "Description": "The SSH transport protocol with certain OpenSSH extensions, found in OpenSSH before 9.6 and other products, allows remote attackers to bypass integrity checks such that some packets are omitted (from the extension negotiation message), and a client and server may consequently end up with a connection for which some security features have been downgraded or disabled, aka a Terrapin attack. This occurs because the SSH Binary Packet Protocol (BPP), implemented by these extensions, mishandles the handshake phase and mishandles use of sequence numbers. For example, there is an effective attack against SSH's use of ChaCha20-Poly1305 (and CBC with Encrypt-then-MAC). The bypass occurs in chacha20-poly1305@openssh.com and (if CBC is used) the -etm@openssh.com MAC algorithms. This also affects Maverick Synergy Java SSH API before 3.1.0-SNAPSHOT, Dropbear through 2022.83, Ssh before 5.1.1 in Erlang/OTP, PuTTY before 0.80, AsyncSSH before 2.14.2, golang.org/x/crypto before 0.17.0, libssh before 0.10.6, libssh2 through 1.11.0, Thorn Tech SFTP Gateway before 3.4.6, Tera Term before 5.1, Paramiko before 3.4.0, jsch before 0.2.15, SFTPGo before 2.5.6, Netgate pfSense Plus through 23.09.1, Netgate pfSense CE through 2.7.2, HPN-SSH through 18.2.0, ProFTPD before 1.3.8b (and before 1.3.9rc2), ORYX CycloneSSH before 2.3.4, NetSarang XShell 7 before Build 0144, CrushFTP before 10.6.0, ConnectBot SSH library before 2.2.22, Apache MINA sshd through 2.11.0, sshj through 0.37.0, TinySSH through 20230101, trilead-ssh2 6401, LANCOM LCOS and LANconfig, FileZilla before 3.66.4, Nova before 11.8, PKIX-SSH before 14.4, SecureCRT before 9.4.3, Transmit5 before 5.10.4, Win32-OpenSSH before 9.5.0.0p1-Beta, WinSCP before 6.2.2, Bitvise SSH Server before 9.32, Bitvise SSH Client before 9.33, KiTTY through 0.76.1.13, the net-ssh gem 7.2.0 for Ruby, the mscdex ssh2 module before 1.15.0 for Node.js, the thrussh library before 0.35.1 for Rust, and the Russh crate before 0.40.2 for Rust.\n\nSonatype's research suggests that this CVE's details differ from those defined at NVD. See https://ossindex.sonatype.org/vulnerability/CVE-2023-48795 for details", + "CvssScore": "5.9", + "CvssVector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N", + "Cve": "CVE-2023-48795", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2023-48795?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2024-45337", + "Title": "[CVE-2024-45337] CWE-863: Incorrect Authorization", + "Description": "Applications and libraries which misuse connection.serverAuthenticate (via callback field ServerConfig.PublicKeyCallback) may be susceptible to an authorization bypass. The documentation for ServerConfig.PublicKeyCallback says that \"A call to this function does not guarantee that the key offered is in fact used to authenticate.\" Specifically, the SSH protocol allows clients to inquire about whether a public key is acceptable before proving control of the corresponding private key. PublicKeyCallback may be called with multiple keys, and the order in which the keys were provided cannot be used to infer which key the client successfully authenticated with, if any. Some applications, which store the key(s) passed to PublicKeyCallback (or derived information) and make security relevant determinations based on it once the connection is established, may make incorrect assumptions. For example, an attacker may send public keys A and B, and then authenticate with A. PublicKeyCallback would be called only twice, first with A and then with B. A vulnerable application may then make authorization decisions based on key B for which the attacker does not actually control the private key. Since this API is widely misused, as a partial mitigation golang.org/x/cry...@v0.31.0 enforces the property that, when successfully authenticating via public key, the last key passed to ServerConfig.PublicKeyCallback will be the key used to authenticate the connection. PublicKeyCallback will now be called multiple times with the same key, if necessary. Note that the client may still not control the last key passed to PublicKeyCallback if the connection is then authenticated with a different method, such as PasswordCallback, KeyboardInteractiveCallback, or NoClientAuth. Users should be using the Extensions field of the Permissions return value from the various authentication callbacks to record data associated with the authentication attempt instead of referencing external state. Once the connection is established the state corresponding to the successful authentication attempt can be retrieved via the ServerConn.Permissions field. Note that some third-party libraries misuse the Permissions type by sharing it across authentication attempts; users of third-party libraries should refer to the relevant projects for guidance.", + "CvssScore": "7.6", + "CvssVector": "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N", + "Cve": "CVE-2024-45337", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2024-45337?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2025-22869", + "Title": "[CVE-2025-22869] CWE-770: Allocation of Resources Without Limits or Throttling", + "Description": "SSH servers which implement file transfer protocols are vulnerable to a denial of service attack from clients which complete the key exchange slowly, or not at all, causing pending content to be read into memory, but never transmitted.", + "CvssScore": "6.9", + "CvssVector": "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N", + "Cve": "CVE-2025-22869", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2025-22869?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + } + ], + "InvalidSemVer": false + }, + { + "Coordinates": "pkg:golang/golang.org/x/text@v0.3.0", + "Reference": "https://ossindex.sonatype.org/component/pkg:golang/golang.org/x/text@v0.3.0?utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Vulnerabilities": [], + "InvalidSemVer": false + } + ], + "excluded": null, + "exclusions": [], + "invalid": [], + "num_audited": 3, + "num_exclusions": 0, + "num_vulnerable": 2, + "version": "1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "vulnerable": [ + { + "Coordinates": "pkg:golang/github.com/ulikunitz/xz@v0.5.9", + "Reference": "https://ossindex.sonatype.org/component/pkg:golang/github.com/ulikunitz/xz@v0.5.9?utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Vulnerabilities": [ + { + "ID": "CVE-2025-58058", + "Title": "[CVE-2025-58058] CWE-770: Allocation of Resources Without Limits or Throttling", + "Description": "xz is a pure golang package for reading and writing xz-compressed files. Prior to version 0.5.14, it is possible to put data in front of an LZMA-encoded byte stream without detecting the situation while reading the header. This can lead to increased memory consumption because the current implementation allocates the full decoding buffer directly after reading the header. The LZMA header doesn't include a magic number or has a checksum to detect such an issue according to the specification. Note that the code recognizes the issue later while reading the stream, but at this time the memory allocation has already been done. This issue has been patched in version 0.5.14.", + "CvssScore": "5.3", + "CvssVector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", + "Cve": "CVE-2025-58058", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2025-58058?component-type=golang&component-name=github.com%2Fulikunitz%2Fxz&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + } + ], + "InvalidSemVer": false + }, + { + "Coordinates": "pkg:golang/golang.org/x/crypto@v0.0.0-20190227175134-215aa809caaf", + "Reference": "https://ossindex.sonatype.org/component/pkg:golang/golang.org/x/crypto@v0.0.0-20190227175134-215aa809caaf?utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Vulnerabilities": [ + { + "ID": "CVE-2022-27191", + "Title": "[CVE-2022-27191] CWE-noinfo", + "Description": "The golang.org/x/crypto/ssh package before 0.0.0-20220314234659-1baeb1ce4c0b for Go allows an attacker to crash a server in certain circumstances involving AddHostKey.", + "CvssScore": "7.5", + "CvssVector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", + "Cve": "CVE-2022-27191", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2022-27191?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2023-48795", + "Title": "[CVE-2023-48795] CWE-354: Improper Validation of Integrity Check Value", + "Description": "The SSH transport protocol with certain OpenSSH extensions, found in OpenSSH before 9.6 and other products, allows remote attackers to bypass integrity checks such that some packets are omitted (from the extension negotiation message), and a client and server may consequently end up with a connection for which some security features have been downgraded or disabled, aka a Terrapin attack. This occurs because the SSH Binary Packet Protocol (BPP), implemented by these extensions, mishandles the handshake phase and mishandles use of sequence numbers. For example, there is an effective attack against SSH's use of ChaCha20-Poly1305 (and CBC with Encrypt-then-MAC). The bypass occurs in chacha20-poly1305@openssh.com and (if CBC is used) the -etm@openssh.com MAC algorithms. This also affects Maverick Synergy Java SSH API before 3.1.0-SNAPSHOT, Dropbear through 2022.83, Ssh before 5.1.1 in Erlang/OTP, PuTTY before 0.80, AsyncSSH before 2.14.2, golang.org/x/crypto before 0.17.0, libssh before 0.10.6, libssh2 through 1.11.0, Thorn Tech SFTP Gateway before 3.4.6, Tera Term before 5.1, Paramiko before 3.4.0, jsch before 0.2.15, SFTPGo before 2.5.6, Netgate pfSense Plus through 23.09.1, Netgate pfSense CE through 2.7.2, HPN-SSH through 18.2.0, ProFTPD before 1.3.8b (and before 1.3.9rc2), ORYX CycloneSSH before 2.3.4, NetSarang XShell 7 before Build 0144, CrushFTP before 10.6.0, ConnectBot SSH library before 2.2.22, Apache MINA sshd through 2.11.0, sshj through 0.37.0, TinySSH through 20230101, trilead-ssh2 6401, LANCOM LCOS and LANconfig, FileZilla before 3.66.4, Nova before 11.8, PKIX-SSH before 14.4, SecureCRT before 9.4.3, Transmit5 before 5.10.4, Win32-OpenSSH before 9.5.0.0p1-Beta, WinSCP before 6.2.2, Bitvise SSH Server before 9.32, Bitvise SSH Client before 9.33, KiTTY through 0.76.1.13, the net-ssh gem 7.2.0 for Ruby, the mscdex ssh2 module before 1.15.0 for Node.js, the thrussh library before 0.35.1 for Rust, and the Russh crate before 0.40.2 for Rust.\n\nSonatype's research suggests that this CVE's details differ from those defined at NVD. See https://ossindex.sonatype.org/vulnerability/CVE-2023-48795 for details", + "CvssScore": "5.9", + "CvssVector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N", + "Cve": "CVE-2023-48795", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2023-48795?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2024-45337", + "Title": "[CVE-2024-45337] CWE-863: Incorrect Authorization", + "Description": "Applications and libraries which misuse connection.serverAuthenticate (via callback field ServerConfig.PublicKeyCallback) may be susceptible to an authorization bypass. The documentation for ServerConfig.PublicKeyCallback says that \"A call to this function does not guarantee that the key offered is in fact used to authenticate.\" Specifically, the SSH protocol allows clients to inquire about whether a public key is acceptable before proving control of the corresponding private key. PublicKeyCallback may be called with multiple keys, and the order in which the keys were provided cannot be used to infer which key the client successfully authenticated with, if any. Some applications, which store the key(s) passed to PublicKeyCallback (or derived information) and make security relevant determinations based on it once the connection is established, may make incorrect assumptions. For example, an attacker may send public keys A and B, and then authenticate with A. PublicKeyCallback would be called only twice, first with A and then with B. A vulnerable application may then make authorization decisions based on key B for which the attacker does not actually control the private key. Since this API is widely misused, as a partial mitigation golang.org/x/cry...@v0.31.0 enforces the property that, when successfully authenticating via public key, the last key passed to ServerConfig.PublicKeyCallback will be the key used to authenticate the connection. PublicKeyCallback will now be called multiple times with the same key, if necessary. Note that the client may still not control the last key passed to PublicKeyCallback if the connection is then authenticated with a different method, such as PasswordCallback, KeyboardInteractiveCallback, or NoClientAuth. Users should be using the Extensions field of the Permissions return value from the various authentication callbacks to record data associated with the authentication attempt instead of referencing external state. Once the connection is established the state corresponding to the successful authentication attempt can be retrieved via the ServerConn.Permissions field. Note that some third-party libraries misuse the Permissions type by sharing it across authentication attempts; users of third-party libraries should refer to the relevant projects for guidance.", + "CvssScore": "7.6", + "CvssVector": "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N", + "Cve": "CVE-2024-45337", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2024-45337?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + }, + { + "ID": "CVE-2025-22869", + "Title": "[CVE-2025-22869] CWE-770: Allocation of Resources Without Limits or Throttling", + "Description": "SSH servers which implement file transfer protocols are vulnerable to a denial of service attack from clients which complete the key exchange slowly, or not at all, causing pending content to be read into memory, but never transmitted.", + "CvssScore": "6.9", + "CvssVector": "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N", + "Cve": "CVE-2025-22869", + "Reference": "https://ossindex.sonatype.org/vulnerability/CVE-2025-22869?component-type=golang&component-name=golang.org%2Fx%2Fcrypto&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.52-next-c4870647da6f9c6f78060307eacc7267a8d81b4d", + "Excluded": false + } + ], + "InvalidSemVer": false + } + ] +} \ No newline at end of file diff --git a/unittests/tools/test_nancy_parser.py b/unittests/tools/test_nancy_parser.py index bd21cc44adc..09b3194360d 100644 --- a/unittests/tools/test_nancy_parser.py +++ b/unittests/tools/test_nancy_parser.py @@ -35,3 +35,14 @@ def test_nancy_plus_parser_with_many_vuln_has_many_findings(self): self.assertEqual(0, finding.cwe) self.assertIsNotNone(finding.description) self.assertGreater(len(finding.description), 0) + + def test_nancy_issue_12860(self): + with (get_unit_tests_scans_path("nancy") / "issue_12860.json").open(encoding="utf-8") as testfile: + parser = NancyParser() + findings = parser.get_findings(testfile, Test()) + self.assertEqual(5, len(findings)) + with self.subTest(i=0): + finding = findings[0] + self.assertEqual("[CVE-2025-58058] CWE-770: Allocation of Resources Without Limits or Throttling", finding.title) + finding = findings[3] + self.assertEqual("[CVE-2024-45337] CWE-863: Incorrect Authorization", finding.title)