Skip to content

Commit

Permalink
Merge pull request #85 from Ostorlab/fix/fix_truncate_description
Browse files Browse the repository at this point in the history
Fix: don't truncate description.
  • Loading branch information
3asm authored Jun 14, 2024
2 parents ee72d18 + b91fac6 commit 3d898d1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions agent/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def minify_dict(
if isinstance(value, list):
return [minify_dict(v, handler) for v in value]
elif isinstance(value, dict):
new_dict = value.copy()
for key, v in value.items():
value[key] = minify_dict(v, handler)
return value
new_dict[key] = minify_dict(v, handler)
return new_dict
else:
return handler(value, truncate_size)
19 changes: 19 additions & 0 deletions tests/agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,22 @@ def testAgentNuclei_whenProxyIsProvided_shouldCallWithProxyArg(
assert "/nuclei/nuclei" in command
assert "-proxy" in command
assert "https://proxy.co" in command


@mock.patch("agent.agent_nuclei.OUTPUT_PATH", "./tests/result_nuclei_long.json")
def testAgentNuclei_whenDescriptionIsLong_shouldNotTruncate(
scan_message_link_with_basic_credential: message.Message,
nuclei_agent_no_url_scope: agent_nuclei.AgentNuclei,
mocker: plugin.MockerFixture,
agent_mock: list[message.Message],
) -> None:
"""Ensure that AgentNuclei runs the nuclei command with the basic Auth header when basic credentials are given."""
mocker.patch("subprocess.run", return_value=None)

nuclei_agent_no_url_scope.process(scan_message_link_with_basic_credential)

assert "v3.report.vulnerability" in [a.selector for a in agent_mock]
assert (
agent_mock[0].data["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 [email protected] and (if CBC is used) the [email protected] 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"
)
1 change: 1 addition & 0 deletions tests/result_nuclei_long.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"template-id":"CVE-2023-48795","template-path":"/app/CVE-2023-48795.yaml","info":{"name":"OpenSSH Terrapin Attack - Detection","author":["pussycat0x"],"tags":["cve","cve2023","packetstorm","seclists","js","ssh","network","passive","openbsd"],"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 [email protected] and (if CBC is used) the [email protected] 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","reference":["https://github.com/rub-nds/terrapin-scanner","https://terrapin-attack.com/","http://packetstormsecurity.com/files/176280/terrapin-ssh-connection-weakening.html","http://seclists.org/fulldisclosure/2024/mar/21","http://www.openwall.com/lists/oss-security/2023/12/18/3"],"severity":"medium","metadata":{"vendor":"openbsd","product":"openssh","shodan-query":["product:\"OpenSSH\"","product:\"openssh\"","cpe:\"cpe:2.3:a:openbsd:openssh\""],"verified":true,"max-request":1},"classification":{"cve-id":["cve-2023-48795"],"cwe-id":["cwe-354"],"cvss-metrics":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","cvss-score":5.9,"epss-score":0.69474,"epss-percentile":0.97955,"cpe":"cpe:2.3:a:openbsd:openssh:*:*:*:*:*:*:*:*"},"remediation":"One can address this vulnerability by temporarily disabling the affected [email protected] encryption and [email protected] MAC algorithms in the configuration of the SSH server (or client), and instead utilize unaffected algorithms like AES-GCM.\n"},"type":"javascript","host":"example.com:22","port":"22","url":"example.com:22","matched-at":"example.com:22","extracted-results":["Vulnerable to Terrapin"],"request":"const m = require(\"nuclei/ssh\");\nconst c = m.SSHClient();\nconst response = c.ConnectSSHInfoMode(Host, Port);\n\nfunction SupportsChaCha20() {\n const CiphersClientServer = response.ServerKex.CiphersClientServer;\n const csexists = CiphersClientServer.includes(\"[email protected]\");\n csexists;\n const CiphersServerClient = response.ServerKex.CiphersServerClient;\n const scexist = CiphersServerClient.includes(\"[email protected]\");\n scexist;\n return csexists || scexist;\n}\n\nfunction SupportsCbcEtm() {\n const EncryCCS = response.ServerKex.CiphersClientServer;\n const EncryCCSsuf = EncryCCS.some(value =\u003e value.endsWith(\"-cbc\"));\n EncryCCSsuf;\n\n const Macacs = response.ServerKex.MACsClientServer;\n const MacacsSuf = Macacs.some(value =\u003e value.endsWith(\"[email protected]\"));\n MacacsSuf;\n\n const EncrySC = response.ServerKex.CiphersServerClient;\n const EncrySCSuf = EncrySC.some(value =\u003e value.endsWith(\"-cbc\"));\n EncrySCSuf;\n\n const Macasc = response.ServerKex.MACsServerClient;\n const MacascSuf = Macasc.some(value =\u003e value.endsWith(\"[email protected]\"));\n MacascSuf;\n return EncryCCSsuf \u0026\u0026 MacacsSuf || EncrySCSuf \u0026\u0026 MacascSuf;\n\n}\n\nfunction SupportsStrictKex() {\n const SuStrictKex = response.ServerKex.KexAlgos;\n const hasSuffix = SuStrictKex.some(value =\u003e value.endsWith(\"[email protected]\"));\n return hasSuffix;\n\n}\n\nfunction IsVulnerable() {\n const vuln = ((SupportsChaCha20() || SupportsCbcEtm()) \u0026\u0026 !SupportsStrictKex())\n if (vuln === true) {\n return (\"Vulnerable to Terrapin\");\n }\n}\nExport(IsVulnerable())","response":"Vulnerable to Terrapin","ip":"45.79.222.138","timestamp":"2024-06-14T15:41:08.064085237Z","matcher-status":true}

0 comments on commit 3d898d1

Please sign in to comment.