-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11998 from mpurg/ubuntu_2204_stig_251025
Add SCE check for ufw_rate_limit for Ubuntu
- Loading branch information
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
linux_os/guide/system/network/network-ufw/ufw_rate_limit/sce/shared.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# check-import = stdout | ||
|
||
ufw_status="$(ufw status verbose)" | ||
|
||
# check ufw is running | ||
if grep -q "Status: inactive" <<< "$ufw_status"; then | ||
exit $XCCDF_RESULT_FAIL | ||
fi | ||
|
||
# check default incoming rule is not allow | ||
if grep -q "Default: allow (incoming)" <<< "$ufw_status"; then | ||
exit $XCCDF_RESULT_FAIL | ||
fi | ||
|
||
# check that listening ports which are open in the firewall are | ||
# not "ALLOW IN", and are thus rate-limited, deny or rejected, or | ||
# or using the default rule | ||
while read -r lpn; | ||
do | ||
if grep -Pq "^\h*$lpn\b.*ALLOW IN" <<< "$ufw_status"; then | ||
exit $XCCDF_RESULT_FAIL | ||
fi | ||
done < <(ss -tulnH | awk '{n=split($5, a, ":"); print a[n]}' | sort -u) | ||
|
||
exit $XCCDF_RESULT_PASS |
12 changes: 12 additions & 0 deletions
12
linux_os/guide/system/network/network-ufw/ufw_rate_limit/tests/allow.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# platforms = multi_platform_ubuntu | ||
# packages = ufw | ||
# remediation = none | ||
|
||
source common.sh | ||
|
||
ufw allow 22 | ||
ufw limit 53 | ||
ufw deny 631 | ||
ufw -f enable | ||
|
19 changes: 19 additions & 0 deletions
19
linux_os/guide/system/network/network-ufw/ufw_rate_limit/tests/common.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# mock `ss -tulnH` | ||
|
||
cat > /usr/local/bin/ss <<EOF | ||
cat <<FOE | ||
udp UNCONN 0 0 127.0.0.53%lo:53 0.0.0.0:* | ||
udp UNCONN 0 0 0.0.0.0:631 0.0.0.0:* | ||
tcp LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* | ||
tcp LISTEN 0 128 127.0.0.1:631 0.0.0.0:* | ||
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* | ||
tcp LISTEN 0 128 [::1]:631 [::]:* | ||
tcp LISTEN 0 128 [::]:22 [::]:* | ||
FOE | ||
EOF | ||
chmod +x /usr/local/bin/ss | ||
|
||
ufw disable | ||
ufw -f reset |
10 changes: 10 additions & 0 deletions
10
linux_os/guide/system/network/network-ufw/ufw_rate_limit/tests/correct.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
# platforms = multi_platform_ubuntu | ||
# packages = ufw | ||
|
||
source common.sh | ||
|
||
ufw limit 22 | ||
ufw limit 53 | ||
ufw deny 631 | ||
ufw -f enable |
8 changes: 8 additions & 0 deletions
8
linux_os/guide/system/network/network-ufw/ufw_rate_limit/tests/default_allow.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# platforms = multi_platform_ubuntu | ||
# packages = ufw | ||
|
||
source common.sh | ||
|
||
ufw default allow | ||
ufw -f enable |
7 changes: 7 additions & 0 deletions
7
linux_os/guide/system/network/network-ufw/ufw_rate_limit/tests/disabled.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# platforms = multi_platform_ubuntu | ||
# packages = ufw | ||
|
||
source common.sh | ||
|
||
ufw -f disable |