mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 22:02:17 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
e478a89bad | |||
371c23cd52 | |||
ea8334d516 | |||
987bb9c975 | |||
3031bb55d1 | |||
66ccc6316a | |||
7a3145d7f1 | |||
5c072668d5 | |||
d1bd1eb2e7 | |||
ad5c71c3ce | |||
33964c0a3d |
2
.github/workflows/compile-manual.yml
vendored
2
.github/workflows/compile-manual.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Produce debian man
|
- name: Produce debian man
|
||||||
run: 'docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6 MANUAL.md -s -t man > debian/cis-hardening.8'
|
run: 'docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6 MANUAL.md -s -t man > debian/cis-hardening.8'
|
||||||
- uses: EndBug/add-and-commit@v8.0.2
|
- uses: EndBug/add-and-commit@v9
|
||||||
with:
|
with:
|
||||||
add: 'debian/cis-hardening.8'
|
add: 'debian/cis-hardening.8'
|
||||||
message: 'Regenerate man pages (Github action)'
|
message: 'Regenerate man pages (Github action)'
|
||||||
|
2
.github/workflows/pre-release.yml
vendored
2
.github/workflows/pre-release.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# GET LATEST VERSION TAG
|
# GET LATEST VERSION TAG
|
||||||
- name: Get latest version tag
|
- name: Get latest version tag
|
||||||
uses: actions-ecosystem/action-get-latest-tag@v1.5.0
|
uses: actions-ecosystem/action-get-latest-tag@v1.6.0
|
||||||
id: get-latest-tag
|
id: get-latest-tag
|
||||||
# GENERATE CHANGELOG CORRESPONDING TO COMMIT BETWEEN HEAD AND COMPUTED LAST TAG
|
# GENERATE CHANGELOG CORRESPONDING TO COMMIT BETWEEN HEAD AND COMPUTED LAST TAG
|
||||||
- name: Generate changelog
|
- name: Generate changelog
|
||||||
|
@ -10,7 +10,7 @@ jobs:
|
|||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Run the sh-checker
|
- name: Run the sh-checker
|
||||||
uses: luizm/action-sh-checker@v0.3.0
|
uses: luizm/action-sh-checker@v0.4.0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional if sh_checker_comment is false.
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional if sh_checker_comment is false.
|
||||||
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
||||||
|
@ -19,16 +19,28 @@ DESCRIPTION="Set sticky bit on world writable directories to prevent users from
|
|||||||
|
|
||||||
EXCEPTIONS=''
|
EXCEPTIONS=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if setuid is set on world writable Directories"
|
info "Checking if setuid is set on world writable Directories"
|
||||||
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
|
||||||
if [ -n "$EXCEPTIONS" ]; then
|
if [ -n "$EXCEPTIONS" ]; then
|
||||||
|
# maybe EXCEPTIONS allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCEPTIONS")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex $EXCEPTIONS -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex $EXCEPTIONS -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
@ -45,7 +57,7 @@ audit() {
|
|||||||
apply() {
|
apply() {
|
||||||
if [ -n "$EXCEPTIONS" ]; then
|
if [ -n "$EXCEPTIONS" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex $EXCEPTIONS -print 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCEPTIONS" | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex "$EXCEPTIONS" -print 2>/dev/null)
|
||||||
else
|
else
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
@ -21,6 +21,7 @@ PACKAGE="iptables"
|
|||||||
FW_CHAINS="INPUT FORWARD"
|
FW_CHAINS="INPUT FORWARD"
|
||||||
FW_POLICY="DROP"
|
FW_POLICY="DROP"
|
||||||
FW_CMD="iptables"
|
FW_CMD="iptables"
|
||||||
|
FW_TIMEOUT="10"
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
@ -28,7 +29,7 @@ audit() {
|
|||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
ipt=$($SUDO_CMD "$FW_CMD" -nL 2>/dev/null || true)
|
ipt=$($SUDO_CMD "$FW_CMD" -w "$FW_TIMEOUT" -nL 2>/dev/null || true)
|
||||||
if [[ -z "$ipt" ]]; then
|
if [[ -z "$ipt" ]]; then
|
||||||
crit "Empty return from $FW_CMD command. Aborting..."
|
crit "Empty return from $FW_CMD command. Aborting..."
|
||||||
return
|
return
|
||||||
|
@ -19,17 +19,28 @@ DESCRIPTION="Ensure no world writable files exist"
|
|||||||
|
|
||||||
EXCLUDED=''
|
EXCLUDED=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if there are world writable files"
|
info "Checking if there are world writable files"
|
||||||
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
|
||||||
|
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
|
# maybe EXCLUDED allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -0002 -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -0002 -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -0002 -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -0002 -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
@ -46,7 +57,7 @@ audit() {
|
|||||||
apply() {
|
apply() {
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type f -perm -0002 -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED" | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type f -perm -0002 -regextype 'egrep' ! -regex "$EXCLUDED" -print 2>/dev/null)
|
||||||
else
|
else
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type f -perm -0002 -print 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type f -perm -0002 -print 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
@ -20,17 +20,30 @@ DESCRIPTION="Ensure no unowned files or directories exist."
|
|||||||
USER='root'
|
USER='root'
|
||||||
EXCLUDED=''
|
EXCLUDED=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if there are unowned files"
|
info "Checking if there are unowned files"
|
||||||
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
|
# maybe EXCLUDED allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nouser -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nouser -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nouser -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nouser -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
crit "Some unowned files are present"
|
crit "Some unowned files are present"
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
@ -45,7 +58,7 @@ audit() {
|
|||||||
apply() {
|
apply() {
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nouser -regextype 'egrep' ! -regex $EXCLUDED -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED" | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nouser -regextype 'egrep' ! -regex "$EXCLUDED" -ls 2>/dev/null)
|
||||||
else
|
else
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nouser -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nouser -ls 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
@ -20,17 +20,31 @@ DESCRIPTION="Ensure no ungrouped files or directories exist"
|
|||||||
GROUP='root'
|
GROUP='root'
|
||||||
EXCLUDED=''
|
EXCLUDED=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if there are ungrouped files"
|
info "Checking if there are ungrouped files"
|
||||||
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
|
# maybe EXCLUDED allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nogroup -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nogroup -regextype 'egrep' ! -regex $EXCLUDED -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
|
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nogroup -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -nogroup -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
crit "Some ungrouped files are present"
|
crit "Some ungrouped files are present"
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
@ -45,7 +59,7 @@ audit() {
|
|||||||
apply() {
|
apply() {
|
||||||
if [ -n "$EXCLUDED" ]; then
|
if [ -n "$EXCLUDED" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nogroup -regextype 'egrep' ! -regex $EXCLUDED -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCLUDED" | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nogroup -regextype 'egrep' ! -regex "$EXCLUDED" -ls 2>/dev/null)
|
||||||
else
|
else
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nogroup -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -nogroup -ls 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
@ -18,16 +18,30 @@ HARDENING_LEVEL=2
|
|||||||
DESCRIPTION="Find SUID system executables."
|
DESCRIPTION="Find SUID system executables."
|
||||||
IGNORED_PATH=''
|
IGNORED_PATH=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if there are suid files"
|
info "Checking if there are suid files"
|
||||||
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }')
|
|
||||||
# shellcheck disable=2086
|
|
||||||
if [ -n "$IGNORED_PATH" ]; then
|
if [ -n "$IGNORED_PATH" ]; then
|
||||||
|
# maybe IGNORED_PATH allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$IGNORED_PATH")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
|
# shellcheck disable=2086
|
||||||
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -4000 -regextype 'egrep' ! -regex $IGNORED_PATH -print)
|
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -4000 -regextype 'egrep' ! -regex $IGNORED_PATH -print)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
|
# shellcheck disable=2086
|
||||||
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -4000 -print)
|
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -4000 -print)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BAD_BINARIES=""
|
BAD_BINARIES=""
|
||||||
for BINARY in $FOUND_BINARIES; do
|
for BINARY in $FOUND_BINARIES; do
|
||||||
if grep -qw "$BINARY" <<<"$EXCEPTIONS"; then
|
if grep -qw "$BINARY" <<<"$EXCEPTIONS"; then
|
||||||
|
@ -18,16 +18,31 @@ HARDENING_LEVEL=2
|
|||||||
DESCRIPTION="Find SGID system executables."
|
DESCRIPTION="Find SGID system executables."
|
||||||
IGNORED_PATH=''
|
IGNORED_PATH=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
info "Checking if there are sgid files"
|
info "Checking if there are sgid files"
|
||||||
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }')
|
|
||||||
# shellcheck disable=2086
|
|
||||||
if [ -n "$IGNORED_PATH" ]; then
|
if [ -n "$IGNORED_PATH" ]; then
|
||||||
|
# maybe IGNORED_PATH allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$IGNORED_PATH")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
|
# shellcheck disable=2086
|
||||||
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -2000 -regextype 'egrep' ! -regex $IGNORED_PATH -print)
|
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -2000 -regextype 'egrep' ! -regex $IGNORED_PATH -print)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
|
|
||||||
else
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
|
# shellcheck disable=2086
|
||||||
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -2000 -print)
|
FOUND_BINARIES=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type f -perm -2000 -print)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BAD_BINARIES=""
|
BAD_BINARIES=""
|
||||||
for BINARY in $FOUND_BINARIES; do
|
for BINARY in $FOUND_BINARIES; do
|
||||||
if grep -qw "$BINARY" <<<"$EXCEPTIONS"; then
|
if grep -qw "$BINARY" <<<"$EXCEPTIONS"; then
|
||||||
|
@ -19,6 +19,7 @@ DESCRIPTION="Check 600 permissions and root:root ownership on /etc/passwd-"
|
|||||||
|
|
||||||
FILE='/etc/passwd-'
|
FILE='/etc/passwd-'
|
||||||
PERMISSIONS='600'
|
PERMISSIONS='600'
|
||||||
|
PERMISSIONSOK='644 640 600'
|
||||||
USER='root'
|
USER='root'
|
||||||
GROUP='root'
|
GROUP='root'
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ audit() {
|
|||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$FILE does not exist"
|
ok "$FILE does not exist"
|
||||||
else
|
else
|
||||||
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
has_file_one_of_permissions "$FILE" "$PERMISSIONSOK"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
|
@ -19,6 +19,7 @@ DESCRIPTION="Check 600 permissions and root:shadow ownership on /etc/shadow-"
|
|||||||
|
|
||||||
FILE='/etc/shadow-'
|
FILE='/etc/shadow-'
|
||||||
PERMISSIONS='600'
|
PERMISSIONS='600'
|
||||||
|
PERMISSIONSOK='640 600'
|
||||||
USER='root'
|
USER='root'
|
||||||
GROUP='shadow'
|
GROUP='shadow'
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ audit() {
|
|||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$FILE does not exist"
|
ok "$FILE does not exist"
|
||||||
else
|
else
|
||||||
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
has_file_one_of_permissions "$FILE" "$PERMISSIONSOK"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
|
@ -19,6 +19,7 @@ DESCRIPTION="Check 600 permissions and root:root ownership on /etc/group-"
|
|||||||
|
|
||||||
FILE='/etc/group-'
|
FILE='/etc/group-'
|
||||||
PERMISSIONS='600'
|
PERMISSIONS='600'
|
||||||
|
PERMISSIONSOK='644 640 600'
|
||||||
USER='root'
|
USER='root'
|
||||||
GROUP='root'
|
GROUP='root'
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ audit() {
|
|||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$FILE does not exist"
|
ok "$FILE does not exist"
|
||||||
else
|
else
|
||||||
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
has_file_one_of_permissions "$FILE" "$PERMISSIONSOK"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
|
@ -109,7 +109,7 @@ audit() {
|
|||||||
crit "/etc/ssh/sshd_config is not readable."
|
crit "/etc/ssh/sshd_config is not readable."
|
||||||
else
|
else
|
||||||
ret=$($SUDO_CMD grep -iP "^AuthorizedKeysFile" /etc/ssh/sshd_config || echo '#KO')
|
ret=$($SUDO_CMD grep -iP "^AuthorizedKeysFile" /etc/ssh/sshd_config || echo '#KO')
|
||||||
if [ "x$ret" = "x#KO" ]; then
|
if [ "$ret" = "#KO" ]; then
|
||||||
debug "No AuthorizedKeysFile defined in sshd_config."
|
debug "No AuthorizedKeysFile defined in sshd_config."
|
||||||
else
|
else
|
||||||
AUTHKEYFILE_PATTERN=$(echo "$ret" | sed 's/AuthorizedKeysFile//i' | sed 's#%h/##' | tr -s "[:space:]")
|
AUTHKEYFILE_PATTERN=$(echo "$ret" | sed 's/AuthorizedKeysFile//i' | sed 's#%h/##' | tr -s "[:space:]")
|
||||||
@ -137,7 +137,7 @@ audit() {
|
|||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
info "User $user has a valid shell ($shell)."
|
info "User $user has a valid shell ($shell)."
|
||||||
if [ "x$user" = "xroot" ] && [ "$user" != "$EXCEPTION_USER" ]; then
|
if [ "$user" = "root" ] && [ "$user" != "$EXCEPTION_USER" ]; then
|
||||||
check_dir /root
|
check_dir /root
|
||||||
continue
|
continue
|
||||||
elif $SUDO_CMD [ ! -d /home/"$user" ]; then
|
elif $SUDO_CMD [ ! -d /home/"$user" ]; then
|
||||||
|
24
debian/changelog
vendored
24
debian/changelog
vendored
@ -1,3 +1,27 @@
|
|||||||
|
cis-hardening (3.7-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* feat: add FIND_IGNORE_NOSUCHFILE_ERR flag (#159)
|
||||||
|
|
||||||
|
-- Yannick Martin <yannick.martin@ovhcloud.com> Mon, 04 Jul 2022 14:34:03 +0200
|
||||||
|
|
||||||
|
cis-hardening (3.6-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* feat: Filter the filesystem to check when the list is built. (#156)
|
||||||
|
|
||||||
|
-- Tarik Megzari <tarik.megzari@corp.ovh.com> Fri, 24 Jun 2022 15:49:00 +0000
|
||||||
|
|
||||||
|
cis-hardening (3.5-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* fix: add 10s wait timeout on iptables command (#151)
|
||||||
|
|
||||||
|
-- Tarik Megzari <tarik.megzari@corp.ovh.com> Wed, 23 Mar 2022 17:28:08 +0100
|
||||||
|
|
||||||
|
cis-hardening (3.4-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* fix: allow passwd-, group- and shadow- debian default permissions (#149)
|
||||||
|
|
||||||
|
-- Thibault Dewailly <thibault.dewailly@ovhcloud.com> Fri, 18 Mar 2022 15:43:24 +0000
|
||||||
|
|
||||||
cis-hardening (3.3-1) unstable; urgency=medium
|
cis-hardening (3.3-1) unstable; urgency=medium
|
||||||
|
|
||||||
* fix: missing shadowtools backup files is ok (#132)
|
* fix: missing shadowtools backup files is ok (#132)
|
||||||
|
@ -349,10 +349,10 @@ is_kernel_option_enabled() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ANSWER=$(cut -d = -f 2 <<<"$RESULT")
|
ANSWER=$(cut -d = -f 2 <<<"$RESULT")
|
||||||
if [ "x$ANSWER" = "xy" ]; then
|
if [ "$ANSWER" = "y" ]; then
|
||||||
debug "Kernel option $KERNEL_OPTION enabled"
|
debug "Kernel option $KERNEL_OPTION enabled"
|
||||||
FNRET=0
|
FNRET=0
|
||||||
elif [ "x$ANSWER" = "xn" ]; then
|
elif [ "$ANSWER" = "n" ]; then
|
||||||
debug "Kernel option $KERNEL_OPTION disabled"
|
debug "Kernel option $KERNEL_OPTION disabled"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
|
@ -23,6 +23,12 @@ test_audit() {
|
|||||||
register_test contain "Some world writable directories are not on sticky bit mode"
|
register_test contain "Some world writable directories are not on sticky bit mode"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some world writable directories are not on sticky bit mode"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
||||||
|
@ -5,7 +5,9 @@ test_audit() {
|
|||||||
# shellcheck disable=2154
|
# shellcheck disable=2154
|
||||||
/opt/debian-cis/bin/hardening/"${script}".sh || true
|
/opt/debian-cis/bin/hardening/"${script}".sh || true
|
||||||
# shellcheck disable=2016
|
# shellcheck disable=2016
|
||||||
echo 'EXCLUDED="$EXCLUDED ^/dev/.*"' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
echo 'EXCLUDED="$EXCLUDED ^/home/secaudit/thisfileisignored.*|^/dev/.*"' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
touch /home/secaudit/thisfileisignored
|
||||||
|
chmod 777 /home/secaudit/thisfileisignored
|
||||||
|
|
||||||
describe Running on blank host
|
describe Running on blank host
|
||||||
register_test retvalshouldbe 0
|
register_test retvalshouldbe 0
|
||||||
@ -21,6 +23,12 @@ test_audit() {
|
|||||||
register_test contain "Some world writable files are present"
|
register_test contain "Some world writable files are present"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some world writable files are present"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
||||||
|
@ -24,6 +24,12 @@ test_audit() {
|
|||||||
register_test contain "Some unowned files are present"
|
register_test contain "Some unowned files are present"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some unowned files are present"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
/opt/debian-cis/bin/hardening/"${script}".sh || true
|
/opt/debian-cis/bin/hardening/"${script}".sh || true
|
||||||
|
@ -24,6 +24,12 @@ test_audit() {
|
|||||||
register_test contain "Some ungrouped files are present"
|
register_test contain "Some ungrouped files are present"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some ungrouped files are present"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
sed -i 's/audit/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
/opt/debian-cis/bin/hardening/"${script}".sh --apply || true
|
||||||
|
@ -21,6 +21,12 @@ test_audit() {
|
|||||||
register_test contain "$targetfile"
|
register_test contain "$targetfile"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some suid files are present"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
chmod 700 $targetfile
|
chmod 700 $targetfile
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ test_audit() {
|
|||||||
register_test contain "$targetfile"
|
register_test contain "$targetfile"
|
||||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
|
describe Tests failing with find ignore flag
|
||||||
|
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>/opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||||
|
register_test retvalshouldbe 1
|
||||||
|
register_test contain "Some sgid files are present"
|
||||||
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe correcting situation
|
describe correcting situation
|
||||||
chmod 700 $targetfile
|
chmod 700 $targetfile
|
||||||
|
|
||||||
|
@ -10,6 +10,13 @@ test_audit() {
|
|||||||
local test_user="testetcpasswd-user"
|
local test_user="testetcpasswd-user"
|
||||||
local test_file="/etc/passwd-"
|
local test_file="/etc/passwd-"
|
||||||
|
|
||||||
|
describe Debian default right shall be accepted
|
||||||
|
chmod 644 "$test_file"
|
||||||
|
chown root:root "$test_file"
|
||||||
|
register_test retvalshouldbe 0
|
||||||
|
register_test contain "has correct permissions"
|
||||||
|
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe Tests purposely failing
|
describe Tests purposely failing
|
||||||
chmod 777 "$test_file"
|
chmod 777 "$test_file"
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
|
@ -10,6 +10,13 @@ test_audit() {
|
|||||||
local test_user="testetcshadow-user"
|
local test_user="testetcshadow-user"
|
||||||
local test_file="/etc/shadow-"
|
local test_file="/etc/shadow-"
|
||||||
|
|
||||||
|
describe Debian default right shall be accepted
|
||||||
|
chmod 640 "$test_file"
|
||||||
|
chown root:shadow "$test_file"
|
||||||
|
register_test retvalshouldbe 0
|
||||||
|
register_test contain "has correct permissions"
|
||||||
|
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe Tests purposely failing
|
describe Tests purposely failing
|
||||||
chmod 777 "$test_file"
|
chmod 777 "$test_file"
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
|
@ -10,6 +10,13 @@ test_audit() {
|
|||||||
local test_user="testetcgroup--user"
|
local test_user="testetcgroup--user"
|
||||||
local test_file="/etc/group-"
|
local test_file="/etc/group-"
|
||||||
|
|
||||||
|
describe Debian default right shall be accepted
|
||||||
|
chmod 644 "$test_file"
|
||||||
|
chown root:root "$test_file"
|
||||||
|
register_test retvalshouldbe 0
|
||||||
|
register_test contain "has correct permissions"
|
||||||
|
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||||
|
|
||||||
describe Tests purposely failing
|
describe Tests purposely failing
|
||||||
chmod 777 "$test_file"
|
chmod 777 "$test_file"
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
|
Reference in New Issue
Block a user