Skip to content

Commit 43fc23e

Browse files
Isma399Ismaël Tanguy
and
Ismaël Tanguy
authored
fix: catch cidr network in ssh keys (#236)
Co-authored-by: Ismaël Tanguy <[email protected]>
1 parent 3bd4078 commit 43fc23e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: bin/hardening/99.5.2.4_ssh_keys_from.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DESCRIPTION="Check <from> field in ssh authorized keys files for users with logi
1919

2020
# Regex looking for empty, hash starting lines, or 'from="127.127.127,127.127.127" ssh'
2121
# shellcheck disable=2089
22-
REGEX_FROM_IP="from=(?:'|\")(,?(\d{1,3}(\.\d{1,3}){3}))+(?:'|\")"
22+
REGEX_FROM_IP="from=(?:'|\")(,?(\d{1,3}(\.\d{1,3}){3})(\/\d{1,2})?)+(?:'|\")"
2323
REGEX_OK_LINES="(^(#|$)|($REGEX_FROM_IP))"
2424
AUTHKEYFILE_PATTERN=""
2525
AUTHKEYFILE_PATTERN_DEFAULT=".ssh/authorized_keys .ssh/authorized_keys2"

Diff for: tests/hardening/99.5.2.4_ssh_keys_from.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ test_audit() {
7272
run allwdfromip "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
7373

7474
# shellcheck disable=2016
75-
echo 'ALLOWED_IPS="$ALLOWED_IPS 127.0.0.1,10.2.3.1"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
75+
echo 'ALLOWED_IPS="$ALLOWED_IPS 127.0.0.1,10.2.3.1/8"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
7676
{
7777
echo -n 'from="10.0.1.2",command="echo bla" '
7878
cat /tmp/key1.pub
79-
echo -n 'command="echo bla,from="10.0.1.2,10.2.3.1"" '
79+
echo -n 'command="echo bla,from="10.0.1.2,10.2.3.1/8"" '
8080
cat /tmp/key1.pub
8181
} >>/home/secaudit/.ssh/authorized_keys2
8282
describe Key with from and command options

0 commit comments

Comments
 (0)