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

Added check for DHEater vulnerability and updated relevant tests (#211) #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ run_openssh_test "5.6p1" "test5" "${PROGRAM_RETVAL_FAILURE}"
echo
run_openssh_test "8.0p1" "test1" "${PROGRAM_RETVAL_FAILURE}"
run_openssh_test "8.0p1" "test2" "${PROGRAM_RETVAL_FAILURE}"
run_openssh_test "8.0p1" "test3" "${PROGRAM_RETVAL_GOOD}"
run_openssh_test "8.0p1" "test3" "${PROGRAM_RETVAL_FAILURE}"
echo
run_dropbear_test "2019.78" "test1" "-r /etc/dropbear/dropbear_rsa_host_key_1024 -r /etc/dropbear/dropbear_dss_host_key -r /etc/dropbear/dropbear_ecdsa_host_key" 3
echo
Expand Down
2 changes: 1 addition & 1 deletion src/ssh_audit/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_recommendations(self, software: Optional['Software'], for_server: bool =
else:
if faults == 0:
continue
if n in ['diffie-hellman-group-exchange-sha256', 'rsa-sha2-256', 'rsa-sha2-512', '[email protected]', '[email protected]']:
if n in ['rsa-sha2-256', 'rsa-sha2-512', '[email protected]', '[email protected]']:
rec[sshv][alg_type]['chg'][n] = faults
else:
rec[sshv][alg_type]['del'][n] = faults
Expand Down
49 changes: 25 additions & 24 deletions src/ssh_audit/ssh2_kexdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SSH2_KexDB: # pylint: disable=too-few-public-methods
FAIL_UNKNOWN = 'using unknown algorithm'
FAIL_UNPROVEN = 'using unproven algorithm'
FAIL_UNTRUSTED = 'using untrusted algorithm developed in secret by a government entity'
FAIL_DHEATER = 'vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com'

WARN_2048BIT_MODULUS = '2048-bit modulus only provides 112-bits of symmetric strength'
WARN_BLOCK_SIZE = 'using small 64-bit block size'
Expand Down Expand Up @@ -83,30 +84,30 @@ class SSH2_KexDB: # pylint: disable=too-few-public-methods
'[email protected]': [['6.4,d2013.62,l10.6.0'], [], [], [INFO_DEFAULT_OPENSSH_KEX]],
'curve448-sha512': [[]],
'[email protected]': [[]],
'diffie-hellman-group14-sha1': [['3.9,d0.53,l10.6.0'], [FAIL_SHA1], [WARN_2048BIT_MODULUS]],
'[email protected]': [[]],
'diffie-hellman-group14-sha256': [['7.3,d2016.73'], [], [WARN_2048BIT_MODULUS]],
'[email protected]': [[], [], [WARN_2048BIT_MODULUS]],
'diffie-hellman-group15-sha256': [[]],
'[email protected]': [[]],
'[email protected]': [[]],
'diffie-hellman-group15-sha512': [[]],
'diffie-hellman-group16-sha256': [[]],
'[email protected]': [[]],
'diffie-hellman-group16-sha512': [['7.3,d2016.73']],
'[email protected]': [[]],
'diffie-hellman-group17-sha512': [[]],
'diffie-hellman_group17-sha512': [[]],
'diffie-hellman-group18-sha512': [['7.3']],
'[email protected]': [[]],
'diffie-hellman-group1-sha1': [['2.3.0,d0.28,l10.2', '6.6', '6.9'], [FAIL_1024BIT_MODULUS, FAIL_LOGJAM_ATTACK, FAIL_SHA1], [], [INFO_REMOVED_IN_OPENSSH69]],
'diffie-hellman-group1-sha256': [[], [FAIL_1024BIT_MODULUS]],
'diffie-hellman-group-exchange-sha1': [['2.3.0', '6.6', None], [FAIL_SHA1]],
'[email protected]': [[]],
'diffie-hellman-group-exchange-sha256': [['4.4']],
'[email protected]': [[]],
'[email protected]': [[]],
'[email protected]': [[]],
'diffie-hellman-group14-sha1': [['3.9,d0.53,l10.6.0'], [FAIL_SHA1, FAIL_DHEATER], [WARN_2048BIT_MODULUS]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group14-sha256': [['7.3,d2016.73'], [FAIL_DHEATER], [WARN_2048BIT_MODULUS]],
'[email protected]': [[], [FAIL_DHEATER], [WARN_2048BIT_MODULUS]],
'diffie-hellman-group15-sha256': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group15-sha512': [[], [FAIL_DHEATER]],
'diffie-hellman-group16-sha256': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group16-sha512': [['7.3,d2016.73'], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group17-sha512': [[], [FAIL_DHEATER]],
'diffie-hellman_group17-sha512': [[], [FAIL_DHEATER]],
'diffie-hellman-group18-sha512': [['7.3'], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group1-sha1': [['2.3.0,d0.28,l10.2', '6.6', '6.9'], [FAIL_1024BIT_MODULUS, FAIL_LOGJAM_ATTACK, FAIL_SHA1, FAIL_DHEATER], [], [INFO_REMOVED_IN_OPENSSH69]],
'diffie-hellman-group1-sha256': [[], [FAIL_1024BIT_MODULUS, FAIL_DHEATER]],
'diffie-hellman-group-exchange-sha1': [['2.3.0', '6.6', None], [FAIL_SHA1, FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'diffie-hellman-group-exchange-sha256': [['4.4'], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_DHEATER]],
'[email protected]': [[], [FAIL_NSA_BACKDOORED_CURVE]],
'[email protected]': [[], [FAIL_NSA_BACKDOORED_CURVE]],
'[email protected]': [[], [FAIL_NSA_BACKDOORED_CURVE]],
Expand Down
22 changes: 9 additions & 13 deletions test/docker/expected_results/dropbear_2019.78_test1.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
{
"algorithm": "diffie-hellman-group14-sha256",
"notes": {
"fail": [
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"available since OpenSSH 7.3, Dropbear SSH 2016.73"
],
Expand All @@ -155,7 +158,8 @@
"algorithm": "diffie-hellman-group14-sha1",
"notes": {
"fail": [
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"available since OpenSSH 3.9, Dropbear SSH 0.53"
Expand Down Expand Up @@ -278,6 +282,10 @@
"name": "diffie-hellman-group14-sha1",
"notes": ""
},
{
"name": "diffie-hellman-group14-sha256",
"notes": ""
},
{
"name": "ecdh-sha2-nistp256",
"notes": ""
Expand Down Expand Up @@ -328,12 +336,6 @@
"name": "twofish256-ctr",
"notes": ""
}
],
"kex": [
{
"name": "diffie-hellman-group16-sha512",
"notes": ""
}
]
}
},
Expand All @@ -349,12 +351,6 @@
"notes": ""
}
],
"kex": [
{
"name": "diffie-hellman-group14-sha256",
"notes": ""
}
],
"mac": [
{
"name": "hmac-sha2-256",
Expand Down
7 changes: 4 additions & 3 deletions test/docker/expected_results/dropbear_2019.78_test1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
`- [info] available since OpenSSH 5.7, Dropbear SSH 2013.62
(kex) ecdh-sha2-nistp256 -- [fail] using elliptic curves that are suspected as being backdoored by the U.S. National Security Agency
`- [info] available since OpenSSH 5.7, Dropbear SSH 2013.62
(kex) diffie-hellman-group14-sha256 -- [warn] 2048-bit modulus only provides 112-bits of symmetric strength
(kex) diffie-hellman-group14-sha256 -- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
 `- [warn] 2048-bit modulus only provides 112-bits of symmetric strength
`- [info] available since OpenSSH 7.3, Dropbear SSH 2016.73
(kex) diffie-hellman-group14-sha1 -- [fail] using broken SHA-1 hash algorithm
 `- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
 `- [warn] 2048-bit modulus only provides 112-bits of symmetric strength
`- [info] available since OpenSSH 3.9, Dropbear SSH 0.53
(kex) [email protected] -- [info] available since Dropbear SSH 2013.57
Expand Down Expand Up @@ -66,6 +68,7 @@
(rec) -3des-cbc -- enc algorithm to remove 
(rec) -3des-ctr -- enc algorithm to remove 
(rec) -diffie-hellman-group14-sha1 -- kex algorithm to remove 
(rec) -diffie-hellman-group14-sha256 -- kex algorithm to remove 
(rec) -ecdh-sha2-nistp256 -- kex algorithm to remove 
(rec) -ecdh-sha2-nistp384 -- kex algorithm to remove 
(rec) -ecdh-sha2-nistp521 -- kex algorithm to remove 
Expand All @@ -74,12 +77,10 @@
(rec) -hmac-sha1-96 -- mac algorithm to remove 
(rec) -ssh-dss -- key algorithm to remove 
(rec) -ssh-rsa -- key algorithm to remove 
(rec) +diffie-hellman-group16-sha512 -- kex algorithm to append 
(rec) +twofish128-ctr -- enc algorithm to append 
(rec) +twofish256-ctr -- enc algorithm to append 
(rec) -aes128-cbc -- enc algorithm to remove 
(rec) -aes256-cbc -- enc algorithm to remove 
(rec) -diffie-hellman-group14-sha256 -- kex algorithm to remove 
(rec) -hmac-sha2-256 -- mac algorithm to remove 

# additional info
Expand Down
6 changes: 4 additions & 2 deletions test/docker/expected_results/openssh_4.0p1_test1.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@
"algorithm": "diffie-hellman-group14-sha1",
"notes": {
"fail": [
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"available since OpenSSH 3.9, Dropbear SSH 0.53"
Expand All @@ -296,7 +297,8 @@
"fail": [
"using small 1024-bit modulus",
"vulnerable to the Logjam attack: https://en.wikipedia.org/wiki/Logjam_(computer_security)",
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"removed in OpenSSH 6.9: https://www.openssh.com/txt/release-6.9",
Expand Down
2 changes: 2 additions & 0 deletions test/docker/expected_results/openssh_4.0p1_test1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
(kex) diffie-hellman-group-exchange-sha1 (1024-bit) -- [fail] using small 1024-bit modulus
`- [info] available since OpenSSH 2.3.0
(kex) diffie-hellman-group14-sha1 -- [fail] using broken SHA-1 hash algorithm
 `- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
 `- [warn] 2048-bit modulus only provides 112-bits of symmetric strength
`- [info] available since OpenSSH 3.9, Dropbear SSH 0.53
(kex) diffie-hellman-group1-sha1 -- [fail] using small 1024-bit modulus
 `- [fail] vulnerable to the Logjam attack: https://en.wikipedia.org/wiki/Logjam_(computer_security)
 `- [fail] using broken SHA-1 hash algorithm
 `- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
`- [info] available since OpenSSH 2.3.0, Dropbear SSH 0.28
`- [info] removed in OpenSSH 6.9: https://www.openssh.com/txt/release-6.9

Expand Down
18 changes: 8 additions & 10 deletions test/docker/expected_results/openssh_5.6p1_test1.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@
"algorithm": "diffie-hellman-group14-sha1",
"notes": {
"fail": [
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"available since OpenSSH 3.9, Dropbear SSH 0.53"
Expand All @@ -295,7 +296,8 @@
"fail": [
"using small 1024-bit modulus",
"vulnerable to the Logjam attack: https://en.wikipedia.org/wiki/Logjam_(computer_security)",
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"removed in OpenSSH 6.9: https://www.openssh.com/txt/release-6.9",
Expand Down Expand Up @@ -435,14 +437,6 @@
],
"recommendations": {
"critical": {
"chg": {
"kex": [
{
"name": "diffie-hellman-group-exchange-sha256",
"notes": "increase modulus size to 3072 bits or larger"
}
]
},
"del": {
"enc": [
{
Expand Down Expand Up @@ -486,6 +480,10 @@
{
"name": "diffie-hellman-group-exchange-sha1",
"notes": ""
},
{
"name": "diffie-hellman-group-exchange-sha256",
"notes": ""
}
],
"key": [
Expand Down
4 changes: 3 additions & 1 deletion test/docker/expected_results/openssh_5.6p1_test1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
(kex) diffie-hellman-group-exchange-sha1 (1024-bit) -- [fail] using small 1024-bit modulus
`- [info] available since OpenSSH 2.3.0
(kex) diffie-hellman-group14-sha1 -- [fail] using broken SHA-1 hash algorithm
 `- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
 `- [warn] 2048-bit modulus only provides 112-bits of symmetric strength
`- [info] available since OpenSSH 3.9, Dropbear SSH 0.53
(kex) diffie-hellman-group1-sha1 -- [fail] using small 1024-bit modulus
 `- [fail] vulnerable to the Logjam attack: https://en.wikipedia.org/wiki/Logjam_(computer_security)
 `- [fail] using broken SHA-1 hash algorithm
 `- [fail] vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com
`- [info] available since OpenSSH 2.3.0, Dropbear SSH 0.28
`- [info] removed in OpenSSH 6.9: https://www.openssh.com/txt/release-6.9

Expand Down Expand Up @@ -105,14 +107,14 @@
(fin) ssh-rsa: SHA256:YZ457EBcJTSxRKI3yXRgtAj3PBf5B9/F36b1SVooml4

# algorithm recommendations (for OpenSSH 5.6)
(rec) !diffie-hellman-group-exchange-sha256 -- kex algorithm to change (increase modulus size to 3072 bits or larger) 
(rec) -3des-cbc -- enc algorithm to remove 
(rec) -arcfour -- enc algorithm to remove 
(rec) -arcfour128 -- enc algorithm to remove 
(rec) -arcfour256 -- enc algorithm to remove 
(rec) -blowfish-cbc -- enc algorithm to remove 
(rec) -cast128-cbc -- enc algorithm to remove 
(rec) -diffie-hellman-group-exchange-sha1 -- kex algorithm to remove 
(rec) -diffie-hellman-group-exchange-sha256 -- kex algorithm to remove 
(rec) -diffie-hellman-group1-sha1 -- kex algorithm to remove 
(rec) -diffie-hellman-group14-sha1 -- kex algorithm to remove 
(rec) -hmac-md5 -- mac algorithm to remove 
Expand Down
18 changes: 8 additions & 10 deletions test/docker/expected_results/openssh_5.6p1_test2.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@
"algorithm": "diffie-hellman-group14-sha1",
"notes": {
"fail": [
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"available since OpenSSH 3.9, Dropbear SSH 0.53"
Expand All @@ -295,7 +296,8 @@
"fail": [
"using small 1024-bit modulus",
"vulnerable to the Logjam attack: https://en.wikipedia.org/wiki/Logjam_(computer_security)",
"using broken SHA-1 hash algorithm"
"using broken SHA-1 hash algorithm",
"vulnerable to the DHEater DOS attacks: CVE-2002-20001 and CVE-2022-40735. More info: https://dheatattack.com"
],
"info": [
"removed in OpenSSH 6.9: https://www.openssh.com/txt/release-6.9",
Expand Down Expand Up @@ -437,14 +439,6 @@
],
"recommendations": {
"critical": {
"chg": {
"kex": [
{
"name": "diffie-hellman-group-exchange-sha256",
"notes": "increase modulus size to 3072 bits or larger"
}
]
},
"del": {
"enc": [
{
Expand Down Expand Up @@ -488,6 +482,10 @@
{
"name": "diffie-hellman-group-exchange-sha1",
"notes": ""
},
{
"name": "diffie-hellman-group-exchange-sha256",
"notes": ""
}
],
"key": [
Expand Down
Loading
Loading