Compare commits

...

499 Commits

Author SHA1 Message Date
Thomas Sjögren ff26d67f25
Merge pull request #559 from cyphar/dist-libexec
dist: adjust script imports to be able to use /usr/libexec
2024-10-21 09:26:06 +02:00
Aleksa Sarai a18798fcfa
dist: adjust script imports to be able to use /usr/libexec
In order to make installation easier for distributions, make all script
imports based on a single variable that distributions can adjust based
on how the script is packaged for each distribution.

Ideally we would actually install the script in /usr/libexec rather than
/ in our Dockerfile, but this is a simpler fix that still lets you run
the script from the repo directory.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-10-18 17:43:13 +11:00
Thomas Sjögren 5c42b8ad5f
Merge pull request #553 from spedersen-emailage/log-level-fix
modified get_docker_configuration_file_args jq command to remove null response
2024-05-16 16:35:13 +02:00
Sean Pedersen c4b7d36042 modified get_docker_configuration_file_args jq command to remove \'null\' return 2024-05-15 10:21:02 -07:00
Thomas Sjögren 23110269a6
Merge pull request #549 from konstruktoid/issue548
include /run in get_service_file
2024-04-16 18:12:13 +02:00
Thomas Sjögren c495b3a774
Merge pull request #550 from konstruktoid/gha
update github action
2024-04-16 10:24:28 +02:00
Thomas Sjögren 12f085d42f
update SLSA action
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2024-04-16 08:23:14 +00:00
Thomas Sjögren 966929427e correct tests and instructions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2024-04-16 07:32:23 +00:00
Thomas Sjögren 5d5ca0a3da
correct tests and instructions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2024-04-16 07:29:45 +00:00
Thomas Sjögren 287fd8774b
systemctl always returns an FragmentPath
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2024-04-12 08:17:17 +00:00
Thomas Sjögren e081393ad7
include /run in get_service_file
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2024-04-11 21:45:15 +00:00
Thomas Sjögren 820abe98c3
Merge pull request #539 from konstruktoid/issue538
check if restart policy is 5 or less
2024-02-11 11:25:09 +01:00
Thomas Sjögren ba0b402ea5
Merge pull request #546 from martipoe/master
Update check ID and add check groups for CIS Controls v8 (v1.6.0 - 06-14-2023)
2023-12-20 15:41:02 +01:00
MaPoe 684512b888 feat: check groups for CIS Controls v8 IG1-3 mapped recommendations 2023-12-17 16:45:13 +01:00
MaPoe 958f5fa6c3 feat: update swarm mode check id from 7.1 to 5.1 2023-12-17 15:57:54 +01:00
Thomas Sjögren 0fd702afed
Merge pull request #543 from UlisesGascon/fix/pin-dependency
feat: use SHA instead of tags for base image
2023-11-19 22:04:37 +00:00
Ulises Gascón 8bbdaf6540
feat: use SHA instead of tags for base image 2023-11-19 21:08:05 +01:00
Thomas Sjögren 4edccd7859
Merge pull request #541 from halfluke/fix537
fix537
2023-10-23 09:45:55 +00:00
halfluke 8d97756c62 fix537_proper 2023-10-21 01:55:29 +01:00
halfluke b6e4380937 fix537 2023-10-21 01:43:46 +01:00
Thomas Sjögren 7287a35a21
Merge pull request #540 from ismailarilik/patch-1
"above" -> "below"
2023-10-06 07:13:44 +00:00
İsmail Arılık 5c647c1b86
"above" -> "below"
It is not above but below.
2023-10-06 08:51:33 +03:00
Thomas Sjögren e680ab2465
update restart_policy w/o swarm
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-09-25 15:29:45 +00:00
Thomas Sjögren ab2190819d
check if restart policy is 5 or less
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-09-25 09:05:44 +00:00
Thomas Sjögren b7a5284ce4
Merge pull request #536 from konstruktoid/v160
Update version v1.6.0
2023-08-25 14:38:42 +02:00
Thomas Sjögren 8da1cc26df
v1.6.0
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-08-25 12:37:35 +00:00
Thomas Sjögren 9120d426ce
Merge pull request #535 from konstruktoid/issue532
Fix image sprawl miscalculation
2023-08-25 14:18:55 +02:00
Thomas Sjögren 26f80fb331
Fix image sprawl miscalculation
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-08-25 12:17:48 +00:00
Thomas Sjögren 5555c37560
Merge pull request #531 from lekpamartin/master
add label filtering config
2023-07-26 17:51:28 +00:00
LEKPA Martin 8ea918620e update doc 2023-07-26 18:47:50 +02:00
Martin LEKPA 59fe573db2
update help 2023-07-25 21:38:20 +02:00
Martin LEKPA 2dfb1bac51
Update README.md 2023-07-25 21:37:03 +02:00
LEKPA Martin 223baf94d1 update doc 2023-07-21 18:53:01 +02:00
Thomas Sjögren d9f1d02102
Merge pull request #522 from andreagalle/issue_521_restart_policy
Issue 521 restart policy
2023-07-07 19:16:48 +00:00
LEKPA Martin bfbeda9263 add label filtering config 2023-07-01 11:19:04 +02:00
Thomas Sjögren 1f9933a867
Merge pull request #528 from konstruktoid/issue527
tr is required, not truncate
2023-06-13 11:55:41 +02:00
Thomas Sjögren d6005f0211
tr is required, not truncate
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-06-13 09:54:22 +00:00
Thomas Sjögren 26dc83ed28
Merge pull request #526 from konstruktoid/docker
update Docker container instructions, remove out-of-date Dockerfiles
2023-06-02 22:18:33 +00:00
Thomas Sjögren 2647070692
update Docker container instructions, remove out-of-date Dockerfiles
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-06-02 22:16:31 +00:00
Thomas Sjögren 1d29a1f405
Merge pull request #525 from brsolomon-deloitte/bugfix/get_docker_configuration_file_args
fix: allow get_docker_configuration_file_args to parse minified json
2023-06-02 21:46:09 +00:00
Brad Solomon 523556b4ac move HAVE_JQ into req_programs 2023-06-02 17:36:29 -04:00
Brad Solomon 79407ce361 remove non-universal tr -u flag 2023-06-02 17:26:21 -04:00
Brad Solomon 39963dad60 fix: allow get_docker_configuration_file_args to parse minified json
Closes #524.
2023-06-02 09:18:42 -04:00
andreagalle 0dc2d2b1e6 should fix the: Error response from daemon: This node is not a swarm manager. issue 2023-04-26 07:04:53 +00:00
andreagalle 412f514bb4 just a typo 2023-04-12 14:51:01 +00:00
andreagalle f97b420af9 couple typos & performance improvements 2023-04-12 14:46:13 +00:00
andreagalle c8c90ee523 checking for the MaxAttempts=5 too at service level 2023-04-12 13:27:36 +00:00
Thomas Sjögren 16c235080d
Merge pull request #520 from konstruktoid/gha
update slsa gha permissions
2023-03-15 17:12:35 +01:00
Thomas Sjögren 9bf4dea527
update slsa gha permissions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-15 17:11:38 +01:00
Thomas Sjögren 93227bf6c0
Merge pull request #519 from konstruktoid/readme
fix version in readme
2023-03-15 16:52:18 +01:00
Thomas Sjögren d0ccaca6a9
Merge pull request #518 from konstruktoid/issuegha
update issue assignment gha
2023-03-15 16:51:53 +01:00
Thomas Sjögren 949c6a034a
fix version in readme
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-15 16:51:15 +01:00
Thomas Sjögren f16cd8dd62
update Issue assignment gha
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-15 16:50:08 +01:00
Thomas Sjögren 6dad6fc405
Merge pull request #517 from konstruktoid/slsa
update slsa gha
2023-03-15 16:47:32 +01:00
Thomas Sjögren df36db7a70
update slsa gha
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-15 16:46:47 +01:00
Thomas Sjögren 5a450fc5ba
Merge pull request #516 from konstruktoid/rel
update image
2023-03-15 16:43:19 +01:00
Thomas Sjögren 956ca6bb34
update image
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-15 16:41:10 +01:00
Thomas Sjögren faa0e88479
slsa gha
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-13 15:52:27 +01:00
Thomas Sjögren 41a44f54d3
Merge pull request #515 from konstruktoid/helper
update yell helper with correct version
2023-03-06 13:17:53 +01:00
Thomas Sjögren 316b610178
update yell helper with correct version
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-06 13:17:11 +01:00
Thomas Sjögren dde48fc185
Merge pull request #514 from konstruktoid/version150
update version and add version table
2023-03-06 13:11:50 +01:00
Thomas Sjögren e82fa2cf5d
update version and add version table
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-06 13:11:02 +01:00
Thomas Sjögren ce38d3dd3c
Merge pull request #513 from konstruktoid/150
align tests to CIS Docker Benchmark 1.5.0
2023-03-06 13:01:33 +01:00
Thomas Sjögren cbd07bb051
align tests to CIS Benchmark 1.5.0
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-03-06 12:59:56 +01:00
Thomas Sjögren f375045741
Merge pull request #511 from konstruktoid/issue510
add support for .NanoCpus
2023-02-02 22:12:27 +01:00
Thomas Sjögren 75ccbc78a3
Merge pull request #508 from QuentinServais/fix/check_2_7_TLS
Fix check_2_7 TLS  check with json config
2023-02-02 11:49:10 +01:00
Thomas Sjögren 941518887b
add support for .NanoCpus
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2023-02-02 11:47:18 +01:00
QuentinServais ee718c40c0
Fix check_2_7 TLS check with json config 2022-12-27 23:39:17 +01:00
Thomas Sjögren 5a8d6434e6
Merge pull request #506 from docker/atomist/pin-docker-base-image/distros/dockerfile.debian
Pin Docker base image in distros/Dockerfile.debian
2022-10-05 15:13:31 +02:00
Atomist Bot 553c11f3a9 Pin Docker image debian:sid
debian:sid
->
debian:sid@sha256:022a3cafe84d704c272794863ca5e383667c99312358e816ad1ff6e9a41ce4f6

 [atomist:generated]
 [atomist-skill:atomist/docker-base-image-policy]

Signed-off-by: Atomist Bot <bot@atomist.com>
2022-10-05 13:00:43 +00:00
Thomas Sjögren 8ccd83a6f0
Merge pull request #504 from gavinmporter/bsd-sed-fix
Fix sed commands for BSD sed
2022-07-19 13:42:49 +02:00
Gavin Porter b29f676bbb Fix sed commands for BSD sed 2022-07-19 11:11:19 +12:00
Thomas Sjögren 44fdceb331
Merge pull request #501 from konstruktoid/issue498
grep host* in config file before testing 2.7
2022-05-23 11:31:04 +02:00
Thomas Sjögren 558fca319f grep host* in config file before testing 2.7
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-05-09 12:26:01 +02:00
Thomas Sjögren 7c7390e723
Merge pull request #500 from konstruktoid/vagrant
add Vagrantfile
2022-04-30 12:05:22 +02:00
Thomas Sjögren d4c4538bc8 add Vagrantfile
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-04-30 12:03:57 +02:00
Thomas Sjögren 58e732f3d1
Merge pull request #499 from konstruktoid/action
add github actions
2022-04-30 12:01:23 +02:00
Thomas Sjögren bb032f154a add github actions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-04-30 12:00:35 +02:00
Thomas Sjögren cd1619c375
Merge pull request #497 from konstruktoid/version
Version
2022-03-07 13:40:44 +01:00
Thomas Sjögren 3cfa505ecc update version information
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-03-07 13:39:45 +01:00
Thomas Sjögren 3fe40815ee ignore Vagrant files
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-03-07 13:39:22 +01:00
Thomas Sjögren d44c2a9d47
Merge pull request #496 from konstruktoid/artifactvalidation
add 4.12 check
2022-03-07 13:06:06 +01:00
Thomas Sjögren 68c8e53dac add 4.12 check
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-03-07 13:05:22 +01:00
Thomas Sjögren 715de9c607
Merge pull request #495 from jammasterj89/master
Update alpine to 3.15
2022-01-11 14:01:36 +01:00
jammasterj89 975820f52b
Update alpine to 3.15
Updated alpine version to latest - 3.15

Signed-off-by: Niall T <19202716+jammasterj89@users.noreply.github.com>
2022-01-11 12:34:38 +00:00
Thomas Sjögren d33139cedc
Merge pull request #494 from konstruktoid/imagenotice
add note regarding docker image
2022-01-06 21:33:48 +01:00
Thomas Sjögren 5c7acd72a5 add note regarding docker image
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2022-01-06 21:32:59 +01:00
Thomas Sjögren 1ff4a62836
Merge pull request #493 from konstruktoid/ISSUE492
if configured with no-new-privileges, pass check 5.25
2021-12-16 10:36:23 +01:00
Thomas Sjögren 0d5874877b if the docker daemon is configure with no-new-privileges, pass check 5.25
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-12-02 11:10:12 +01:00
Thomas Sjögren 3f3ff4fb2d
Merge pull request #491 from SericaLaw/fix-check-5-3
fix style and false warning in check_5_3
2021-12-01 10:49:06 +01:00
serica 0ae544dd03 fix style and false warning in check_5_3 2021-11-30 18:38:36 -08:00
Thomas Sjögren ec211a3277
Merge pull request #489 from joaocfernandes/fix_typos
Fix description typos
2021-11-12 10:07:56 +01:00
João Fernandes a409e03d99
Fix typo in check_5_21 2021-11-11 20:39:22 +00:00
João Fernandes 7e89ea067d
Fix typo in check_4_11
Fix the text description for check_4_11 .
2021-11-11 20:39:00 +00:00
Thomas Sjögren ec3ddf2acd
Merge pull request #475 from nikitastupin/feature-list-open-ports
Implement listing of open ports
2021-10-31 12:50:27 +01:00
Thomas Sjögren fd93a6ee93
Merge pull request #476 from nikitastupin/feature-specific-capability-checks
Add checks for capabilities that allows container escape
2021-10-31 12:26:40 +01:00
Thomas Sjögren a40b888ee9
Merge pull request #488 from garettmd/master
Add /etc/hostname fix for macOS
2021-10-01 22:04:59 +02:00
Garett Dunn 8ac4513d24
Add /etc/hostname fix for macOS 2021-10-01 11:39:17 -04:00
Thomas Sjögren 1891eaa8b3
Merge pull request #487 from AErmie/patch-1
Updated log file name
2021-09-30 15:23:24 +02:00
Adin Ermie d98a054c2f
Updated log file name
From testing, the default logfile name is `docker-bench-security.log.json` not `docker-bench-security.sh.log.json`
2021-09-30 09:02:41 -04:00
Thomas Sjögren f656a5d683
Merge pull request #485 from AErmie/patch-1
Added multiple check groups example
2021-09-29 10:20:25 +02:00
Adin Ermie e6a742ba38
Added multiple check groups example
Added an example of running multiple groups of checks, as the documentation did not clearly show this is possible (and the proper syntax).
2021-09-28 17:51:40 -04:00
Thomas Sjögren dfb3a90f67
Merge pull request #478 from konstruktoid/ISSUE477
fix socket check
2021-07-12 21:55:31 +00:00
Thomas Sjögren 683c5a92b5 fix socket check
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-07-12 15:22:12 +02:00
Nikita Stupin cf93e9ed07 Add checks for capabilities that allows container escape 2021-07-08 13:10:12 +03:00
Nikita Stupin dacc7372bf Implement listing of open ports 2021-07-08 13:00:21 +03:00
Thomas Sjögren 2024e16f09
Merge pull request #474 from denhamparry/master
fix: set docker-bench-security to sh
2021-07-07 11:05:42 +00:00
Lewis Denham-Parry e31e7aa0ae
fix: set docker-bench-security to sh
- Set script to execute with sh rather than bash
- Set CMD Dockerfile to use /bin/sh
2021-07-07 08:22:59 +01:00
Thomas Sjögren c6256295fc
Merge pull request #471 from aagot/master
Update 2_docker_daemon_configuration.sh
2021-06-26 16:14:39 +00:00
aagot 08a7b09d4d
Update 2_docker_daemon_configuration.sh 2021-06-25 14:38:02 +02:00
Thomas Sjögren 3769a64a2f
Merge pull request #469 from konstruktoid/v131
Initial v1.3.1 PR
2021-05-25 18:52:43 +00:00
Thomas Sjögren c1457e6ad3 initial commit of tests/99_community_checks.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren 32c5e5f1fb initial commit of tests/8_docker_enterprise_configuration.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren 4e379bbaf9 initial commit of tests/7_docker_swarm_configuration.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren 3a9deae328 initial commit of tests/6_docker_security_operations.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren bd05445528 initial commit of tests/5_container_runtime.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren 28fa0393da initial commit of tests/4_container_images.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:46 +02:00
Thomas Sjögren 6f574b07c1 initial commit of tests/3_docker_daemon_configuration_files.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:45 +02:00
Thomas Sjögren 6a685524eb initial commit of tests/2_docker_daemon_configuration.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:45 +02:00
Thomas Sjögren 4a4ae81a03 initial commit of tests/1_host_configuration.sh v1.3.1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:49:45 +02:00
Thomas Sjögren ca4ef8fa57 linting
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:46:07 +02:00
Thomas Sjögren 2466ab4826 update wording
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:45:38 +02:00
Thomas Sjögren 17026093f1 update check functions and remove docker_enterprise_configuration from default
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:45:20 +02:00
Thomas Sjögren cff5d7f32c wording and set printremediation="0"
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:44:18 +02:00
Thomas Sjögren addefc6ee4 update documentation
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2021-05-25 20:43:33 +02:00
Thomas Sjögren 6a8fdcf72e
Merge pull request #467 from razvanstoica89/master
Small improvement of user experience
2021-04-27 08:46:53 +00:00
Razvan Stoica 0a59baa9fb Change "Impact" to "Remediation Impact" in bash log 2021-04-19 09:51:48 +03:00
Razvan Stoica e4d9bd1556 Set remediationImpact for 5.31 test to None. 2021-04-14 11:17:22 +03:00
Razvan Stoica 15aa1eecd5 Update remediation impact message for test 5.31 2021-04-14 10:58:53 +03:00
Razvan Stoica 38ac7ef8d8 Fix the printing error when using bash 2021-04-10 12:01:33 +03:00
Razvan Stoica c67469d96b Fix systemctl error when running inside a container 2021-03-29 16:20:01 +03:00
Razvan Stoica 81ac358e82 Remove temporary files 2021-03-29 15:32:34 +03:00
Razvan Stoica d0443cc817 Bug fixing and improving source code readability 2021-03-29 15:22:14 +03:00
Razvan Stoica 86985f854f Overwrite the json log at each run. Beautify the json log. 2021-03-28 11:08:15 +03:00
Razvan Stoica 8a934aebf1 Remove the Debian family-specific installation command 2021-03-28 09:47:49 +03:00
Razvan Stoica 4b68c2e040 Rename logs without the .sh extension 2021-03-27 09:36:10 +02:00
Razvan Stoica f31e60c379 Add more remediation stuff 2021-03-22 09:43:56 +02:00
Razvan Stoica c8721c90fa Displays the correct current time 2021-03-19 13:51:31 +02:00
Razvan Stoica 68cb493117 Log the remediation measure in JSON file only if the -p flag is not set 2021-03-19 09:29:55 +02:00
Razvan Stoica cc8171fbfe Add remediation stuff on enterprise configuration 2021-03-18 10:32:02 +02:00
Razvan Stoica 3a7fe3bb24 Add remediation stuff on swarm configuration 2021-03-18 10:31:22 +02:00
Razvan Stoica 25de0bd826 Add remediation stuff on security operations 2021-03-18 10:30:30 +02:00
Razvan Stoica c05c58674a Add remediation stuff on daemon configuration 2021-03-18 10:29:28 +02:00
Razvan Stoica 7e89fdd364 Add remediation stuff on host configuration 2021-03-18 10:28:45 +02:00
Razvan Stoica 68bcd14fb3 Increase version 2021-03-17 14:05:48 +02:00
Razvan Stoica e5efe2bf40 Add explanations for newly added features 2021-03-16 10:13:31 +02:00
Razvan Stoica 091b4b954a Add option to specify trusted users. Add option to disable the printing of remediation measures. 2021-03-16 10:11:29 +02:00
Razvan Stoica 9722e5d89a Move the help scripts to a dedicated folder 2021-03-16 10:07:48 +02:00
Razvan Stoica 7144b947de Tests update 2021-03-16 10:05:49 +02:00
Razvan Stoica ca03a37db6 Remove duplicate Dockerfile 2021-03-16 10:00:45 +02:00
Razvan Stoica b757aa7334 Connection to the apk repositories is HTTPS by default 2021-03-16 09:58:57 +02:00
Razvan Stoica 2986d618f4 Ignore all. Whitelist only essential things. 2021-03-16 09:53:32 +02:00
Razvan Stoica ee5972cb69 Add new folders to improve code segmentation 2021-03-16 09:50:12 +02:00
Razvan Stoica bf11d68522 Add new check groups 2021-03-11 16:17:11 +02:00
Razvan Stoica 11886d47d8 Fixed invalid JSON log 2021-03-11 15:00:12 +02:00
Razvan Stoica 82ecb7e089 README file updated with new default logs location 2021-03-11 13:29:15 +02:00
Razvan Stoica ed23f2d285 Change default log locations 2021-03-11 13:24:58 +02:00
Razvan Stoica ad62371ace Move all pictures to a dedicated folder 2021-03-11 13:12:05 +02:00
Razvan Stoica 59a63dd49a Print more details in help message 2021-03-11 10:21:13 +02:00
Razvan Stoica c623d3afdd Print the remediation measure only if the check is not passed 2021-03-11 09:32:29 +02:00
Razvan Stoica b3a36e8d94 Print Section B only if it contains remediation measures 2021-03-11 09:26:31 +02:00
Razvan Stoica 82bbe1d562 Update benchmark log photo 2021-03-11 09:12:46 +02:00
Razvan Stoica 1623c4585e Set a relative image link 2021-03-11 08:34:55 +02:00
Razvan Stoica 85117ea1a2 Improve wording 2021-03-11 08:30:01 +02:00
Razvan Stoica f769a32e9b Update benchmark log photo 2021-03-11 08:26:35 +02:00
Razvan Stoica 6c586b4e08 Print remediation measures at the end of the logs 2021-03-10 21:47:52 +02:00
Razvan Stoica 9ae0d92b5d Fix "nohealthlocal: command not found" error 2021-03-10 14:58:58 +02:00
Razvan Stoica 2132b03b92 Usage instructions aligned between the README.md and docker-bench-security.sh files 2021-03-10 10:01:18 +02:00
Razvan Stoica c00ef4330b Add details about remediations measure for host configuration tests 2021-03-09 21:43:25 +02:00
Razvan Stoica 58205d4ef5 Add new programs to the list of required programs 2021-03-09 17:50:00 +02:00
Razvan Stoica 519f20befd Append JSON logs when run multiple times 2021-03-09 16:06:38 +02:00
Razvan Stoica c3511209f9 Add support for logging remediation measures in JSON format 2021-03-09 13:35:40 +02:00
Razvan Stoica 8e0daa11de Print date and time in ISO 8601 UTC format 2021-03-09 13:27:32 +02:00
Razvan Stoica 94900eedb9 Change global variable used only locally to local variable for simplification 2021-03-09 12:42:48 +02:00
Thomas Sjögren 1aa919e918
Merge pull request #466 from razvanstoica89/master
Add current year to the copyright header
2021-03-08 11:45:13 +00:00
Razvan Stoica 4b4fdd9f77
Add current year to the copyright header 2021-03-08 13:38:07 +02:00
Thomas Sjögren c8984e9591
Merge pull request #464 from archaeogeek/patch-2
Update 4_container_images.sh
2021-02-25 22:10:39 +00:00
Jo Cook e9b9bfd270
Update 4_container_images.sh
Correcting an extremely minor grammatical error (sorry)
2021-02-25 19:04:05 +00:00
Thomas Sjögren dcf478884b
Merge pull request #463 from archaeogeek/patch-1
Update README.md
2021-02-23 20:28:31 +00:00
Jo Cook 3732a475cb
Update README.md
Extended my two edits to specify that they only apply if running in a container.
2021-02-23 17:25:12 +00:00
Jo Cook cf7c50bf33
Update README.md
Clarified that log files are created inside the container so that new users (ie me) don't spend ages wondering where the logs are!
2021-02-23 12:15:22 +00:00
Thomas Sjögren 7c881b4b0b
Merge pull request #461 from jammasterj89/master
Fix check_2 to -le 644
2021-01-15 13:39:29 +00:00
jammasterj89 f8c9b0fd5b
Replace multiple -eq with -le
Replace multiple -eq with -le for file permission checks. Except for line 228 which uses slightly different logic so is -ge.

Signed-off-by: Niall T 19202716+jammasterj89@users.noreply.github.com
2021-01-15 11:20:59 +00:00
jammasterj89 47e4cc173c
Fix check_2 to -le 644
Issue #459 raised that check_2 was only checking for 644 or 600 permissions, this now checks for anything less than or equal to 644.

Signed-off-by: Niall T 19202716+jammasterj89@users.noreply.github.com
2021-01-15 10:29:11 +00:00
Thomas Sjögren 8bd04d683f
Merge pull request #460 from jammasterj89/master
Update alpine to 3.13.0
2021-01-15 10:21:31 +00:00
Thomas Sjögren d3d25c8fc8
Update Dockerfile
Co-authored-by: Sebastiaan van Stijn <thaJeztah@users.noreply.github.com>
2021-01-15 10:20:35 +00:00
jammasterj89 f47f61538e
Update alpine to 3.13.0
Updated alpine version to latest - 3.13.0

Signed-off-by: Niall T <19202716+jammasterj89@users.noreply.github.com>
2021-01-15 09:30:14 +00:00
Thomas Sjögren 75fe107048
Merge pull request #457 from sa7mon/patch-1
Grammar fixes in README
2020-11-30 16:26:33 +00:00
Dan Salmon b7d8805ce1
Update README.md
Grammar fixes
2020-11-30 14:44:00 +00:00
Thomas Sjögren ca0db8898f
Merge pull request #454 from Constantin07/do_not_leave_dangling_container_after_run
Remove container after run.
2020-11-18 09:22:08 +00:00
Constantin Bugneac 1ea667f2f0 Remove container after run. 2020-11-17 21:49:07 +00:00
Thomas Sjögren 6ad1a1ef77
Merge pull request #451 from konstruktoid/imgname
print img if empty RepoTags, and fix tabbing
2020-11-02 08:27:59 +00:00
Thomas Sjögren 3877abd975 print img if empty RepoTags, and fix tabbing
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-11-02 09:26:20 +01:00
Thomas Sjögren 93c619f018
Merge pull request #445 from thaJeztah/no_experimental
Deprecate rule 2.16 for Docker > 19.03
2020-10-02 17:31:15 +00:00
Sebastiaan van Stijn 0f3dfe70fe
Deprecate rule 2.16 for Docker > 19.03
The upcoming 20.x docker release will always have experimental features
enabled, which will stop this test from working.

More details can be found in docker/cli##2774

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-10-02 18:01:57 +02:00
Thomas Sjögren f3e9c791ce
Merge pull request #444 from markdumay/partition
Support user namespaces in partition check (1.2.1)
2020-09-29 11:24:17 +00:00
mark d85c73316a Updated mountpoint check to support user namespace 2020-09-29 12:41:25 +02:00
mark 919816dbbf Changed to 'df' to support user namespaces 2020-09-28 08:04:17 +02:00
Thomas Sjögren b6478e9367
Merge pull request #374 from draios/limit-num-items-reported
Limit the number of reported items
2020-07-13 11:22:49 +00:00
Mark Stemm 4cfb58f675 Limit the number of reported items
In some evironments, there may be a very large number of images,
containers, etc not satisfying a given test. For example, in one
environment, we saw *378k* images not satisfying 4.6, mostly because
the customer was never cleaning up old images.

To avoid overly long lists of items, add a new option "-n LIMIT" that
limits the number of items included in JSON output. When the limit is
reached, the list will be truncated and a trailing (truncated) will be
added. Here's an example:

```
{"id": "5.9", "desc": "Ensure the host's network namespace is not
shared", "result": "WARN", "details": "Containers running with
networking mode 'host':  k8s_POD_storage-provisioner_kube-system_ef960ef5-62c5-11e9-802f-08002719228f_0
k8s_POD_kube-proxy-xfln8_kube-system_ee70c4c3-62c5-11e9-802f-08002719228f_0 (truncated)",
"items":
["k8s_POD_storage-provisioner_kube-system_ef960ef5-62c5-11e9-802f-08002719228f_0","k8s_POD_kube-proxy-xfln8_kube-system_ee70c4c3-62c5-11e9-802f-08002719228f_0","(truncated)"]},
```

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-07-10 13:00:29 -07:00
Thomas Sjögren 41593e80d0
Merge pull request #439 from roman-mueller/fix_description
Remove prefix of check ID in description
2020-06-02 14:10:21 +00:00
Roman Mueller b3182ca8f5 Remove prefix of check ID 2020-06-02 15:57:33 +02:00
Thomas Sjögren d6969dd2a4
Merge pull request #438 from konstruktoid/alpine
alpine:3.12
2020-06-01 07:31:05 +00:00
Thomas Sjögren aa984c44db alpine:3.12
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-06-01 09:30:09 +02:00
Thomas Sjögren 1e0a10b71f
Merge pull request #436 from konstruktoid/macnetstat
more flexible binary usage, better support for mac os
2020-05-08 11:10:57 +00:00
Thomas Sjögren 8aec461d46 more flexible binary usage, better support for mac os
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-05-08 13:09:52 +02:00
Thomas Sjögren 375d32c0db
Merge pull request #435 from konstruktoid/scoring
map desc_ to benchmark headings
2020-05-08 10:41:41 +00:00
Thomas Sjögren 98acc66436 map desc_ to benchmark headings
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-05-08 12:38:08 +02:00
Thomas Sjögren 735938a8f1
Merge pull request #434 from HristoStoyanovMM/CIS_Level1_only_checks
Add CIS Level 1 only functions
2020-05-08 08:46:28 +00:00
herc1 4612146563 Add CIS Level 1 only functions
Signed-off-by: HristoStoyanovMM <hristo.stoyanov@mentormate.com>
2020-05-07 19:44:56 +03:00
Thomas Sjögren 79ef925df1
Merge pull request #430 from konstruktoid/ISSUE422b
by an appropriate
2020-04-17 11:12:51 +00:00
Thomas Sjögren 5210cc9ff9 by an appropriate
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-04-17 13:11:37 +02:00
Thomas Sjögren d32d4f3ce3
Merge pull request #429 from konstruktoid/ISSUE422
fix MacOSX volume, and lint
2020-04-17 06:26:30 +00:00
Thomas Sjögren 1c2b912aa2 fix MacOSX volume, and lint
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-04-17 08:25:44 +02:00
Thomas Sjögren d53ac42de1
Merge pull request #428 from konstruktoid/ISSUE424
update README, correct volume binary paths
2020-04-16 15:18:38 +00:00
Thomas Sjögren 3c38419c5b update README, correct volume binary paths
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-04-16 17:17:51 +02:00
Thomas Sjögren 2cdfa3df25
Merge pull request #423 from illyaMs/master
[Ubuntu] Fix issue with docker.service and docker.socket files not found
2020-04-15 09:05:50 +00:00
Thomas Sjögren 2972b685fc
Merge pull request #427 from konstruktoid/ISSUE425
use opensuse/leap, and remove awk linkage
2020-04-15 08:55:27 +00:00
Thomas Sjögren 9f92e46df8 use opensuse/leap, and remove awk linkage
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-04-15 10:54:17 +02:00
Ilya Dus 51bc75eb55 fix(docs): explain the need of mounting `/lib/systemd/system` folder for Ubuntu
Signed-off-by: Ilya Dus <ilyadoos@gmail.com>
2020-04-10 16:27:32 +03:00
Ilya Dus d42fedc370 fix(sh): check default ubuntu locations of docker.service and docker.socket files
Signed-off-by: Ilya Dus <ilyadoos@gmail.com>
2020-04-10 16:26:25 +03:00
Thomas Sjögren 0307da4c61
Merge pull request #421 from konstruktoid/issue158
macOS user instructions. ref #158
2020-04-01 13:20:41 +02:00
Thomas Sjögren b3488e7d1f macOS user instructions. ref #158
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2020-04-01 13:19:55 +02:00
Thomas Sjögren 937ec4958a
Merge pull request #419 from zawazawa0316/fix_5
Fix check conditions
2020-03-09 14:54:32 +00:00
zawazawa0316 33566331d1 fix line 230
Signed-off-by: zawazawa0316 <37421794+zawazawa0316@users.noreply.github.com>
2020-03-09 23:48:10 +09:00
zawazawa0316 b046f930bc remove single space at line 230
Signed-off-by: zawazawa0316 <37421794+zawazawa0316@users.noreply.github.com>
2020-03-09 23:45:25 +09:00
zawazawa0316 12f19d9f64 Fix check conditions
Signed-off-by: zawazawa0316 <37421794+zawazawa0316@users.noreply.github.com>
2020-03-07 05:24:24 +09:00
Thomas Sjögren e1feca8620
Merge pull request #417 from zawazawa0316/fix_2_5
Fix check condition
2020-03-03 14:04:32 +00:00
zawazawa0316 b16da2c2ed Fix check condition
Signed-off-by: zawazawa0316 <37421794+zawazawa0316@users.noreply.github.com>
2020-03-03 21:51:49 +09:00
Thomas Sjögren 11da147df9
Merge pull request #407 from Intermax-Cloudsourcing/allow-include-checks-mixing
fix: allow combining include and exclude
2020-01-29 12:07:32 +00:00
wilmardo 4054055546 fix: uncomment PATH variable
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2020-01-29 10:31:15 +01:00
Thomas Sjögren 9696a8bd6a
Merge pull request #413 from konstruktoid/alpineupdate
alpine:3.11
2019-12-21 20:32:28 +00:00
Thomas Sjögren 685236f4e6 alpine:3.11
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-12-21 21:31:33 +01:00
Thomas Sjögren d9a70bc006
Merge pull request #412 from konstruktoid/ISSUE410b
locate configuration file before we run the tests #410
2019-12-18 07:21:32 +00:00
Thomas Sjögren 269b71eed8 locate configuration file before we run the tests #410
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-12-17 15:03:54 +01:00
Thomas Sjögren 19173cb954
Merge pull request #411 from konstruktoid/ISSUE410
correct grep #410
2019-12-17 09:19:39 +00:00
Thomas Sjögren c8c5615061 correct grep #410
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-12-16 09:57:21 +01:00
Thomas Sjögren 3c545daccf
Merge pull request #409 from konstruktoid/ISSUE408
catch json w/o space #408
2019-12-13 13:00:06 +00:00
Thomas Sjögren e21999c5c7 catch json w/o space #408
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-12-12 11:03:23 +01:00
wilmardo 155c739fc9 feat: all mixes of include and excludes are now supported
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2019-12-09 15:19:17 +01:00
wilmardo f1c4dc4cd6 docs: Adds example of combining include and exclude
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2019-12-05 16:21:46 +01:00
wilmardo 91d36b62f9 refact: removes variable, use result directly in loop
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2019-12-05 16:20:47 +01:00
wilmardo cf9baa76ae feat: improve sed match
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2019-12-05 15:51:14 +01:00
wilmardo 1b37a1e6bc fix: allow combining include and exclude
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2019-12-04 15:35:11 +01:00
Thomas Sjögren c35d71f533
Merge pull request #406 from jammasterj89/master
Reorder of sed command on images
2019-12-04 11:23:33 +00:00
jammasterj89 d2963b4c42
Reorder of sed command on images
Ensure sed command is first when filtering on images to ensure the description row is removed correctly.

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-12-04 11:14:43 +00:00
Thomas Sjögren c2caa29512
Merge pull request #404 from konstruktoid/logimg
remove macosx shadow...
2019-11-05 10:35:53 +00:00
Thomas Sjögren b3029904d6 remove macosx shadow...
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-11-05 11:34:51 +01:00
Thomas Sjögren 85544e1f69
Merge pull request #403 from konstruktoid/verimage
update benchmark_log.png and contributors
2019-11-05 09:48:52 +00:00
Thomas Sjögren 8163884633 update benchmark_log.png and contributors
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-11-05 10:46:15 +01:00
Thomas Sjögren 8ebf21bbc9
Merge pull request #402 from konstruktoid/linting
shellcheck
2019-10-16 11:49:40 +02:00
Thomas Sjögren ddad135d13 shellcheck
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-10-16 09:49:18 +02:00
Thomas Sjögren bf42355279
Merge pull request #401 from AurelienGasser/patch-1
support whitespace in PATH
2019-10-08 08:44:17 +02:00
Aurélien Gasser 577e9f5edb support whitespace in PATH
Signed-off-by: Aurélien Gasser <aurelien.gasser@gmail.com>
2019-10-07 10:32:58 -04:00
Thomas Sjögren 3bee5e6a54
Merge pull request #398 from konstruktoid/ISSUE397
fix /etc/sysconfig/docker
2019-10-04 14:51:50 +02:00
Thomas Sjögren d680213a7b fix /etc/sysconfig/docker
closes #397

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-10-04 14:50:48 +02:00
Thomas Sjögren 6d73492aab
Merge pull request #392 from jammasterj89/master
Fixed exclude flag issue with functions_lib.sh
2019-09-02 14:29:59 +02:00
jammasterj89 f4e33ee54e
Fixed exclude flag issue with functions_lib.sh
Include the all text named functions within functions_lib.sh call if the -e flag is set.

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-09-02 13:22:28 +01:00
Thomas Sjögren b354514d29
Merge pull request #385 from J0WI/ro
Mount volumes read only
2019-08-29 15:13:34 +02:00
J0WI 59c289eefe Mount volumes read only
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2019-08-29 15:11:26 +02:00
Thomas Sjögren d1934b614e
Merge pull request #390 from jammasterj89/master
Issue #383 ability to exclude images
Closes #383, #369
2019-08-29 15:10:53 +02:00
jammasterj89 3d02432bc8
Removed whitespace
Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:48:24 +01:00
jammasterj89 ef206be6e0 Remove -t parameter
Removed -t parameter

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:59 +01:00
jammasterj89 e1d26673ee Remove check_images
Removed check_images due to removal of -t parameter and $images being set in docker-bench-security.sh

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:50 +01:00
jammasterj89 6cd952c7a1 Remove check_images
Removed check_images due to removal of -t parameter

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:46 +01:00
jammasterj89 c53157e184 Remove -t parameter
$images now set via -i and -x parameters

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:41 +01:00
jammasterj89 7f29aebd71 Added $images to $exclude
Added $images $exclude logic so now containers and images are excluded.
Added new $benchimagecont for images to replicate the $benchcont for containers.

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:35 +01:00
jammasterj89 af8b59f29d Added check_images
Added check_images to run the new check_images() function within tests/4_container_images.sh

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:29 +01:00
jammasterj89 4bb6e19965 Added check_images
Added check_images which moves the previous $imgList into this function and removed the else as this is handled within the main .sh

Signed-off-by: Niall T <jammasterj89@gmail.com>
2019-08-29 13:37:10 +01:00
Thomas Sjögren 495a8674c4
Merge pull request #391 from konstruktoid/master
catch community editions.
2019-08-29 13:03:07 +02:00
Thomas Sjögren e9d7398893 Merge branch 'master' of github.com:konstruktoid/docker-bench-security
* 'master' of github.com:konstruktoid/docker-bench-security:
  catch community editions
2019-08-29 13:00:48 +02:00
Thomas Sjögren 0cac0e339d catch community editions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-29 10:29:38 +02:00
Thomas Sjögren c8a7e87132
Merge pull request #386 from J0WI/enhance-install
Enhance installation of docker cli
2019-08-29 10:28:27 +02:00
Thomas Sjögren 4f3898257f catch community editions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-29 09:53:40 +02:00
Thomas Sjögren 5a829f9e8c
Merge pull request #389 from konstruktoid/CDB120
Cdb120
2019-08-28 13:12:05 +02:00
Thomas Sjögren 77a3bc65d7 fix 5.28
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 12:59:49 +02:00
Thomas Sjögren 261e3f2611 update version yell
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 12:43:06 +02:00
Thomas Sjögren 71f63a192a tmp fix for json
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 12:36:49 +02:00
Thomas Sjögren 7ad1c816e8 update README and contributors
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 12:30:34 +02:00
Thomas Sjögren 17c6262d2f formating
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 12:14:35 +02:00
Thomas Sjögren d7f1d9753a ignore section 8 if community edition
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 11:49:22 +02:00
Thomas Sjögren a785c02c59 add INFO for section 8
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-28 10:26:44 +02:00
Thomas Sjögren adb6a42c4a update function names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 16:11:55 +02:00
Thomas Sjögren 7110df800b section 8 docker enterprise skeleton
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 16:11:38 +02:00
Thomas Sjögren bcd6e5dd55 json sections
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 16:10:59 +02:00
Thomas Sjögren ca3714bc16 first pass on section 7
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 16:03:29 +02:00
Thomas Sjögren 3d6dd81956 first pass on section 6
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 15:52:06 +02:00
Thomas Sjögren 0b007baf7e first pass on section 5
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 15:43:29 +02:00
Thomas Sjögren e5c22c5f01 first pass on section 4
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 15:25:54 +02:00
Thomas Sjögren f968597051 first pass on section 3
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 15:13:19 +02:00
Thomas Sjögren bb0d65ceb1 update function list
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 14:54:23 +02:00
Thomas Sjögren 6c6d0836a4 first pass on section 2
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 14:54:08 +02:00
Thomas Sjögren 82644982a8 move old 2.13 to community checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-27 14:53:42 +02:00
Thomas Sjögren d963b93fcc update info output
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 15:13:50 +02:00
Thomas Sjögren f2a7e6d6a6 update sect 1 function names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 15:13:31 +02:00
Thomas Sjögren 28f16f0afd add 1.2.9, #ref https://github.com/docker/docker-bench-security/pull/359
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 14:41:37 +02:00
Thomas Sjögren 6105f02a16 first pass on section 1
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 14:37:25 +02:00
Thomas Sjögren 7685c0417a update CIS Docker Benchmark version and link
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 14:12:03 +02:00
Thomas Sjögren 227f2faa5b bump version to 1.3.5
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 14:11:10 +02:00
Thomas Sjögren 6720207512 FROM alpine:3.10
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-08-26 14:10:42 +02:00
J0WI ee9a0c5681 Enhance installation of docker cli
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2019-07-01 14:58:19 +02:00
Thomas Sjögren 50bfd11df9
Merge pull request #384 from J0WI/alpine10
Update Alpine to 3.10
2019-07-01 08:39:26 +00:00
J0WI 6e2e70da8d Update Alpine to 3.10
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2019-06-29 00:25:19 +02:00
Thomas Sjögren e6f1f81b7c
Merge pull request #381 from konstruktoid/alpineupdate
update distro Dockerfile
2019-05-12 20:13:29 +02:00
Thomas Sjögren 972f855d42 update distro Dockerfile
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-05-12 20:11:33 +02:00
Thomas Sjögren ffe1d6a762
Merge pull request #380 from ellerbrock/master
Update to Alpine 3.9 (CVE-2019-5021)
2019-05-12 20:02:03 +02:00
Maik Ellerbrock 3f3cf01fa8 Update to Alpine 3.9 (CVE-2019-5021)
Signed-off-by: Maik Ellerbrock <opensource@frapsoft.com>
2019-05-12 00:56:34 +02:00
Thomas Sjögren 689c22fbeb
Merge pull request #378 from konstruktoid/contrib
ignore case when sorting
2019-05-05 20:32:48 +00:00
Thomas Sjögren e09aff559c ignore case when sorting
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-05-05 22:31:26 +02:00
Thomas Sjögren e71d05de20
Merge pull request #377 from konstruktoid/contrib
add CONTRIBUTORS.md and update email
2019-05-05 20:27:47 +00:00
Thomas Sjögren 0f6c6d21a1 add CONTRIBUTORS.md and update email
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-05-05 22:27:05 +02:00
Thomas Sjögren 55ab78bb12
Merge pull request #373 from konstruktoid/ISSUE309
use only year and month for version check #309
2019-04-13 14:35:12 +00:00
Thomas Sjögren 326e31f403 use only year and month for version check #309
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-04-13 16:33:57 +02:00
Thomas Sjögren 7aaebd63c4
Merge pull request #372 from konstruktoid/ISSUE371
add binaries as volumes #371
2019-04-10 11:16:22 +00:00
Thomas Sjögren 166ccf7832 add binaries as volumes #371
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-04-10 13:15:33 +02:00
Thomas Sjögren f791eb8a70
Merge pull request #368 from konstruktoid/revertgrep
revert grep thought fail
2019-03-20 08:57:59 +00:00
Thomas Sjögren 1c8699bcf3 revert grep thought fail
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-03-20 09:57:19 +01:00
Thomas Sjögren 2e6b7ec653
Merge pull request #367 from konstruktoid/ISSUE362c
accept only if ADD in / #362
2019-03-19 13:55:10 +00:00
Thomas Sjögren 740439d352 accept only if ADD in / #362
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-03-19 14:54:38 +01:00
Thomas Sjögren 5370aef248
Merge pull request #366 from konstruktoid/ISSUE362b
exclude first ADD since its most often the base #362
2019-03-19 13:28:01 +00:00
Thomas Sjögren cec124a162 exclude first ADD since its most often the base #362
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-03-19 14:27:02 +01:00
Thomas Sjögren f01acac650
Merge pull request #364 from konstruktoid/ISSUE362
INFO shouldnt increase score #362
2019-03-14 11:13:22 +00:00
Thomas Sjögren d942b12e0a INFO shouldnt increase score #362
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-03-14 10:32:39 +01:00
Thomas Sjögren b802f55f1a
Merge pull request #361 from ekho/bugfix/check_2_9
Fixed check 2.9
2019-03-12 15:20:40 +00:00
Boris Gorbylev 689a5a62c5
Fixed check 2.9
Signed-off-by: Boris Gorbylev <ekho@ekho.name>
2019-02-21 19:15:38 +03:00
Thomas Sjögren f8be7239e5
Merge pull request #360 from konstruktoid/ISSUE358
catch root with uid and name as well #358 CVE-2019-5736
2019-02-13 15:00:46 +01:00
Thomas Sjögren 7e3ecaf17d catch root with uid and name as well #358 CVE-2019-5736
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-02-13 14:58:34 +01:00
Thomas Sjögren 6d5b15788a
Merge pull request #357 from konstruktoid/ISSUE356
4.9 resulttestjson "INFO" #356
2019-01-24 16:47:35 +01:00
Thomas Sjögren a911c23915 4.9 resulttestjson "INFO" #356
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2019-01-24 16:46:51 +01:00
Thomas Sjögren 2fb15f4b6d
Merge pull request #353 from kakakakakku/improve-readme
Updated README.md / Added -t option
2019-01-17 15:24:00 +01:00
kakakakakku c560b044e4 Updated README.md
Signed-off-by: Yoshiaki Yoshida <y.yoshida22@gmail.com>
2019-01-17 21:04:46 +09:00
Thomas Sjögren b1bbe07902
Merge pull request #352 from anthony-roger/master
feat: add target -t option to run checks for specifics images
2019-01-15 09:24:13 +01:00
Anthony Roger 1dd7956760 feat: add the ability to select the images to be check from registry in order to integrate in ci
Signed-off-by: Anthony Roger <aroger@softwaymedical.fr>
2018-12-11 14:39:16 +01:00
Thomas Sjögren cc6b16d8a7
Merge pull request #349 from konstruktoid/ISSUE286
exclude docker-bench-security container #286
2018-11-23 10:51:12 +01:00
Thomas Sjögren 9d9da6d375 exclude docker-bench-security container #286
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-11-23 10:50:34 +01:00
Thomas Sjögren a7a24a8d7f
Merge pull request #347 from telepresencebot2/master
fix test 7.4 using 5.25 as a model
2018-11-15 08:56:45 +01:00
telepresencebot2 4bf876296a fix test 7.4 using 5.25 as a model
Signed-off-by: Taylor Lucy <talucy@franklinamerican.com>
2018-11-14 14:30:51 -06:00
Thomas Sjögren 7088b21f02
Merge pull request #345 from boblington/issue-344
Fix missing check_7_4
2018-11-12 09:58:22 +01:00
Thomas Sjögren 3887a4095d
Merge pull request #343 from boblington/master
fix bugs in -e option
2018-11-12 09:55:55 +01:00
Cheng-Li Jerry Ma a46b6500af Fix missing check_7_4
Signed-off-by: Cheng-Li Jerry Ma <chengli.ma@gmail.com>
2018-11-09 09:47:41 -07:00
Cheng-Li Jerry Ma 304094cbb2 Fix -e option totalChecks and currentScore always 0
Signed-off-by: Cheng-Li Jerry Ma <chengli.ma@gmail.com>
2018-11-08 15:35:20 -07:00
Cheng-Li Jerry Ma 37ccf4dbcf Fix -e option last entry is not excluded in docker
Signed-off-by: Cheng-Li Jerry Ma <chengli.ma@gmail.com>
2018-11-08 15:34:55 -07:00
Cheng-Li Jerry Ma db8a8c0d96 Fix -e option always skipping check_1, check_2, check_3 and ...
this also caused the output json to be malformed without proper grouping/nesting

Signed-off-by: Cheng-Li Jerry Ma <chengli.ma@gmail.com>
2018-11-08 15:33:23 -07:00
Thomas Sjögren a9caef9eb6
Merge pull request #339 from ellerbrock/master
Update Alpine Linux to Version 3.8 (latest)
2018-11-07 11:40:15 +01:00
Maik Ellerbrock af334986e1
build(update alpine linux to version 3.8):
Signed-off-by: Maik Ellerbrock <opensource@frapsoft.com>
2018-11-07 10:20:45 +01:00
Thomas Sjögren bcd1c22845
Merge pull request #338 from konstruktoid/lint
Lint
2018-11-01 11:07:34 +01:00
Thomas Sjögren 75c8f3d2da cleanup
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-11-01 11:05:52 +01:00
Thomas Sjögren 391e09f76a linting
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-11-01 10:24:36 +01:00
Thomas Sjögren 4725582a0c
Merge pull request #337 from konstruktoid/issue321
load dependencies in correct order
2018-10-25 12:06:52 +02:00
Thomas Sjögren eb9ea59fe5 load dependencies in correct order
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-25 12:05:48 +02:00
Thomas Sjögren d45081bd1a
Merge pull request #336 from konstruktoid/issue321
Issue321
2018-10-25 11:42:27 +02:00
Thomas Sjögren 1647e47976 update README
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-25 11:39:35 +02:00
Thomas Sjögren 2cbfd83f53 add nocolor option #321
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-25 11:34:14 +02:00
Thomas Sjögren 9dd2fa5ce0
Merge pull request #335 from konstruktoid/issue330
sed option extravaganza #330
2018-10-25 08:48:07 +02:00
Thomas Sjögren e84e9e52e0
Merge pull request #333 from konstruktoid/issue332
use mountpoint and DockerRootDir #332
2018-10-25 08:47:42 +02:00
Thomas Sjögren 6789403599
Merge pull request #328 from konstruktoid/issue286
add include option #286
2018-10-25 08:47:04 +02:00
Thomas Sjögren afa289d9b7 sed option extravaganza #330
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-24 10:01:27 +02:00
Thomas Sjögren d5b900ce05 use mountpoint and DockerRootDir #332
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-23 15:26:41 +02:00
Thomas Sjögren 1721253616
Merge pull request #331 from konstruktoid/issue330
update README #330
2018-10-23 12:17:42 +02:00
Thomas Sjögren 704471c52d update README #330
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-23 12:16:55 +02:00
Thomas Sjögren 36b73c4398 add include option #286
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-10-15 16:21:00 +02:00
Thomas Sjögren 9ca5b8b2e1
Merge pull request #314 from draios/master
Improve docker-bench-security json output
2018-10-12 12:27:20 +02:00
Mark Stemm ec7d8ce690 Improve docker-bench-security json output
Add a test object for each test performed by the script. Each object has
an id N.M, a desc property describing the test, and the result. Some
tests include additional information about the test e.g. "No TLS
Certificate Found". That can be found in an optional details property of
the test object.

Also, some tests might also return a list of containers, images, users,
etc. This is included in an optional items property of the test object.

Instead of having all test results as top-level objects, break the test
results into sections. Each section has an id + description e.g. "1" and
"Host Configuration". The tests for that section are an array below that
object.

All of the additional json output is implemented by adding new functions
startsectionjson(), endsectionjson(), starttestjson(), and
resulttestjson() that take the id/desc/etc as arguments and print the
proper json properties. It also required adding an "end" test to each
script that calls endsectionjson().

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2018-10-11 13:39:55 -07:00
Thomas Sjögren bbf43c88e1
Merge pull request #326 from konstruktoid/issu325
ref #325 daemon.json permissions
2018-09-27 09:51:02 +02:00
Thomas Sjögren 773625a894 ref #325 daemon.json permissions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-09-27 09:49:32 +02:00
Thomas Sjögren feced0f6b2
Merge pull request #313 from nbrownuk/issue295-fix-tls-config-check
Fixes incorrect reporting of TLS configuration in test 2.6
2018-08-08 11:58:47 +02:00
Thomas Sjögren dbe0ada203
Merge pull request #322 from konstruktoid/ISSUE316
dont decrease 5.29 #316
2018-08-06 09:51:42 +02:00
Thomas Sjögren f1137cd36a dont decrease 5.29 #316
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-08-06 09:51:06 +02:00
Thomas Sjögren b408fb3e86
Merge pull request #317 from joewilliams/joewilliams-patch-1
fix docker user json output
2018-08-06 09:37:29 +02:00
Joe Williams cfb3357a12 fix docker user json output
This prints out the docker users in a similar fashion to the other tests, including `INFO` rather than just the system command output.

Signed-off-by: Joe Williams <joe.williams@github.com>
2018-07-26 15:07:59 -04:00
Nigel Brown 167c3507a2 Fixes incorrect reporting of TLS configuration in test 2.6
Signed-off-by: Nigel Brown <nigel@windsock.io>
2018-07-10 14:35:30 +01:00
Thomas Sjögren b73d254e76
Merge pull request #311 from konstruktoid/ISSUE309
deprecated --disable-legacy-registry
2018-07-01 20:55:32 +02:00
Thomas Sjögren c8894d3b26 deprecated --disable-legacy-registry
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-07-01 20:53:20 +02:00
Thomas Sjögren b881675d51
Merge pull request #310 from konstruktoid/ISSUE302
Issue302
2018-07-01 20:07:27 +02:00
Thomas Sjögren 78700f2600 consistent currentScore
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-07-01 20:04:20 +02:00
Thomas Sjögren ebfb20c65f 4.7 is not scored
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-07-01 20:01:10 +02:00
Thomas Sjögren ca41ed7db3
Merge pull request #308 from mike01/path_variable_fix
fix for path variable
2018-07-01 19:50:10 +02:00
Michael Stahn d24ee50420 fix for path variable
Signed-off-by: Michael Stahn <michael.stahn.42@gmail.com>
2018-06-26 21:57:15 +02:00
Thomas Sjögren b926f0446a
Merge pull request #305 from danielino/master
fix count total_containers for swarm mode
2018-05-18 12:58:00 +02:00
Daniele Marcocci 77074962b1 fix count total_containers for swarm mode
Signed-off-by: Daniele Marcocci <daniele.marcocci@par-tec.it>
2018-05-18 10:17:42 +02:00
Thomas Sjögren f7518b4d7a
Merge pull request #301 from konstruktoid/yell
prettier yell output
2018-05-10 15:47:56 +02:00
Thomas Sjögren dfccc21a18 prettier yell output
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-05-10 15:47:23 +02:00
Thomas Sjögren 6829756643
Merge pull request #300 from konstruktoid/lint
Lint and yell function
2018-05-10 15:43:30 +02:00
Thomas Sjögren 11230d052e formatting
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-05-10 15:41:27 +02:00
Thomas Sjögren 6c0dce7b19 yell function and version varible
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-05-10 15:19:10 +02:00
Thomas Sjögren 2a549f5be5
Merge pull request #299 from konstruktoid/issue298
add -e option to exclude checks
2018-05-10 14:50:08 +02:00
Thomas Sjögren f78145214a add -e option to exclude checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-05-10 14:45:59 +02:00
Thomas Sjögren d03f69931c
Merge pull request #297 from konstruktoid/ISSUE296
enable docker run script options
2018-05-02 14:53:26 +02:00
Thomas Sjögren 173d80f30e enable docker run script options
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-05-02 14:52:38 +02:00
Thomas Sjögren 0c00cc0336
Merge pull request #293 from mpritter76/master
Minor fix to ensure exclude only works against container name
2018-02-28 09:22:01 +01:00
Mike Ritter b37dfb95e3 Minor fix to ensure exclude only works against container name
Signed-off-by: Mike Ritter <mike.ritter@target.com>
2018-02-27 18:24:25 -06:00
Thomas Sjögren dd61f061fc
Merge pull request #292 from mpritter76/master
New Features
2018-02-27 15:56:14 +01:00
Mike Ritter a3094ac5c6 New Features
Signed-off-by: Mike Ritter <mike.ritter@target.com>
2018-02-27 08:43:51 -06:00
Thomas Sjögren 44b82d53e2
Merge pull request #288 from konstruktoid/issue287
fix 2.18
2018-02-09 11:03:45 +01:00
Thomas Sjögren bdeaeaa05a fix 2.18
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-02-09 11:02:04 +01:00
Thomas Sjögren e169d99736
Merge pull request #285 from konstruktoid/checkexamples
Checkexamples
2018-01-18 11:31:24 +01:00
Thomas Sjögren 2494261ddf remove Vagrantfile
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-18 11:30:31 +01:00
Thomas Sjögren 2aa9719dd6 silence example check output
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-18 11:29:20 +01:00
Thomas Sjögren 57365ba1e4 fail if check doesnt exist
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-18 11:29:02 +01:00
Thomas Sjögren 83ed8122ef update the README about community checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-18 11:28:36 +01:00
Thomas Sjögren 2958a8b806
Merge pull request #284 from konstruktoid/communitychecks
Communitychecks
2018-01-17 16:14:47 +01:00
Thomas Sjögren 700202ac7b add header
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-17 16:13:29 +01:00
Thomas Sjögren 8fe0b5ea02 add example community check
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-17 16:11:04 +01:00
Thomas Sjögren ed73b3728f
Merge pull request #283 from konstruktoid/functionsupdate
Functionsupdate
2018-01-16 13:53:44 +01:00
Thomas Sjögren 8142de8334 convert all checks to functions
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-16 13:46:49 +01:00
Thomas Sjögren dc369a6bad move audit rules default path variable
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-16 13:46:08 +01:00
Thomas Sjögren 50ca5fc7ff add function helper
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-16 13:45:45 +01:00
Thomas Sjögren d92a8abe13 update README with examples
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-16 13:45:06 +01:00
Thomas Sjögren 6ec6ee0638 add check option, and function names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-16 13:44:43 +01:00
Thomas Sjögren ddf231e377
Merge pull request #282 from konstruktoid/issue279
add iproute2 to alpine builds
2018-01-12 12:03:52 +01:00
Thomas Sjögren 18a034c3fd add iproute2 to alpine builds
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-12 12:03:02 +01:00
Thomas Sjögren 166ff96c17
Merge pull request #266 from konstruktoid/issue265
Add check count and scoring
2018-01-12 11:52:24 +01:00
Thomas Sjögren c0345c83a6
Merge branch 'master' into issue265 2018-01-12 11:49:31 +01:00
Thomas Sjögren 25b40c94a2
Merge branch 'master' into issue265 2018-01-12 11:49:04 +01:00
Thomas Sjögren ce5ab6b063 update version check
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-12 11:42:52 +01:00
Thomas Sjögren 60e119fac0
Merge pull request #281 from konstruktoid/issue277
catch seccomp:unconfined|seccomp=unconfined
2018-01-12 11:38:07 +01:00
Thomas Sjögren 57acb04a96 catch seccomp:unconfined|seccomp=unconfined
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-12 11:36:14 +01:00
Thomas Sjögren bdba64c8c0
Merge pull request #280 from konstruktoid/version
adapt to 18.01 docker version
2018-01-12 11:09:47 +01:00
Thomas Sjögren e0a302eb40 adapt to 18.01 docker version
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2018-01-12 11:09:16 +01:00
Thomas Sjögren ddf821f22c
Merge pull request #279 from kbabiochSUSE/feat/ss
Replace netstat by ss
2018-01-12 10:59:23 +01:00
Karol Babioch f5542683c5 Replaced net-tools with iproute2 in Dockerfiles
Signed-off-by: Karol Babioch <kbabioch@suse.de>
2018-01-12 10:44:04 +01:00
Karol Babioch 997ce7330e Replace netstat by ss
ss(8) is a modern replacement for netstat(8). The former is slowly replacing
the latter in major Linux distributions, which makes it necessary to switch
at some point.

This addresses #278.

Signed-off-by: Karol Babioch <kbabioch@suse.de>
2018-01-11 16:52:54 +01:00
Thomas Sjögren aae04fb75e
Merge pull request #274 from ellerbrock/dockerignore
perf(update .dockerignore file):
2017-12-15 09:24:42 +01:00
Maik Ellerbrock 34a8dfeb97
perf(update .dockerignore file):
Signed-off-by: Maik Ellerbrock <opensource@frapsoft.com>
2017-12-14 19:41:02 +01:00
Thomas Sjögren 688a824db2
Merge pull request #272 from ellerbrock/alpine-upgrade
feat(dockerfile): update alpine and cleanup the dockerfile
2017-12-14 10:09:06 +01:00
Maik Ellerbrock 2521d596d1
fix(dockerfile): copy dockerfile to distro 2017-12-14 02:46:48 +01:00
Maik Ellerbrock dcfcccd5f7
refactor(healthcheck): reactivate healthcheck 2017-12-14 00:22:54 +01:00
Maik Ellerbrock bbe32c5bec
perf(dockerfile): move copy at the end to improve cache invalidation 2017-12-11 22:14:47 +01:00
Maik Ellerbrock be2a7b6b6e
feat(dockerfile): update alpine and cleanup the dockerfile
Signed-off-by: Maik Ellerbrock <opensource@frapsoft.com>
2017-12-11 01:14:02 +01:00
Thomas Sjögren d05852c171
Merge pull request #271 from tpartington/alpine-https-repositories
Switch to the HTTPS alpine apk repositories
2017-12-06 10:24:22 +01:00
Tom Partington 6e70402f4a Switch to the HTTPS endpoint for the alpine APK repositories
Signed-off-by: Tom Partington <tom.partington@cevo.com.au>
2017-12-06 11:14:20 +11:00
Thomas Sjögren 3633545c35
Merge pull request #268 from jhermann/patch-1
Add "--userns host" to `docker run` example
2017-11-23 10:23:09 +01:00
Thomas Sjögren 8d6a23f423
Merge pull request #269 from znerd/master
Trivial: fixed typo in README file.
2017-11-20 15:50:27 +01:00
Ernst de Haan 173d347c52
Trivial: fixed typo in README file.
Fixed a small typo; changed “[…] was build to” to “[…] was built to”
2017-11-20 15:22:24 +01:00
Jürgen Hermann a4afe51cb6 Add "--userns host" to docker run example
If UID remapping is configured as a default, it has to be defeated.

Signed-off-by: Juergen Hermann <jh@web.de>
2017-11-20 15:14:05 +01:00
Thomas Sjögren 976463a87b add score and totalChecks to 7_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:41:15 +02:00
Thomas Sjögren 7ebe21823d add score and totalChecks to 6_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:41:03 +02:00
Thomas Sjögren e32910172f add score and totalChecks to 5_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:40:52 +02:00
Thomas Sjögren de82250274 add score and totalChecks to 4_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:40:12 +02:00
Thomas Sjögren f9be3996f4 add score and totalChecks to 3_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:39:52 +02:00
Thomas Sjögren ec4060ea2f add score and totalChecks to 2_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:39:32 +02:00
Thomas Sjögren 3d532a29ac add score and totalChecks to 1_
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:39:18 +02:00
Thomas Sjögren a7600dd539 add integer for json logging
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:38:31 +02:00
Thomas Sjögren 8424b0a6ba add check and score info
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-23 15:38:08 +02:00
Thomas Sjögren ad045075eb Merge pull request #264 from konstruktoid/issue247
skeleton json
2017-10-23 09:35:21 +02:00
Thomas Sjögren 4bbfc5465e mention dvs version
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 11:37:54 +02:00
Thomas Sjögren fa9b227a7b check 7.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 10:38:31 +02:00
Thomas Sjögren e1adab029d check 6.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 10:28:42 +02:00
Thomas Sjögren be4dd69f3f check 5.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 10:25:23 +02:00
Thomas Sjögren b8fac4a7d2 check 4.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 10:02:48 +02:00
Thomas Sjögren 7a1b813cdc check 3.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-13 09:53:15 +02:00
Thomas Sjögren 78b1f5dc86 check 2.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-10 14:46:08 +02:00
Thomas Sjögren a3612c574e check 1.x json log
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-10 14:33:32 +02:00
Thomas Sjögren 9e3d42c5f5 ignore all logs
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-10 14:20:38 +02:00
Thomas Sjögren 809da21c4a skeleton json
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-10 13:54:59 +02:00
Thomas Sjögren a5a40e80a9 Merge pull request #263 from konstruktoid/134
1.3.4-pre
2017-10-06 16:05:57 +02:00
Thomas Sjögren 5af0568986 1.3.4-pre
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-10-06 16:04:51 +02:00
Thomas Sjögren d062b1edce Merge pull request #256 from konstruktoid/date_255
busybox date conversion
2017-10-06 09:57:41 +02:00
Thomas Sjögren 02987bbb98 Merge pull request #259 from konstruktoid/k10d/reqversion
require Docker 1.13 or later
2017-09-21 10:23:11 +02:00
Thomas Sjögren 55a8ec6b39 require Docker 1.13 or later
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-09-21 10:22:26 +02:00
Thomas Sjögren 4ec0962704 Merge pull request #257 from jgsqware/2-14-check-dockerd
update 2.14
2017-09-21 10:18:34 +02:00
Thomas Sjögren eeeb010a43 Merge pull request #258 from jgsqware/1.1-check-mountpoint
use mountpoint to check if /var/lib/docker is on separate partition
2017-09-21 09:24:15 +02:00
Julien Garcia Gonzalez 683a728364 update 1.1
Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>
2017-09-21 08:53:07 +02:00
Julien Garcia Gonzalez 1d07abf659
update 2.14 2017-09-21 08:15:09 +02:00
Thomas Sjögren f8354c1017 busybox date conversion
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-09-20 11:10:36 +02:00
Thomas Sjögren e9bc9bd953 Merge pull request #250 from konstruktoid/png
less ugly png
2017-07-14 11:23:09 +02:00
Thomas Sjögren 495b4402ba less ugly png
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-14 11:21:53 +02:00
Thomas Sjögren 5d8f34954f Merge pull request #248 from konstruktoid/cisDockerCE
CIS Docker CE
2017-07-10 15:17:16 +02:00
Thomas Sjögren bffb682ef7 update png
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 15:16:32 +02:00
Thomas Sjögren 44e46c63c3 spaces
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 13:06:23 +02:00
Thomas Sjögren 84baf80b7d no short forms
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 13:03:45 +02:00
Thomas Sjögren 565ef3fb3b redirect errors
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 13:03:10 +02:00
Thomas Sjögren 73afde56d0 date conversion
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:38:21 +02:00
Thomas Sjögren 6f0303ef56 versioning
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:31:22 +02:00
Thomas Sjögren 00c2d6e796 docker date versioning
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:24:03 +02:00
Thomas Sjögren dac6a62ba1 space
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:10:37 +02:00
Thomas Sjögren 5bf4f824a4 pass 7.7
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:08:31 +02:00
Thomas Sjögren 125eaf90cd inspect requires images
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:07:00 +02:00
Thomas Sjögren 60afd7ec83 7.7 verify swarm
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:05:42 +02:00
Thomas Sjögren 3736e0e711 docs
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:03:40 +02:00
Thomas Sjögren 2f0112497a md formating
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 12:02:15 +02:00
Thomas Sjögren cabb5d8dbc update CONTRIBUTING.md
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 11:46:49 +02:00
Thomas Sjögren 789af6d8d6 add Docker Swarm Configuration tests
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 11:43:15 +02:00
Thomas Sjögren e1e902b3ed update checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 11:19:02 +02:00
Thomas Sjögren 88b48315bc update checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 11:16:49 +02:00
Thomas Sjögren efa3b4522f update check names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:56:18 +02:00
Thomas Sjögren 03974c0854 update titles and tests
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:37:09 +02:00
Thomas Sjögren d93bc6b075 update section 2, clean tests
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:23:40 +02:00
Thomas Sjögren 2226ad1b90 update versions, CIS Docker Community Edition Benchmark
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:22:57 +02:00
Thomas Sjögren e8d553b4c0 Update to CIS Docker Community Edition Benchmark
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:22:27 +02:00
Thomas Sjögren 2dd6f2ebec update test names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-07-07 10:21:38 +02:00
Thomas Sjögren 7d0def16df Merge pull request #246 from konstruktoid/alpine
alpine 3.6
2017-05-29 12:03:57 +02:00
Thomas Sjögren f262f7d5b5 alpine 3.6
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-05-29 12:03:04 +02:00
Thomas Sjögren d2936821b2 Merge pull request #245 from konstruktoid/version
auto update due to new versioning
2017-05-08 15:22:11 +02:00
Thomas Sjögren e5afda701f auto update due to new versioning
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-05-08 14:58:16 +02:00
Thomas Sjögren 0be551b31f Merge pull request #243 from konstruktoid/missing_audit
supress grep is auditd rules is missing
2017-04-21 14:24:45 +02:00
Thomas Sjögren 986aaa67fb supress grep is auditd rules is missing
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-04-21 14:24:02 +02:00
Thomas Sjögren 7e6ac47467 Merge pull request #242 from konstruktoid/issue_241
.Server.Experimental pre-1.13
2017-04-21 13:53:10 +02:00
Thomas Sjögren 5d9101cfc2 .Server.Experimental pre-1.13
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2017-04-21 13:51:09 +02:00
34 changed files with 4780 additions and 1531 deletions

View File

@ -1 +1,6 @@
.git
*
!docker-bench-security.sh
!functions/
!tests/
!log/
log/*

19
.github/workflows/issues.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Issue assignment
on:
issues:
types: [opened]
permissions:
contents: read
jobs:
auto-assign:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: 'auto-assign issue'
uses: pozil/auto-assign-issue@74b9f64cc1a08f99358061073e243a4c3d7dd5c4 # v1.11.0
with:
assignees: konstruktoid

80
.github/workflows/slsa.yml vendored Normal file
View File

@ -0,0 +1,80 @@
---
name: SLSA
on:
push:
release:
permissions:
contents: write
types: [published, released]
permissions:
contents: read
jobs:
build:
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Build artifacts
run: |
find *.sh functions/* tests/* Dockerfile Vagrantfile -exec sha256sum {} \; > ${{ env.REPOSITORY_NAME }}.sha256
- name: Generate hashes
shell: bash
id: hash
run: |
echo "hashes=$(sha256sum ${{ env.REPOSITORY_NAME }}.sha256 | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Upload ${{ env.REPOSITORY_NAME }}.sha256
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: ${{ env.REPOSITORY_NAME }}.sha256
path: ${{ env.REPOSITORY_NAME }}.sha256
if-no-files-found: error
retention-days: 5
provenance:
needs: [build]
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
with:
base64-subjects: "${{ needs.build.outputs.hashes }}"
upload-assets: ${{ startsWith(github.ref, 'refs/tags/') }}
release:
permissions:
actions: read
id-token: write
contents: write
needs: [build, provenance]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash
- name: Download ${{ env.REPOSITORY_NAME }}.sha256
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ env.REPOSITORY_NAME }}.sha256
- name: Upload asset
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
with:
files: |
${{ env.REPOSITORY_NAME }}.sha256

4
.gitignore vendored
View File

@ -1 +1,3 @@
*.log
log/*
*.swp*
.vagrant/

View File

@ -8,54 +8,51 @@ project, and follows the same rules and principles. If you're already familiar
with the way Docker does things, you'll feel right at home.
Otherwise, go read
[Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md).
[Contribute to the Moby Project](https://github.com/moby/moby/blob/master/CONTRIBUTING.md).
## Development Environment Setup
The only thing you need to hack on Docker Bench for Security is a POSIX 2004
compliant shell. We try to keep the project compliant for maximum portability.
### Start hacking
You can build the container that wraps the docker-bench for security:
```sh
git clone git@github.com:docker/docker-bench-security.git
cd docker-bench-security
docker build -t docker-bench-security .
git clone git@github.com:docker/docker-bench-security.git
cd docker-bench-security
docker build -t docker-bench-security .
```
Or you can simply run the shell script locally:
```sh
git clone git@github.com:docker/docker-bench-security.git
cd docker-bench-security
sh docker-bench-security.sh
git clone git@github.com:docker/docker-bench-security.git
cd docker-bench-security
sudo sh docker-bench-security.sh
```
The Docker Bench has the main script called `docker-bench-security.sh`.
This is the main script that checks for all the dependencies, deals with
command line arguments and loads all the tests.
The tests are split in 6 different files:
The tests are split into the following files:
```sh
✗ tree tests/
tests/
├── 1_host_configuration.sh
├── 2_docker_daemon_configuration.sh
├── 3_docker_daemon_configuration_files.sh
├── 4_container_images.sh
├── 5_container_runtime.sh
└── 6_docker_security_operations.sh
├── 6_docker_security_operations.sh
├── 7_docker_swarm_configuration.sh
├── 8_docker_enterprise_configuration.sh
└── 99_community_checks.sh
```
To modify the Docker Bench for Security you should first clone the repository,
make your changes, check your code with `shellcheck`, `checkbashisms` or similar
tools, and then sign off on your commits. After that feel free to send us a
pull request with the changes.
make your changes, check your code with `shellcheck`, or similar tools, and
then sign off on your commits. After that feel free to send us a pull request
with the changes.
While this tool was inspired by the [CIS Docker 1.11.0 benchmark](https://benchmarks.cisecurity.org/downloads/show-single/index.cfm?file=docker16.110),
feel free to add new tests. We will try to turn [dockerbench.com](https://dockerbench.com)
into a list of good community benchmarks for both security and performance,
and we would love community contributions.
While this tool was inspired by the [CIS Docker 1.11.0 benchmark](https://www.cisecurity.org/benchmark/docker/)
and its successors, feel free to add new tests.

58
CONTRIBUTORS.md Normal file
View File

@ -0,0 +1,58 @@
The following people, listed in alphabetical order, have contributed to docker-bench-security:
* alberto <alberto@tutum.co>
* Andreas Stieger <astieger@suse.com>
* Anthony Roger <aroger@softwaymedical.fr>
* Aurélien Gasser <aurelien.gasser@gmail.com>
* binary <binary@webdev.fritz.box>
* Boris Gorbylev <ekho@ekho.name>
* Cheng-Li Jerry Ma <chengli.ma@gmail.com>
* Csaba Palfi <csaba@palfi.me>
* Daniele Marcocci <daniele.marcocci@par-tec.it>
* Dhawal Patel <dhawal.patel@nordstrom.com>
* Diogo Monica <diogo@docker.com>
* Diogo Mónica <diogo.monica@gmail.com>
* Ernst de Haan <ernst@ernstdehaan.com>
* HuKeping <hukeping@huawei.com>
* Ivan Angelov <iangelov@users.noreply.github.com>
* J0WI <J0WI@users.noreply.github.com>
* jammasterj89 <jammasterj89@gmail.com>
* Jessica Frazelle <princess@docker.com>
* Joachim Lusiardi <jlusiardi@users.noreply.github.com>
* Joachim Lusiardi <joachim@lusiardi.de>
* Joachim Lusiardi <shing19m@dev1.lusiardi.de>
* Joe Williams <joe.williams@github.com>
* Julien Garcia Gonzalez <julien@giantswarm.io>
* Jürgen Hermann <jh@web.de>
* kakakakakku <y.yoshida22@gmail.com>
* Karol Babioch <kbabioch@suse.de>
* Kevin Lim <kevin.lim@sap.com>
* kevinll <imhael@gmail.com>
* Liron Levin <liron@twistlock.com>
* liron-l <levinlir@gmail.com>
* LorensK <LorensK@users.noreply.github.com>
* lusitania <lusitania@users.noreply.github.com>
* Maik Ellerbrock <opensource@frapsoft.com>
* Mark Stemm <mark.stemm@gmail.com>
* Matt Fellows <matt.fellows@onegeek.com.au>
* Michael Crosby <crosbymichael@gmail.com>
* Michael Stahn <michael.stahn.42@gmail.com>
* Mike Ritter <mike.ritter@target.com>
* Mr. Secure <ben.github@mrsecure.org>
* MrSecure <MrSecure@users.noreply.github.com>
* Nigel Brown <nigel@windsock.io>
* Paul Czarkowski <username.taken@gmail.com>
* Paul Morgan <jumanjiman@gmail.com>
* Pete Sellars <psellars@gmail.com>
* Peter <lusitania@users.noreply.github.com>
* Ravi Kumar Vadapalli <vadapalli.ravikumar@gmail.com>
* Scott McCarty <scott.mccarty@gmail.com>
* Sebastiaan van Stijn <github@gone.nl>
* telepresencebot2 <telepresencebot2@users.noreply.github.com>
* Thomas Sjögren <konstruktoid@users.noreply.github.com>
* Tom Partington <tom.partington@cevo.com.au>
* Werner Buck <wernerbuck@gmail.com>
* will Farrell <willfarrell@users.noreply.github.com>
* Zvi "Viz" Effron <zeffron@riotgames.com>
This list was generated Tue Nov 5 09:45:35 UTC 2019.

View File

@ -1,24 +1,20 @@
FROM alpine:3.5
FROM alpine:3.18@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978
LABEL org.label-schema.name="docker-bench-security" \
org.label-schema.url="https://dockerbench.com" \
org.label-schema.vcs-url="https://github.com/docker/docker-bench-security.git"
LABEL \
org.label-schema.name="docker-bench-security" \
org.label-schema.url="https://dockerbench.com" \
org.label-schema.vcs-url="https://github.com/docker/docker-bench-security.git"
RUN \
apk upgrade --no-cache && \
apk add --no-cache \
docker \
dumb-init && \
rm -rf /usr/bin/docker-* /usr/bin/dockerd && \
mkdir /usr/local/bin/tests
RUN apk add --no-cache iproute2 \
docker-cli \
dumb-init \
jq
COPY ./*.sh /usr/local/bin/
COPY ./tests/*.sh /usr/local/bin/tests/
WORKDIR /usr/local/bin
COPY . /usr/local/bin/
HEALTHCHECK CMD exit 0
ENTRYPOINT [ "/usr/bin/dumb-init", "docker-bench-security.sh" ]
WORKDIR /usr/local/bin
ENTRYPOINT [ "/usr/bin/dumb-init", "/bin/sh", "docker-bench-security.sh" ]
CMD [""]

View File

@ -30,5 +30,5 @@
[people.konstruktoid]
Name = "Thomas Sjögren"
Email = "thomas.sjogren@outlook.com"
Email = "thomas.sjogren@protonmail.com"
GitHub = "konstruktoid"

185
README.md
View File

@ -1,69 +1,51 @@
# Docker Bench for Security
![Docker Bench for Security running](https://raw.githubusercontent.com/docker/docker-bench-security/master/benchmark_log.png "Docker Bench for Security running")
![Docker Bench for Security running](img/benchmark_log.png)
The Docker Bench for Security is a script that checks for dozens of common
best-practices around deploying Docker containers in production. The tests are
all automated, and are inspired by the [CIS Docker 1.13 Benchmark](https://benchmarks.cisecurity.org/tools2/docker/CIS_Docker_1.13.0_Benchmark_v1.0.0.pdf).
We are releasing this as a follow-up to our [Understanding Docker Security and Best Practices](https://blog.docker.com/2015/05/understanding-docker-security-and-best-practices/)
blog post.
The Docker Bench for Security is a script that checks for dozens of common best-practices around deploying Docker containers in production. The tests are all automated, and are based on the [CIS Docker Benchmark v1.6.0](https://www.cisecurity.org/benchmark/docker/).
We are making this available as an open-source utility so the Docker community
can have an easy way to self-assess their hosts and docker containers against
this benchmark.
We are making this available as an open-source utility so the Docker community can have an easy way to self-assess their hosts and Docker containers against this benchmark.
Release | CIS |
:---:|:---:|
1.6.0|1.6.0|
1.5.0|1.5.0|
1.3.6|1.4.0|
1.3.5|1.2.0|
1.3.3|1.1.0|
1.3.0|1.13.0|
## Running Docker Bench for Security
We packaged docker bench as a small container for your convenience. Note that
this container is being run with a *lot* of privilege -- sharing the host's
filesystem, pid and network namespaces, due to portions of the benchmark
applying to the running host. Don't forget to adjust the shared volumes
according to your operating system, for example it might not use systemd.
### Run from your base host
The easiest way to run your hosts against the Docker Bench for Security is by
running our pre-built container:
```sh
docker run -it --net host --pid host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /var/lib:/var/lib \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/lib/systemd:/usr/lib/systemd \
-v /etc:/etc --label docker_bench_security \
docker/docker-bench-security
```
Docker bench requires Docker 1.10.0 or later in order to run.
Note that when distributions doesn't contain `auditctl`, the audit tests will
check `/etc/audit/audit.rules` to see if a rule is present instead.
Distribution specific Dockerfiles that fixes this issue are available in the
[distros directory](https://github.com/docker/docker-bench-security/tree/master/distros).
The [distribution specific Dockerfiles](https://github.com/docker/docker-bench-security/tree/master/distros)
may also help if the distribution you're using haven't yet shipped Docker
version 1.10.0 or later.
## Building Docker Bench for Security
If you wish to build and run this container yourself, you can follow the
following steps:
You can simply run this script from your base host by running:
```sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
docker build -t docker-bench-security .
docker run -it --net host --pid host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /var/lib:/var/lib \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/lib/systemd:/usr/lib/systemd \
-v /etc:/etc --label docker_bench_security \
docker-bench-security
sudo sh docker-bench-security.sh
```
or use [Docker Compose](https://docs.docker.com/compose/):
> Note: [`jq`](https://jqlang.github.io/jq/) is an optional but recommended dependency.
### Run with Docker
#### Building Docker image
You have two options if you wish to build and run this container yourself:
1. Use Docker Build:
```sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
docker build --no-cache -t docker-bench-security .
```
Followed by an appropriate `docker run` command as stated below.
2. Use Docker Compose:
```sh
git clone https://github.com/docker/docker-bench-security.git
@ -71,13 +53,100 @@ cd docker-bench-security
docker-compose run --rm docker-bench-security
```
Also, this script can also be simply run from your base host by running:
_Please note that the `docker/docker-bench-security` image is out-of-date and and a manual build is required. See [#405](https://github.com/docker/docker-bench-security/issues/405) for more information._
Note that this container is being run with a *lot* of privilege -- sharing the host's filesystem, pid and network namespaces, due to portions of the benchmark applying to the running host.
### Using the container
```sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
sh docker-bench-security.sh
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc:ro \
-v /usr/bin/containerd:/usr/bin/containerd:ro \
-v /usr/bin/runc:/usr/bin/runc:ro \
-v /usr/lib/systemd:/usr/lib/systemd:ro \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security
```
This script was build to be POSIX 2004 compliant, so it should be portable
across any Unix platform.
Don't forget to adjust the shared volumes according to your operating system.
Some examples are:
1. On Ubuntu the `docker.service` and `docker.secret` files are located in
`/lib/systemd/system` folder by default.
```sh
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc:ro \
-v /lib/systemd/system:/lib/systemd/system:ro \
-v /usr/bin/containerd:/usr/bin/containerd:ro \
-v /usr/bin/runc:/usr/bin/runc:ro \
-v /usr/lib/systemd:/usr/lib/systemd:ro \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security
```
2. The /etc/hostname file is missing on macOS, so it will need to be created first. Also, `Docker Desktop` on macOS doesn't have `/usr/lib/systemd` or the above Docker
binaries.
```sh
sudo touch /etc/hostname
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security
```
### Note
Docker bench requires Docker 1.13.0 or later in order to run.
Note that when distributions don't contain `auditctl`, the audit tests will check `/etc/audit/audit.rules` to see if a rule is present instead.
### Docker Bench for Security options
```sh
-b optional Do not print colors
-h optional Print this help message
-l FILE optional Log output in FILE, inside container if run using docker
-u USERS optional Comma delimited list of trusted docker user(s)
-c CHECK optional Comma delimited list of specific check(s) id
-e CHECK optional Comma delimited list of specific check(s) id to exclude
-i INCLUDE optional Comma delimited list of patterns within a container or image name to check
-x EXCLUDE optional Comma delimited list of patterns within a container or image name to exclude from check
-t LABEL optional Comma delimited list of labels within a container or image to check
-n LIMIT optional In JSON output, when reporting lists of items (containers, images, etc.), limit the number of reported items to LIMIT. Default 0 (no limit).
-p PRINT optional Disable the printing of remediation measures. Default: print remediation measures.
```
By default the Docker Bench for Security script will run all available CIS tests and produce
logs in the log folder from current directory, named `docker-bench-security.log.json` and
`docker-bench-security.log`.
If the docker container is used then the log files will be created inside the container in location `/usr/local/bin/log/`. If you wish to access them from the host after the container has been run you will need to mount a volume for storing them in.
The CIS based checks are named `check_<section>_<number>`, e.g. `check_2_6` and community contributed checks are named `check_c_<number>`.
`sh docker-bench-security.sh -c check_2_2` will only run check `2.2 Ensure the logging level is set to 'info'`.
`sh docker-bench-security.sh -e check_2_2` will run all available checks except `2.2 Ensure the logging level is set to 'info'`.
`sh docker-bench-security.sh -e docker_enterprise_configuration` will run all available checks except the docker_enterprise_configuration group
`sh docker-bench-security.sh -e docker_enterprise_configuration,check_2_2` will run all available checks except the docker_enterprise_configuration group and `2.2 Ensure the logging level is set to 'info'`
`sh docker-bench-security.sh -c container_images,container_runtime` will run just the container_images and container_runtime checks
`sh docker-bench-security.sh -c container_images -e check_4_5` will run just the container_images checks except `4.5 Ensure Content trust for Docker is Enabled`
Note that when submitting checks, provide information why it is a reasonable test to add and please include some kind of official documentation verifying that information.

19
Vagrantfile vendored Normal file
View File

@ -0,0 +1,19 @@
Vagrant.configure("2") do |config|
config.vbguest.installer_options = { allow_kernel_upgrade: true }
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
v.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
end
config.vm.define "jammy" do |jammy|
jammy.ssh.extra_args = ["-o","ConnectTimeout=600"]
jammy.ssh.insert_key = true
jammy.vm.boot_timeout = 600
jammy.vm.box = "ubuntu/jammy64"
jammy.vm.hostname = "jammy"
jammy.vm.provision "shell",
inline: "apt-get update && curl -sSL get.docker.com | sh && addgroup vagrant docker"
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

View File

@ -1,22 +0,0 @@
FROM alpine:3.5
LABEL org.label-schema.name="docker-bench-security" \
org.label-schema.url="https://dockerbench.com" \
org.label-schema.vcs-url="https://github.com/docker/docker-bench-security.git"
RUN \
apk upgrade --no-cache && \
apk add --no-cache \
docker \
dumb-init && \
rm -rf /usr/bin/docker-* /usr/bin/dockerd && \
mkdir /usr/local/bin/tests
COPY ./*.sh /usr/local/bin/
COPY ./tests/*.sh /usr/local/bin/tests/
WORKDIR /usr/local/bin
ENTRYPOINT [ "/usr/bin/dumb-init", "docker-bench-security.sh" ]

View File

@ -1,15 +0,0 @@
# REPOSITORY https://github.com/fatherlinux/docker-bench-security
FROM centos
MAINTAINER smccarty@redhat.com
RUN yum install -y docker net-tools audit procps-ng; yum clean all
RUN mkdir /docker-bench-security
COPY . /docker-bench-security
WORKDIR /docker-bench-security
ENTRYPOINT ["/bin/sh", "docker-bench-security.sh"]

View File

@ -1,24 +0,0 @@
FROM debian:sid
LABEL org.label-schema.name="docker-bench-security" \
org.label-schema.url="https://github.com/konstruktoid/docker-bench-security" \
org.label-schema.vcs-url="https://github.com/konstruktoid/docker-bench-security.git"
RUN \
apt-get update && \
apt-get -y upgrade && \
apt-get -y install auditd ca-certificates docker.io \
gawk net-tools procps --no-install-recommends && \
apt-get -y clean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/* \
/usr/share/doc /usr/share/doc-base \
/usr/share/man /usr/share/locale /usr/share/zoneinfo
RUN mkdir /docker-bench-security
COPY . /docker-bench-security
WORKDIR /docker-bench-security
ENTRYPOINT ["/bin/sh", "docker-bench-security.sh"]

View File

@ -1,15 +0,0 @@
# REPOSITORY https://github.com/docker/docker-bench-security
FROM opensuse
MAINTAINER security@suse.com
RUN zypper -n in docker net-tools audit
RUN mkdir /docker-bench-security
COPY . /docker-bench-security
WORKDIR /docker-bench-security
ENTRYPOINT ["/bin/sh", "docker-bench-security.sh"]

View File

@ -1,18 +0,0 @@
# REPOSITORY https://github.com/fatherlinux/docker-bench-security
FROM rhel7
MAINTAINER smccarty@redhat.com
RUN yum install -y yum-utils; yum clean all
RUN yum-config-manager --disable "*" &>/dev/null
RUN yum-config-manager --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms
RUN yum install -y docker net-tools audit procps-ng; yum clean all
RUN mkdir /docker-bench-security
COPY . /docker-bench-security
WORKDIR /docker-bench-security
ENTRYPOINT ["/bin/sh", "docker-bench-security.sh"]

View File

@ -1,21 +0,0 @@
# Distribution specific Dockerfiles
## Requirements
### Dockerfile name
The format should be `Dockerfile.{distribution name}`.
### Keep your images up-to-date
Use the distribution package manager to keep your image up-to-date.
### Labels
Use the following labels in your Dockerfile:
```
LABEL org.label-schema.name="docker-bench-security" \
org.label-schema.url="<YOUR GIT REPOSITORY HTTPS ADDRESS>" \
org.label-schema.vcs-url="<YOUR REPOSITORY HTTPS GIT ADDRESS"
```

View File

@ -1,28 +1,32 @@
#!/bin/sh
# ------------------------------------------------------------------------------
# Docker Bench for Security v1.3.2
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Docker Bench for Security
#
# Docker, Inc. (c) 2015-
# Docker, Inc. (c) 2015-2022
#
# Checks for dozens of common best-practices around deploying Docker containers in production.
# Inspired by the CIS Docker 1.13 Benchmark.
# ------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
version='1.6.0'
LIBEXEC="." # Distributions can change this to /usr/libexec or similar.
# Load dependencies
. ./output_lib.sh
. ./helper_lib.sh
. $LIBEXEC/functions/functions_lib.sh
. $LIBEXEC/functions/helper_lib.sh
# Setup the paths
this_path=$(abspath "$0") ## Path of this file including filenamel
myname=$(basename "${this_path}") ## file name of this script.
this_path=$(abspath "$0") ## Path of this file including filename
myname=$(basename "${this_path%.*}") ## file name of this script.
export PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin/
readonly version
readonly this_path
readonly myname
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin/"
# Check for required program(s)
req_progs='awk docker grep netstat stat'
for p in $req_progs; do
command -v "$p" >/dev/null 2>&1 || { printf "%s command not found.\n" "$p"; exit 1; }
done
req_programs 'awk docker grep sed stat tail tee tr wc xargs'
# Ensure we can connect to docker daemon
if ! docker ps -q >/dev/null 2>&1; then
@ -32,66 +36,187 @@ fi
usage () {
cat <<EOF
usage: ${myname} [options]
Docker Bench for Security - Docker, Inc. (c) 2015-$(date +"%Y")
Checks for dozens of common best-practices around deploying Docker containers in production.
Based on the CIS Docker Benchmark 1.6.0.
Usage: ${myname}.sh [OPTIONS]
Example:
- Only run check "2.2 - Ensure the logging level is set to 'info'":
sh docker-bench-security.sh -c check_2_2
- Run all available checks except the host_configuration group and "2.8 - Enable user namespace support":
sh docker-bench-security.sh -e host_configuration,check_2_8
- Run just the container_images checks except "4.5 - Ensure Content trust for Docker is Enabled":
sh docker-bench-security.sh -c container_images -e check_4_5
Options:
-b optional Do not print colors
-h optional Print this help message
-l PATH optional Log output in PATH
-l FILE optional Log output in FILE, inside container if run using docker
-u USERS optional Comma delimited list of trusted docker user(s)
-c CHECK optional Comma delimited list of specific check(s) id
-e CHECK optional Comma delimited list of specific check(s) id to exclude
-i INCLUDE optional Comma delimited list of patterns within a container or image name to check
-x EXCLUDE optional Comma delimited list of patterns within a container or image name to exclude from check
-t LABEL optional Comma delimited list of labels within a container or image to check
-n LIMIT optional In JSON output, when reporting lists of items (containers, images, etc.), limit the number of reported items to LIMIT. Default 0 (no limit).
-p PRINT optional Print remediation measures. Default: Don't print remediation measures.
Complete list of checks: <https://github.com/docker/docker-bench-security/blob/master/tests/>
Full documentation: <https://github.com/docker/docker-bench-security>
Released under the Apache-2.0 License.
EOF
}
# Default values
if [ ! -d log ]; then
mkdir log
fi
logger="log/${myname}.log"
limit=0
printremediation="0"
globalRemediation=""
# Get the flags
# If you add an option here, please
# remember to update usage() above.
while getopts hl: args
while getopts bhl:u:c:e:i:x:t:n:p args
do
case $args in
b) nocolor="nocolor";;
h) usage; exit 0 ;;
l) logger="$OPTARG" ;;
u) dockertrustusers="$OPTARG" ;;
c) check="$OPTARG" ;;
e) checkexclude="$OPTARG" ;;
i) include="$OPTARG" ;;
x) exclude="$OPTARG" ;;
t) labels="$OPTARG" ;;
n) limit="$OPTARG" ;;
p) printremediation="1" ;;
*) usage; exit 1 ;;
esac
done
if [ -z "$logger" ]; then
logger="${myname}.log"
fi
# Load output formating
. $LIBEXEC/functions/output_lib.sh
yell "# ------------------------------------------------------------------------------
# Docker Bench for Security v1.3.2
#
# Docker, Inc. (c) 2015-
#
# Checks for dozens of common best-practices around deploying Docker containers in production.
# Inspired by the CIS Docker 1.13 Benchmark.
# ------------------------------------------------------------------------------"
yell_info
# Warn if not root
ID=$(id -u)
if [ "x$ID" != "x0" ]; then
warn "Some tests might require root to run"
sleep 3
if [ "$(id -u)" != "0" ]; then
warn "$(yell 'Some tests might require root to run')\n"
sleep 3
fi
logit "Initializing $(date)\n"
# Total Score
# Warn Scored -1, Pass Scored +1, Not Score -0
totalChecks=0
currentScore=0
logit "Initializing $(date +%Y-%m-%dT%H:%M:%S%:z)\n"
beginjson "$version" "$(date +%s)"
# Load all the tests from tests/ and run them
main () {
# List all running containers
containers=$(docker ps | sed '1d' | awk '{print $NF}')
logit "\n${bldylw}Section A - Check results${txtrst}"
# Get configuration location
get_docker_configuration_file
# If there is a container with label docker_bench_security, memorize it:
benchcont="nil"
for c in $containers; do
for c in $(docker ps | sed '1d' | awk '{print $NF}'); do
if docker inspect --format '{{ .Config.Labels }}' "$c" | \
grep -e 'docker.bench.security' >/dev/null 2>&1; then
benchcont="$c"
fi
done
# List all running containers except docker-bench (use names to improve readability in logs)
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
for test in tests/*.sh
do
. ./"$test"
# Get the image id of the docker_bench_security_image, memorize it:
benchimagecont="nil"
for c in $(docker images | sed '1d' | awk '{print $3}'); do
if docker inspect --format '{{ .Config.Labels }}' "$c" | \
grep -e 'docker.bench.security' >/dev/null 2>&1; then
benchimagecont="$c"
fi
done
# Format LABELS
for label in $(echo "$labels" | sed 's/,/ /g'); do
LABELS="$LABELS --filter label=$label"
done
if [ -n "$include" ]; then
pattern=$(echo "$include" | sed 's/,/|/g')
containers=$(docker ps $LABELS| sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -E "$pattern")
images=$(docker images $LABELS| sed '1d' | grep -E "$pattern" | awk '{print $3}' | grep -v "$benchimagecont")
elif [ -n "$exclude" ]; then
pattern=$(echo "$exclude" | sed 's/,/|/g')
containers=$(docker ps $LABELS| sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -Ev "$pattern")
images=$(docker images $LABELS| sed '1d' | grep -Ev "$pattern" | awk '{print $3}' | grep -v "$benchimagecont")
else
containers=$(docker ps $LABELS| sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
images=$(docker images -q $LABELS| grep -v "$benchcont")
fi
for test in $LIBEXEC/tests/*.sh; do
. "$test"
done
if [ -z "$check" ] && [ ! "$checkexclude" ]; then
# No options just run
cis
elif [ -z "$check" ]; then
# No check defined but excludes defined set to calls in cis() function
check=$(sed -ne "/cis() {/,/}/{/{/d; /}/d; p;}" functions/functions_lib.sh)
fi
for c in $(echo "$check" | sed "s/,/ /g"); do
if ! command -v "$c" 2>/dev/null 1>&2; then
echo "Check \"$c\" doesn't seem to exist."
continue
fi
if [ -z "$checkexclude" ]; then
# No excludes just run the checks specified
"$c"
else
# Exludes specified and check exists
checkexcluded="$(echo ",$checkexclude" | sed -e 's/^/\^/g' -e 's/,/\$|/g' -e 's/$/\$/g')"
if echo "$c" | grep -E "$checkexcluded" 2>/dev/null 1>&2; then
# Excluded
continue
elif echo "$c" | grep -vE 'check_[0-9]|check_[a-z]' 2>/dev/null 1>&2; then
# Function not a check, fill loop_checks with all check from function
loop_checks="$(sed -ne "/$c() {/,/}/{/{/d; /}/d; p;}" functions/functions_lib.sh)"
else
# Just one check
loop_checks="$c"
fi
for lc in $loop_checks; do
if echo "$lc" | grep -vE "$checkexcluded" 2>/dev/null 1>&2; then
# Not excluded
"$lc"
fi
done
fi
done
if [ -n "${globalRemediation}" ] && [ "$printremediation" = "1" ]; then
logit "\n\n${bldylw}Section B - Remediation measures${txtrst}"
logit "${globalRemediation}"
fi
logit "\n\n${bldylw}Section C - Score${txtrst}\n"
info "Checks: $totalChecks"
info "Score: $currentScore\n"
endjson "$totalChecks" "$currentScore" "$(date +%s)"
}
main "$@"

View File

@ -1,21 +1,21 @@
docker-bench-security:
# use image if you have a dedicated build step:
# docker build --rm -t docker-bench-security .
# image: docker-bench-security
services:
docker-bench-security:
# use image if you have a dedicated build step:
# docker build --rm -t docker-bench-security .
# image: docker-bench-security
# use build path to Dockerfile if docker-compose should build the image
build: .
# use build path to Dockerfile if docker-compose should build the image
build: .
cap_add:
- audit_control
labels:
- docker_bench_security
net: host
pid: host
stdin_open: true
tty: true
volumes:
- /var/lib:/var/lib
- /var/run/docker.sock:/var/run/docker.sock
- /usr/lib/systemd:/usr/lib/systemd
- /etc:/etc
cap_add:
- audit_control
labels:
- docker_bench_security
pid: host
stdin_open: true
tty: true
volumes:
- /var/lib:/var/lib:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /usr/lib/systemd:/usr/lib/systemd:ro
- /etc:/etc:ro

571
functions/functions_lib.sh Normal file
View File

@ -0,0 +1,571 @@
#!/bin/sh
host_configuration() {
check_1
check_1_1
check_1_1_1
check_1_1_2
check_1_1_3
check_1_1_4
check_1_1_5
check_1_1_6
check_1_1_7
check_1_1_8
check_1_1_9
check_1_1_10
check_1_1_11
check_1_1_12
check_1_1_13
check_1_1_14
check_1_1_15
check_1_1_16
check_1_1_17
check_1_1_18
check_1_2
check_1_2_1
check_1_2_2
check_1_end
}
host_configuration_level1() {
check_1
check_1_end
}
linux_hosts_specific_configuration() {
check_1_1
check_1_1_1
check_1_1_2
check_1_1_3
check_1_1_4
check_1_1_5
check_1_1_6
check_1_1_7
check_1_1_8
check_1_1_9
check_1_1_10
check_1_1_11
check_1_1_12
check_1_1_13
check_1_1_14
check_1_1_15
check_1_1_16
check_1_1_17
check_1_1_18
}
host_general_configuration() {
check_1
check_1_2
check_1_2_1
check_1_2_2
check_1_end
}
docker_daemon_configuration() {
check_2
check_2_1
check_2_2
check_2_3
check_2_4
check_2_5
check_2_6
check_2_7
check_2_8
check_2_9
check_2_10
check_2_11
check_2_12
check_2_13
check_2_14
check_2_15
check_2_16
check_2_17
check_2_18
check_2_end
}
docker_daemon_configuration_level1() {
check_2
check_2_end
}
docker_daemon_files() {
check_3
check_3_1
check_3_2
check_3_3
check_3_4
check_3_5
check_3_6
check_3_7
check_3_8
check_3_9
check_3_10
check_3_11
check_3_12
check_3_13
check_3_14
check_3_15
check_3_16
check_3_17
check_3_18
check_3_19
check_3_20
check_3_21
check_3_22
check_3_23
check_3_24
check_3_end
}
docker_daemon_files_level1() {
check_3
check_3_end
}
container_images() {
check_4
check_4_1
check_4_2
check_4_3
check_4_4
check_4_5
check_4_6
check_4_7
check_4_8
check_4_9
check_4_10
check_4_11
check_4_12
check_4_end
}
container_images_level1() {
check_4
check_4_end
}
container_runtime() {
check_5
check_running_containers
check_5_1
check_5_2
check_5_3
check_5_4
check_5_5
check_5_6
check_5_7
check_5_8
check_5_9
check_5_10
check_5_11
check_5_12
check_5_13
check_5_14
check_5_15
check_5_16
check_5_17
check_5_18
check_5_19
check_5_20
check_5_21
check_5_22
check_5_23
check_5_24
check_5_25
check_5_26
check_5_27
check_5_28
check_5_29
check_5_30
check_5_31
check_5_32
check_5_end
}
container_runtime_level1() {
check_5
check_5_end
}
docker_security_operations() {
check_6
check_6_1
check_6_2
check_6_end
}
docker_security_operations_level1() {
check_6
check_6_1
check_6_2
check_6_end
}
docker_swarm_configuration() {
check_7
check_7_1
check_7_2
check_7_3
check_7_4
check_7_5
check_7_6
check_7_7
check_7_8
check_7_9
check_7_end
}
docker_swarm_configuration_level1() {
check_7
check_7_end
}
docker_enterprise_configuration() {
check_8
check_product_license
check_8_1
check_8_1_1
check_8_1_2
check_8_1_3
check_8_1_4
check_8_1_5
check_8_1_6
check_8_1_7
check_8_2
check_8_2_1
check_8_end
}
docker_enterprise_configuration_level1() {
check_8
check_product_license
check_8_1
check_8_1_1
check_8_1_2
check_8_1_3
check_8_1_4
check_8_1_5
check_8_1_6
check_8_1_7
check_8_2
check_8_2_1
check_8_end
}
universal_control_plane_configuration() {
check_8
check_8_1
check_8_1_1
check_8_1_2
check_8_1_3
check_8_1_4
check_8_1_5
check_8_1_6
check_8_1_7
check_8_end
}
docker_trusted_registry_configuration() {
check_8
check_8_2
check_8_2_1
check_8_end
}
community_checks() {
check_c
check_c_1
check_c_1_1
check_c_2
check_c_5_3_1
check_c_5_3_2
check_c_5_3_3
check_c_5_3_4
check_c_end
}
# CIS
cis() {
host_configuration
docker_daemon_configuration
docker_daemon_files
container_images
container_runtime
docker_security_operations
docker_swarm_configuration
}
cis_level1() {
host_configuration_level1
docker_daemon_configuration_level1
docker_daemon_files_level1
container_images_level1
container_runtime_level1
docker_security_operations_level1
docker_swarm_configuration_level1
}
cis_controls_v8_ig1() {
check_1_1_2
check_1_1_3
check_2_1
check_2_13
check_2_14
check_3_1
check_3_2
check_3_3
check_3_4
check_3_5
check_3_6
check_3_7
check_3_8
check_3_9
check_3_10
check_3_11
check_3_12
check_3_13
check_3_14
check_3_15
check_3_16
check_3_17
check_3_18
check_3_19
check_3_20
check_3_21
check_3_22
check_3_23
check_3_24
check_4_8
check_4_11
check_5_5
check_5_14
check_5_18
check_5_22
check_5_23
check_5_24
check_5_25
check_5_26
check_5_32
check_7_2
check_7_6
check_7_7
check_7_8
}
cis_controls_v8_ig2() {
check_1_1_1
check_1_1_2
check_1_1_3
check_1_1_4
check_1_1_5
check_1_1_6
check_1_1_7
check_1_1_8
check_1_1_9
check_1_1_10
check_1_1_11
check_1_1_12
check_1_1_13
check_1_1_14
check_1_1_15
check_1_1_16
check_1_1_17
check_1_1_18
check_1_2_1
check_1_2_2
check_2_1
check_2_2
check_2_3
check_2_4
check_2_5
check_2_7
check_2_8
check_2_11
check_2_13
check_2_14
check_2_15
check_2_16
check_2_18
check_3_1
check_3_2
check_3_3
check_3_4
check_3_5
check_3_6
check_3_7
check_3_8
check_3_9
check_3_10
check_3_11
check_3_12
check_3_13
check_3_14
check_3_15
check_3_16
check_3_17
check_3_18
check_3_19
check_3_20
check_3_21
check_3_22
check_3_23
check_3_24
check_4_2
check_4_3
check_4_4
check_4_7
check_4_8
check_4_9
check_4_11
check_5_1
check_5_2
check_5_3
check_5_4
check_5_5
check_5_7
check_5_10
check_5_11
check_5_12
check_5_14
check_5_16
check_5_17
check_5_18
check_5_19
check_5_21
check_5_22
check_5_23
check_5_24
check_5_25
check_5_26
check_5_27
check_5_30
check_5_31
check_5_32
check_6_1
check_6_2
check_7_2
check_7_3
check_7_5
check_7_6
check_7_7
check_7_8
check_7_9
}
cis_controls_v8_ig3() {
check_1_1_1
check_1_1_2
check_1_1_3
check_1_1_4
check_1_1_5
check_1_1_6
check_1_1_7
check_1_1_8
check_1_1_9
check_1_1_10
check_1_1_11
check_1_1_12
check_1_1_13
check_1_1_14
check_1_1_15
check_1_1_16
check_1_1_17
check_1_1_18
check_1_2_1
check_1_2_2
check_2_1
check_2_2
check_2_3
check_2_4
check_2_5
check_2_7
check_2_8
check_2_11
check_2_13
check_2_14
check_2_15
check_2_16
check_2_18
check_3_1
check_3_2
check_3_3
check_3_4
check_3_5
check_3_6
check_3_7
check_3_8
check_3_9
check_3_10
check_3_11
check_3_12
check_3_13
check_3_14
check_3_15
check_3_16
check_3_17
check_3_18
check_3_19
check_3_20
check_3_21
check_3_22
check_3_23
check_3_24
check_4_2
check_4_3
check_4_4
check_4_6
check_4_7
check_4_8
check_4_9
check_4_11
check_4_12
check_5_1
check_5_2
check_5_3
check_5_4
check_5_5
check_5_7
check_5_8
check_5_9
check_5_10
check_5_11
check_5_12
check_5_14
check_5_16
check_5_17
check_5_18
check_5_19
check_5_21
check_5_22
check_5_23
check_5_24
check_5_25
check_5_26
check_5_27
check_5_30
check_5_31
check_5_32
check_6_1
check_6_2
check_7_2
check_7_3
check_7_5
check_7_6
check_7_7
check_7_8
check_7_9
}
# Community contributed
community() {
community_checks
}
# All
all() {
cis
docker_enterprise_configuration
community
}

163
functions/helper_lib.sh Normal file
View File

@ -0,0 +1,163 @@
#!/bin/bash
# Returns the absolute path of a given string
abspath () { case "$1" in /*)printf "%s\n" "$1";; *)printf "%s\n" "$PWD/$1";; esac; }
# Audit rules default path
auditrules="/etc/audit/audit.rules"
# Check for required program(s)
req_programs() {
for p in $1; do
command -v "$p" >/dev/null 2>&1 || { printf "Required program not found: %s\n" "$p"; exit 1; }
done
if command -v jq >/dev/null 2>&1; then
HAVE_JQ=true
else
HAVE_JQ=false
fi
if command -v ss >/dev/null 2>&1; then
netbin=ss
return
fi
if command -v netstat >/dev/null 2>&1; then
netbin=netstat
return
fi
echo "ss or netstat command not found."
exit 1
}
# Compares versions of software of the format X.Y.Z
do_version_check() {
[ "$1" = "$2" ] && return 10
ver1front=$(printf "%s" "$1" | cut -d "." -f -1)
ver1back=$(printf "%s" "$1" | cut -d "." -f 2-)
ver2front=$(printf "%s" "$2" | cut -d "." -f -1)
ver2back=$(printf "%s" "$2" | cut -d "." -f 2-)
if [ "$ver1front" != "$1" ] || [ "$ver2front" != "$2" ]; then
[ "$ver1front" -gt "$ver2front" ] && return 11
[ "$ver1front" -lt "$ver2front" ] && return 9
[ "$ver1front" = "$1" ] || [ -z "$ver1back" ] && ver1back=0
[ "$ver2front" = "$2" ] || [ -z "$ver2back" ] && ver2back=0
do_version_check "$ver1back" "$ver2back"
return $?
fi
[ "$1" -gt "$2" ] && return 11 || return 9
}
# Extracts commandline args from the newest running processes named like the first parameter
get_command_line_args() {
PROC="$1"
for PID in $(pgrep -f -n "$PROC"); do
tr "\0" " " < /proc/"$PID"/cmdline
done
}
# Extract the cumulative command line arguments for the docker daemon
#
# If specified multiple times, all matches are returned.
# Accounts for long and short variants, call with short option.
# Does not account for option defaults or implicit options.
get_docker_cumulative_command_line_args() {
OPTION="$1"
line_arg="dockerd"
if ! get_command_line_args "docker daemon" >/dev/null 2>&1 ; then
line_arg="docker daemon"
fi
get_command_line_args "$line_arg" |
# normalize known long options to their short versions
sed \
-e 's/\-\-debug/-D/g' \
-e 's/\-\-host/-H/g' \
-e 's/\-\-log-level/-l/g' \
-e 's/\-\-version/-v/g' \
|
# normalize parameters separated by space(s) to -O=VALUE
sed \
-e 's/\-\([DHlv]\)[= ]\([^- ][^ ]\)/-\1=\2/g' \
|
# get the last interesting option
tr ' ' "\n" |
grep "^${OPTION}" |
# normalize quoting of values
sed \
-e 's/"//g' \
-e "s/'//g"
}
# Extract the effective command line arguments for the docker daemon
#
# Accounts for multiple specifications, takes the last option.
# Accounts for long and short variants, call with short option
# Does not account for option default or implicit options.
get_docker_effective_command_line_args() {
OPTION="$1"
get_docker_cumulative_command_line_args "$OPTION" | tail -n1
}
get_docker_configuration_file() {
FILE="$(get_docker_effective_command_line_args '--config-file' | \
sed 's/.*=//g')"
if [ -f "$FILE" ]; then
CONFIG_FILE="$FILE"
return
fi
if [ -f '/etc/docker/daemon.json' ]; then
CONFIG_FILE='/etc/docker/daemon.json'
return
fi
CONFIG_FILE='/dev/null'
}
get_docker_configuration_file_args() {
OPTION="$1"
get_docker_configuration_file
if "$HAVE_JQ"; then
jq --monochrome-output --raw-output "if has(\"${OPTION}\") then .[\"${OPTION}\"] else \"\" end" "$CONFIG_FILE"
else
cat "$CONFIG_FILE" | tr , '\n' | grep "$OPTION" | sed 's/.*://g' | tr -d '" ',
fi
}
get_service_file() {
SERVICE="$1"
if [ -f "/etc/systemd/system/$SERVICE" ]; then
echo "/etc/systemd/system/$SERVICE"
return
fi
if [ -f "/lib/systemd/system/$SERVICE" ]; then
echo "/lib/systemd/system/$SERVICE"
return
fi
if find /run -name "$SERVICE" 2> /dev/null 1>&2; then
find /run -name "$SERVICE" | head -n1
return
fi
if [ "$(systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//')" != "" ]; then
systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//'
return
fi
echo "/usr/lib/systemd/system/$SERVICE"
}
yell_info() {
yell "# --------------------------------------------------------------------------------------------
# Docker Bench for Security v$version
#
# Docker, Inc. (c) 2015-$(date +"%Y")
#
# Checks for dozens of common best-practices around deploying Docker containers in production.
# Based on the CIS Docker Benchmark 1.6.0.
# --------------------------------------------------------------------------------------------"
}

190
functions/output_lib.sh Normal file
View File

@ -0,0 +1,190 @@
#!/bin/bash
bldred='\033[1;31m' # Bold Red
bldgrn='\033[1;32m' # Bold Green
bldblu='\033[1;34m' # Bold Blue
bldylw='\033[1;33m' # Bold Yellow
txtrst='\033[0m'
if [ -n "$nocolor" ] && [ "$nocolor" = "nocolor" ]; then
bldred=''
bldgrn=''
bldblu=''
bldylw=''
txtrst=''
fi
logit () {
printf "%b\n" "$1" | tee -a "$logger"
}
info () {
local infoCountCheck
local OPTIND c
while getopts c args
do
case $args in
c) infoCountCheck="true" ;;
*) exit 1 ;;
esac
done
if [ "$infoCountCheck" = "true" ]; then
printf "%b\n" "${bldblu}[INFO]${txtrst} $2" | tee -a "$logger"
totalChecks=$((totalChecks + 1))
return
fi
printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger"
}
pass () {
local passScored
local passCountCheck
local OPTIND s c
while getopts sc args
do
case $args in
s) passScored="true" ;;
c) passCountCheck="true" ;;
*) exit 1 ;;
esac
done
if [ "$passScored" = "true" ] || [ "$passCountCheck" = "true" ]; then
printf "%b\n" "${bldgrn}[PASS]${txtrst} $2" | tee -a "$logger"
totalChecks=$((totalChecks + 1))
fi
if [ "$passScored" = "true" ]; then
currentScore=$((currentScore + 1))
fi
if [ "$passScored" != "true" ] && [ "$passCountCheck" != "true" ]; then
printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger"
fi
}
warn () {
local warnScored
local OPTIND s
while getopts s args
do
case $args in
s) warnScored="true" ;;
*) exit 1 ;;
esac
done
if [ "$warnScored" = "true" ]; then
printf "%b\n" "${bldred}[WARN]${txtrst} $2" | tee -a "$logger"
totalChecks=$((totalChecks + 1))
currentScore=$((currentScore - 1))
return
fi
printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger"
}
note () {
local noteCountCheck
local OPTIND c
while getopts c args
do
case $args in
c) noteCountCheck="true" ;;
*) exit 1 ;;
esac
done
if [ "$noteCountCheck" = "true" ]; then
printf "%b\n" "${bldylw}[NOTE]${txtrst} $2" | tee -a "$logger"
totalChecks=$((totalChecks + 1))
return
fi
printf "%b\n" "${bldylw}[NOTE]${txtrst} $1" | tee -a "$logger"
}
yell () {
printf "%b\n" "${bldylw}$1${txtrst}\n"
}
beginjson () {
printf "{\n \"dockerbenchsecurity\": \"%s\",\n \"start\": %s,\n \"tests\": [" "$1" "$2" | tee "$logger.json" 2>/dev/null 1>&2
}
endjson (){
printf "\n ],\n \"checks\": %s,\n \"score\": %s,\n \"end\": %s\n}" "$1" "$2" "$3" | tee -a "$logger.json" 2>/dev/null 1>&2
}
logjson (){
printf "\n \"%s\": \"%s\"," "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2
}
SSEP=
SEP=
startsectionjson() {
printf "%s\n {\n \"id\": \"%s\",\n \"desc\": \"%s\",\n \"results\": [" "$SSEP" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2
SEP=
SSEP=","
}
endsectionjson() {
printf "\n ]\n }" | tee -a "$logger.json" 2>/dev/null 1>&2
}
starttestjson() {
printf "%s\n {\n \"id\": \"%s\",\n \"desc\": \"%s\",\n " "$SEP" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2
SEP=","
}
log_to_json() {
if [ $# -eq 1 ]; then
printf "\"result\": \"%s\"" "$1" | tee -a "$logger.json" 2>/dev/null 1>&2
return
fi
if [ $# -eq 2 ] && [ $# -ne 1 ]; then
# Result also contains details
printf "\"result\": \"%s\",\n \"details\": \"%s\"" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2
return
fi
# Result also includes details and a list of items. Add that directly to details and to an array property "items"
# Also limit the number of items to $limit, if $limit is non-zero
truncItems=$3
if [ "$limit" != 0 ]; then
truncItems=""
ITEM_COUNT=0
for item in $3; do
truncItems="$truncItems $item"
ITEM_COUNT=$((ITEM_COUNT + 1));
if [ "$ITEM_COUNT" == "$limit" ]; then
truncItems="$truncItems (truncated)"
break;
fi
done
fi
itemsJson=$(printf "[\n "; ISEP=""; ITEMCOUNT=0; for item in $truncItems; do printf "%s\"%s\"" "$ISEP" "$item"; ISEP=","; done; printf "\n ]")
printf "\"result\": \"%s\",\n \"details\": \"%s: %s\",\n \"items\": %s" "$1" "$2" "$truncItems" "$itemsJson" | tee -a "$logger.json" 2>/dev/null 1>&2
}
logcheckresult() {
# Log to JSON
log_to_json "$@"
# Log remediation measure to JSON
if [ -n "$remediation" ] && [ "$1" != "PASS" ] && [ "$printremediation" = "1" ]; then
printf ",\n \"remediation\": \"%s\"" "$remediation" | tee -a "$logger.json" 2>/dev/null 1>&2
if [ -n "$remediationImpact" ]; then
printf ",\n \"remediation-impact\": \"%s\"" "$remediationImpact" | tee -a "$logger.json" 2>/dev/null 1>&2
fi
fi
printf "\n }" | tee -a "$logger.json" 2>/dev/null 1>&2
# Save remediation measure for print log to stdout
if [ -n "$remediation" ] && [ "$1" != "PASS" ]; then
if [ -n "${checkHeader}" ]; then
if [ -n "${addSpaceHeader}" ]; then
globalRemediation="${globalRemediation}\n"
fi
globalRemediation="${globalRemediation}\n${bldblu}[INFO]${txtrst} ${checkHeader}"
checkHeader=""
addSpaceHeader="1"
fi
globalRemediation="${globalRemediation}\n${bldblu}[INFO]${txtrst} ${id} - ${remediation}"
if [ -n "${remediationImpact}" ]; then
globalRemediation="${globalRemediation} Remediation Impact: ${remediationImpact}"
fi
fi
}

View File

@ -1,109 +0,0 @@
#!/bin/sh
# Returns the absolute path of a given string
abspath () { case "$1" in /*)printf "%s\n" "$1";; *)printf "%s\n" "$PWD/$1";; esac; }
# Compares versions of software of the format X.Y.Z
do_version_check() {
[ "$1" = "$2" ] && return 10
ver1front=$(printf "%s" "$1" | cut -d "." -f -1)
ver1back=$(printf "%s" "$1" | cut -d "." -f 2-)
ver2front=$(printf "%s" "$2" | cut -d "." -f -1)
ver2back=$(printf "%s" "$2" | cut -d "." -f 2-)
if [ "$ver1front" != "$1" ] || [ "$ver2front" != "$2" ]; then
[ "$ver1front" -gt "$ver2front" ] && return 11
[ "$ver1front" -lt "$ver2front" ] && return 9
[ "$ver1front" = "$1" ] || [ -z "$ver1back" ] && ver1back=0
[ "$ver2front" = "$2" ] || [ -z "$ver2back" ] && ver2back=0
do_version_check "$ver1back" "$ver2back"
return $?
else
[ "$1" -gt "$2" ] && return 11 || return 9
fi
}
# Extracts commandline args from the newest running processes named like the first parameter
get_command_line_args() {
PROC="$1"
for PID in $(pgrep -f -n "$PROC")
do
tr "\0" " " < /proc/"$PID"/cmdline
done
}
# Extract the cumulative command line arguments for the docker daemon
#
# If specified multiple times, all matches are returned.
# Accounts for long and short variants, call with short option.
# Does not account for option defaults or implicit options.
get_docker_cumulative_command_line_args() {
OPTION="$1"
if ! get_command_line_args "docker daemon" >/dev/null 2>&1 ; then
line_arg="docker daemon"
else
line_arg="dockerd"
fi
get_command_line_args "$line_arg" |
# normalize known long options to their short versions
sed \
-e 's/\-\-debug/-D/g' \
-e 's/\-\-host/-H/g' \
-e 's/\-\-log-level/-l/g' \
-e 's/\-\-version/-v/g' \
|
# normalize parameters separated by space(s) to -O=VALUE
sed \
-e 's/\-\([DHlv]\)[= ]\([^- ][^ ]\)/-\1=\2/g' \
|
# get the last interesting option
tr ' ' "\n" |
grep "^${OPTION}" |
# normalize quoting of values
sed \
-e 's/"//g' \
-e "s/'//g"
}
# Extract the effective command line arguments for the docker daemon
#
# Accounts for multiple specifications, takes the last option.
# Accounts for long and short variants, call with short option
# Does not account for option default or implicit options.
get_docker_effective_command_line_args() {
OPTION="$1"
get_docker_cumulative_command_line_args "$OPTION" | tail -n1
}
get_docker_configuration_file_args() {
OPTION="$1"
FILE="$(get_docker_effective_command_line_args '--config-file' | \
sed 's/.*=//g')"
if [ -f "$FILE" ]; then
CONFIG_FILE="$FILE"
elif [ -f '/etc/docker/daemon.json' ]; then
CONFIG_FILE='/etc/docker/daemon.json'
else
CONFIG_FILE='/dev/null'
fi
grep "$OPTION" "$CONFIG_FILE" | sed 's/.*: //g' | tr -d \",
}
get_systemd_service_file(){
SERVICE="$1"
if [ -f "/etc/systemd/system/$SERVICE" ]; then
echo "/etc/systemd/system/$SERVICE"
elif systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2; then
systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//'
else
echo "/usr/lib/systemd/system/$SERVICE"
fi
}

BIN
img/benchmark_log.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

View File

@ -1,30 +0,0 @@
#!/bin/sh
bldred='\033[1;31m'
bldgrn='\033[1;32m'
bldblu='\033[1;34m'
bldylw='\033[1;33m' # Yellow
txtrst='\033[0m'
logit () {
printf "%b\n" "$1" | tee -a "$logger"
}
info () {
printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger"
}
pass () {
printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger"
}
warn () {
printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger"
}
note () {
printf "%b\n" "${bldylw}[NOTE]${txtrst} $1" | tee -a "$logger"
}
yell () {
printf "%b\n" "${bldylw}$1${txtrst}\n"
}

View File

@ -1,217 +1,662 @@
#!/bin/sh
#!/bin/bash
logit ""
info "1 - Host Configuration"
auditrules="/etc/audit/audit.rules"
check_1() {
logit ""
local id="1"
local desc="Host Configuration"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
# 1.1
check_1_1="1.1 - Create a separate partition for containers"
if grep /var/lib/docker /etc/fstab >/dev/null 2>&1; then
pass "$check_1_1"
else
warn "$check_1_1"
fi
check_1_1() {
local id="1.1"
local desc="Linux Hosts Specific Configuration"
local check="$id - $desc"
info "$check"
}
# 1.2
check_1_2="1.2 - Harden the container host"
note "$check_1_2"
check_1_1_1() {
local id="1.1.1"
local desc="Ensure a separate partition for containers has been created (Automated)"
local remediation="For new installations, you should create a separate partition for the /var/lib/docker mount point. For systems that have already been installed, you should use the Logical Volume Manager (LVM) within Linux to create a new partition."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 1.3
check_1_3="1.3 - Keep Docker up to date"
docker_version=$(docker version | grep -i -A1 '^server' | grep -i 'version:' \
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,')
docker_current_version="17.03.0"
docker_current_date="2017-03-01"
do_version_check "$docker_current_version" "$docker_version"
if [ $? -eq 11 ]; then
info "$check_1_3"
info " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
info " * Your operating system vendor may provide support and security maintenance for Docker"
else
pass "$check_1_3"
info " * Using $docker_version which is current as of $docker_current_date"
info " * Check with your operating system vendor for support and security maintenance for Docker"
fi
# 1.4
check_1_4="1.4 - Only allow trusted users to control Docker daemon"
docker_users=$(getent group docker)
info "$check_1_4"
for u in $docker_users; do
info " * $u"
done
# 1.5
check_1_5="1.5 - Audit docker daemon - /usr/bin/docker"
file="/usr/bin/docker "
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass "$check_1_5"
else
warn "$check_1_5"
docker_root_dir=$(docker info -f '{{ .DockerRootDir }}')
if docker info | grep -q userns ; then
docker_root_dir=$(readlink -f "$docker_root_dir/..")
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_5"
else
warn "$check_1_5"
fi
# 1.6
check_1_6="1.6 - Audit Docker files and directories - /var/lib/docker"
directory="/var/lib/docker"
if [ -d "$directory" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $directory >/dev/null 2>&1; then
pass "$check_1_6"
else
warn "$check_1_6"
fi
elif grep "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_6"
else
warn "$check_1_6"
if mountpoint -q -- "$docker_root_dir" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
else
info "$check_1_6"
info " * Directory not found"
fi
warn -s "$check"
logcheckresult "WARN"
}
# 1.7
check_1_7="1.7 - Audit Docker files and directories - /etc/docker"
directory="/etc/docker"
if [ -d "$directory" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $directory >/dev/null 2>&1; then
pass "$check_1_7"
else
warn "$check_1_7"
fi
elif grep "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_7"
else
warn "$check_1_7"
check_1_1_2() {
local id="1.1.2"
local desc="Ensure only trusted users are allowed to control Docker daemon (Automated)"
local remediation="You should remove any untrusted users from the docker group using command sudo gpasswd -d <your-user> docker or add trusted users to the docker group using command sudo usermod -aG docker <your-user>. You should not create a mapping of sensitive directories from the host to container volumes."
local remediationImpact="Only trust user are allow to build and execute containers as normal user."
local check="$id - $desc"
starttestjson "$id" "$desc"
docker_users=$(grep 'docker' /etc/group)
if command -v getent >/dev/null 2>&1; then
docker_users=$(getent group docker)
fi
else
info "$check_1_7"
info " * Directory not found"
fi
docker_users=$(printf "%s" "$docker_users" | awk -F: '{print $4}')
# 1.8
check_1_8="1.8 - Audit Docker files and directories - docker.service"
file="$(get_systemd_service_file docker.service)"
if [ -f "$file" ]; then
local doubtfulusers=""
if [ -n "$dockertrustusers" ]; then
for u in $(printf "%s" "$docker_users" | sed "s/,/ /g"); do
if ! printf "%s" "$dockertrustusers" | grep -q "$u" ; then
doubtfulusers="$u"
if [ -n "${doubtfulusers}" ]; then
doubtfulusers="${doubtfulusers},$u"
fi
fi
done
else
info -c "$check"
info " * Users: $docker_users"
logcheckresult "INFO" "doubtfulusers" "$docker_users"
fi
if [ -n "${doubtfulusers}" ]; then
warn -s "$check"
warn " * Doubtful users: $doubtfulusers"
logcheckresult "WARN" "doubtfulusers" "$doubtfulusers"
fi
if [ -z "${doubtfulusers}" ] && [ -n "${dockertrustusers}" ]; then
pass -s "$check"
logcheckresult "PASS"
fi
}
check_1_1_3() {
local id="1.1.3"
local desc="Ensure auditing is configured for the Docker daemon (Automated)"
local remediation="Install auditd. Add -w /usr/bin/dockerd -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/dockerd"
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass "$check_1_8"
else
warn "$check_1_8"
pass -s "$check"
logcheckresult "PASS"
return
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_8"
else
warn "$check_1_8"
warn -s "$check"
logcheckresult "WARN"
return
fi
else
info "$check_1_8"
info " * File not found"
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
# 1.9
check_1_9="1.9 - Audit Docker files and directories - docker.socket"
file="$(get_systemd_service_file docker.socket)"
if [ -e "$file" ]; then
check_1_1_4() {
local id="1.1.4"
local desc="Ensure auditing is configured for Docker files and directories -/run/containerd (Automated)"
local remediation="Install auditd. Add -a exit,always -F path=/run/containerd -F perm=war -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/run/containerd"
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass "$check_1_9"
else
warn "$check_1_9"
pass -s "$check"
logcheckresult "PASS"
return
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_9"
else
warn "$check_1_9"
warn -s "$check"
logcheckresult "WARN"
return
fi
else
info "$check_1_9"
info " * File not found"
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
# 1.10
check_1_10="1.10 - Audit Docker files and directories - /etc/default/docker"
file="/etc/default/docker"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass "$check_1_10"
else
warn "$check_1_10"
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_10"
else
warn "$check_1_10"
fi
else
info "$check_1_10"
info " * File not found"
fi
check_1_1_5() {
local id="1.1.5"
local desc="Ensure auditing is configured for Docker files and directories - /var/lib/docker (Automated)"
local remediation="Install auditd. Add -w /var/lib/docker -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 1.11
check_1_11="1.11 - Audit Docker files and directories - /etc/docker/daemon.json"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass "$check_1_11"
else
warn "$check_1_11"
directory="/var/lib/docker"
if [ -d "$directory" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $directory >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_11"
else
warn "$check_1_11"
if grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
else
info "$check_1_11"
info " * File not found"
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
# 1.12
check_1_12="1.12 - Audit Docker files and directories - /usr/bin/docker-containerd"
file="/usr/bin/docker-containerd"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass "$check_1_12"
else
warn "$check_1_12"
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_12"
else
warn "$check_1_12"
fi
else
info "$check_1_12"
info " * File not found"
fi
check_1_1_6() {
local id="1.1.6"
local desc="Ensure auditing is configured for Docker files and directories - /etc/docker (Automated)"
local remediation="Install auditd. Add -w /etc/docker -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 1.13
check_1_13="1.13 - Audit Docker files and directories - /usr/bin/docker-runc"
file="/usr/bin/docker-runc"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass "$check_1_13"
else
warn "$check_1_13"
directory="/etc/docker"
if [ -d "$directory" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $directory >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
elif grep "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass "$check_1_13"
else
warn "$check_1_13"
if grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
else
info "$check_1_13"
info " * File not found"
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
check_1_1_7() {
local id="1.1.7"
local desc="Ensure auditing is configured for Docker files and directories - docker.service (Automated)"
local remediation
remediation="Install auditd. Add -w $(get_service_file docker.service) -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="$(get_service_file docker.service)"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_8() {
local id="1.1.8"
local desc="Ensure auditing is configured for Docker files and directories - containerd.sock (Automated)"
local remediation
remediation="Install auditd. Add -w $(get_service_file containerd.sock) -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="$(get_service_file containerd.sock)"
if [ -e "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_9() {
local id="1.1.9"
local desc="Ensure auditing is configured for Docker files and directories - docker.socket (Automated)"
local remediation
remediation="Install auditd. Add -w $(get_service_file docker.socket) -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="$(get_service_file docker.socket)"
if [ -e "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep "$file" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_10() {
local id="1.1.10"
local desc="Ensure auditing is configured for Docker files and directories - /etc/default/docker (Automated)"
local remediation="Install auditd. Add -w /etc/default/docker -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/default/docker"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_11() {
local id="1.1.11"
local desc="Ensure auditing is configured for Dockerfiles and directories - /etc/docker/daemon.json (Automated)"
local remediation="Install auditd. Add -w /etc/docker/daemon.json -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_12() {
local id="1.1.12"
local desc="1.1.12 Ensure auditing is configured for Dockerfiles and directories - /etc/containerd/config.toml (Automated)"
local remediation="Install auditd. Add -w /etc/containerd/config.toml -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/containerd/config.toml"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_13() {
local id="1.1.13"
local desc="Ensure auditing is configured for Docker files and directories - /etc/sysconfig/docker (Automated)"
local remediation="Install auditd. Add -w /etc/sysconfig/docker -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/sysconfig/docker"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_14() {
local id="1.1.14"
local desc="Ensure auditing is configured for Docker files and directories - /usr/bin/containerd (Automated)"
local remediation="Install auditd. Add -w /usr/bin/containerd -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/containerd"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_15() {
local id="1.1.15"
local desc="Ensure auditing is configured for Docker files and directories - /usr/bin/containerd-shim (Automated)"
local remediation="Install auditd. Add -w /usr/bin/containerd-shim -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/containerd-shim"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_16() {
local id="1.1.16"
local desc="Ensure auditing is configured for Docker files and directories - /usr/bin/containerd-shim-runc-v1 (Automated)"
local remediation="Install auditd. Add -w /usr/bin/containerd-shim-runc-v1 -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/containerd-shim-runc-v1"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_17() {
local id="1.1.17"
local desc="Ensure auditing is configured for Docker files and directories - /usr/bin/containerd-shim-runc-v2 (Automated)"
local remediation="Install auditd. Add -w /usr/bin/containerd-shim-runc-v2 -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/containerd-shim-runc-v2"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_1_18() {
local id="1.1.18"
local desc="Ensure auditing is configured for Docker files and directories - /usr/bin/runc (Automated)"
local remediation="Install auditd. Add -w /usr/bin/runc -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart."
local remediationImpact="Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/usr/bin/runc"
if [ -f "$file" ]; then
if command -v auditctl >/dev/null 2>&1; then
if auditctl -l | grep $file >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_1_2() {
local id="1.2"
local desc="General Configuration"
local check="$id - $desc"
info "$check"
}
check_1_2_1() {
local id="1.2.1"
local desc="Ensure the container host has been Hardened (Manual)"
local remediation="You may consider various Security Benchmarks for your container host."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_1_2_2() {
local id="1.2.2"
local desc="Ensure that the version of Docker is up to date (Manual)"
local remediation="You should monitor versions of Docker releases and make sure your software is updated as required."
local remediationImpact="You should perform a risk assessment regarding Docker version updates and review how they may impact your operations."
local check="$id - $desc"
starttestjson "$id" "$desc"
docker_version=$(docker version | grep -i -A2 '^server' | grep ' Version:' \
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,')
docker_current_version="$(date +%y.%m.0 -d @$(( $(date +%s) - 2592000)))"
do_version_check "$docker_current_version" "$docker_version"
if [ $? -eq 11 ]; then
pass -c "$check"
info " * Using $docker_version, verify is it up to date as deemed necessary"
logcheckresult "INFO" "Using $docker_version"
return
fi
pass -c "$check"
info " * Using $docker_version which is current"
info " * Check with your operating system vendor for support and security maintenance for Docker"
logcheckresult "PASS" "Using $docker_version"
}
check_1_end() {
endsectionjson
}

View File

@ -1,288 +1,424 @@
#!/bin/sh
#!/bin/bash
logit "\n"
info "2 - Docker Daemon Configuration"
check_2() {
logit ""
local id="2"
local desc="Docker daemon configuration"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
# 2.1
check_2_1="2.1 - Restrict network traffic between containers"
if get_docker_effective_command_line_args '--icc' | grep false >/dev/null 2>&1; then
pass "$check_2_1"
elif get_docker_configuration_file_args 'icc' | grep "false" >/dev/null 2>&1; then
pass "$check_2_1"
else
warn "$check_2_1"
fi
check_2_1() {
local id="2.1"
local desc="Run the Docker daemon as a non-root user, if possible (Manual)"
local remediation="Follow the current Dockerdocumentation on how to install the Docker daemon as a non-root user."
local remediationImpact="There are multiple prerequisites depending on which distribution that is in use, and also known limitations regarding networking and resource limitation. Running in rootless mode also changes the location of any configuration files in use, including all containers using the daemon."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.2
check_2_2="2.2 - Set the logging level"
if get_docker_configuration_file_args 'log-level' >/dev/null 2>&1; then
if get_docker_configuration_file_args 'log-level' | grep info >/dev/null 2>&1; then
pass "$check_2_2"
elif [ -z "$(get_docker_configuration_file_args 'log-level')" ]; then
pass "$check_2_2"
else
warn "$check_2_2"
note -c "$check"
logcheckresult "INFO"
}
check_2_2() {
local id="2.2"
local desc="Ensure network traffic is restricted between containers on the default bridge (Scored)"
local remediation="Edit the Docker daemon configuration file to ensure that inter-container communication is disabled: icc: false."
local remediationImpact="Inter-container communication is disabled on the default network bridge. If any communication between containers on the same host is desired, it needs to be explicitly defined using container linking or custom networks."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_effective_command_line_args '--icc' | grep false >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
elif get_docker_effective_command_line_args '-l'; then
if get_docker_effective_command_line_args '-l' | grep "info" >/dev/null 2>&1; then
pass "$check_2_2"
else
warn "$check_2_2"
if [[ $(get_docker_configuration_file_args 'icc' | grep "false") ]] && [[ $(get_docker_configuration_file_args 'icc' | grep "false") != "null" ]] ; then
pass -s "$check"
logcheckresult "PASS"
return
fi
else
pass "$check_2_2"
fi
warn -s "$check"
logcheckresult "WARN"
}
# 2.3
check_2_3="2.3 - Allow Docker to make changes to iptables"
if get_docker_effective_command_line_args '--iptables' | grep "false" >/dev/null 2>&1; then
warn "$check_2_3"
elif get_docker_configuration_file_args 'iptables' | grep "false" >/dev/null 2>&1; then
warn "$check_2_3"
else
pass "$check_2_3"
fi
check_2_3() {
local id="2.3"
local desc="Ensure the logging level is set to 'info' (Scored)"
local remediation="Ensure that the Docker daemon configuration file has the following configuration included log-level: info. Alternatively, run the Docker daemon as following: dockerd --log-level=info"
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.4
check_2_4="2.4 - Do not use insecure registries"
if get_docker_effective_command_line_args '--insecure-registry' | grep "insecure-registry" >/dev/null 2>&1; then
warn "$check_2_4"
elif ! [ -z "$(get_docker_configuration_file_args 'insecure-registries')" ]; then
if get_docker_configuration_file_args 'insecure-registries' | grep '\[]' >/dev/null 2>&1; then
pass "$check_2_4"
else
warn "$check_2_4"
fi
else
pass "$check_2_4"
fi
# 2.5
check_2_5="2.5 - Do not use the aufs storage driver"
if docker info 2>/dev/null | grep -e "^Storage Driver:\s*aufs\s*$" >/dev/null 2>&1; then
warn "$check_2_5"
else
pass "$check_2_5"
fi
# 2.6
check_2_6="2.6 - Configure TLS authentication for Docker daemon"
if grep -i 'tcp://' "$CONFIG_FILE" 2>/dev/null 1>&2; then
if [ $(get_docker_configuration_file_args '"tls":' | grep 'true') ] || \
[ $(get_docker_configuration_file_args '"tlsverify' | grep 'true') ] ; then
if get_docker_configuration_file_args 'tlskey' | grep -v '""' >/dev/null 2>&1; then
if get_docker_configuration_file_args 'tlsverify' | grep 'true' >/dev/null 2>&1; then
pass "$check_2_6"
else
warn "$check_2_6"
warn " * Docker daemon currently listening on TCP with TLS, but no verification"
fi
if get_docker_configuration_file_args 'log-level' >/dev/null 2>&1; then
if get_docker_configuration_file_args 'log-level' | grep info >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
else
warn "$check_2_6"
warn " * Docker daemon currently listening on TCP without TLS"
if [ -z "$(get_docker_configuration_file_args 'log-level')" ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
elif get_docker_cumulative_command_line_args '-H' | grep -vE '(unix|fd)://' >/dev/null 2>&1; then
if get_docker_cumulative_command_line_args '--tlskey' | grep 'tlskey=' >/dev/null 2>&1; then
if get_docker_cumulative_command_line_args '--tlsverify' | grep 'tlsverify' >/dev/null 2>&1; then
pass "$check_2_6"
else
warn "$check_2_6"
if get_docker_effective_command_line_args '-l'; then
if get_docker_effective_command_line_args '-l' | grep "info" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
check_2_4() {
local id="2.4"
local desc="Ensure Docker is allowed to make changes to iptables (Scored)"
local remediation="Do not run the Docker daemon with --iptables=false option."
local remediationImpact="The Docker daemon service requires iptables rules to be enabled before it starts."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_effective_command_line_args '--iptables' | grep "false" >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
if [[ $(get_docker_configuration_file_args 'iptables' | grep "false") ]] && [[ $(get_docker_configuration_file_args 'iptables' | grep "false") != "null" ]] ; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
check_2_5() {
local id="2.5"
local desc="Ensure insecure registries are not used (Scored)"
local remediation="You should ensure that no insecure registries are in use."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_effective_command_line_args '--insecure-registry' | grep "insecure-registry" >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
if [[ $(get_docker_configuration_file_args 'insecure-registries' | grep -v '\[]') ]] && [[ $(get_docker_configuration_file_args 'insecure-registries' | grep -v '\[]') != "null" ]] ; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
check_2_6() {
local id="2.6"
local desc="Ensure aufs storage driver is not used (Scored)"
local remediation="Do not start Docker daemon as using dockerd --storage-driver aufs option."
local remediationImpact="aufs is the only storage driver that allows containers to share executable and shared library memory. Its use should be reviewed in line with your organization's security policy."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "^\sStorage Driver:\s*aufs\s*$" >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
check_2_7() {
local id="2.7"
local desc="Ensure TLS authentication for Docker daemon is configured (Scored)"
local remediation="Follow the steps mentioned in the Docker documentation or other references. By default, TLS authentication is not configured."
local remediationImpact="You would need to manage and guard certificates and keys for the Docker daemon and Docker clients."
local check="$id - $desc"
starttestjson "$id" "$desc"
if $(grep -qE "host.*tcp://" "$CONFIG_FILE") || \
[ $(get_docker_cumulative_command_line_args '-H' | grep -vE '(unix|fd)://') > /dev/null 2>&1 ]; then
if [ $(get_docker_configuration_file_args '"tlsverify":' | grep 'true') ] || \
[ $(get_docker_cumulative_command_line_args '--tlsverify' | grep 'tlsverify') >/dev/null 2>&1 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if [ $(get_docker_configuration_file_args '"tls":' | grep 'true') ] || \
[ $(get_docker_cumulative_command_line_args '--tls' | grep 'tls$') >/dev/null 2>&1 ]; then
warn -s "$check"
warn " * Docker daemon currently listening on TCP with TLS, but no verification"
logcheckresult "WARN" "Docker daemon currently listening on TCP with TLS, but no verification"
return
fi
else
warn "$check_2_6"
warn -s "$check"
warn " * Docker daemon currently listening on TCP without TLS"
logcheckresult "WARN" "Docker daemon currently listening on TCP without TLS"
return
fi
else
info "$check_2_6"
info -c "$check"
info " * Docker daemon not listening on TCP"
fi
logcheckresult "INFO" "Docker daemon not listening on TCP"
}
check_2_8() {
local id="2.8"
local desc="Ensure the default ulimit is configured appropriately (Manual)"
local remediation="Run Docker in daemon mode and pass --default-ulimit as option with respective ulimits as appropriate in your environment and in line with your security policy. Example: dockerd --default-ulimit nproc=1024:2048 --default-ulimit nofile=100:200"
local remediationImpact="If ulimits are set incorrectly this could cause issues with system resources, possibly causing a denial of service condition."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.7
check_2_7="2.7 - Set default ulimit as appropriate"
if get_docker_configuration_file_args 'default-ulimit' | grep -v '{}' >/dev/null 2>&1; then
pass "$check_2_7"
elif get_docker_effective_command_line_args '--default-ulimit' | grep "default-ulimit" >/dev/null 2>&1; then
pass "$check_2_7"
else
info "$check_2_7"
if [[ $(get_docker_configuration_file_args 'default-ulimits' | grep -v '{}') ]] && [[ $(get_docker_configuration_file_args 'default-ulimits' | grep -v '{}') != "null" ]] ; then
pass -c "$check"
logcheckresult "PASS"
return
fi
if get_docker_effective_command_line_args '--default-ulimit' | grep "default-ulimit" >/dev/null 2>&1; then
pass -c "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
info " * Default ulimit doesn't appear to be set"
fi
logcheckresult "INFO" "Default ulimit doesn't appear to be set"
}
# 2.8
check_2_8="2.8 - Enable user namespace support"
if get_docker_configuration_file_args 'userns-remap' | grep -v '""'; then
pass "$check_2_8"
elif get_docker_effective_command_line_args '--userns-remap' | grep "userns-remap" >/dev/null 2>&1; then
pass "$check_2_8"
else
warn "$check_2_8"
fi
check_2_9() {
local id="2.9"
local desc="Enable user namespace support (Scored)"
local remediation="Please consult the Docker documentation for various ways in which this can be configured depending upon your requirements. The high-level steps are: Ensure that the files /etc/subuid and /etc/subgid exist. Start the docker daemon with --userns-remap flag."
local remediationImpact="User namespace remapping is incompatible with a number of Docker features and also currently breaks some of its functionalities."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.9
check_2_9="2.9 - Confirm default cgroup usage"
if get_docker_configuration_file_args 'cgroup-parent' | grep -v '""'; then
warn "$check_2_9"
info " * Confirm cgroup usage"
elif get_docker_effective_command_line_args '--cgroup-parent' | grep "cgroup-parent" >/dev/null 2>&1; then
warn "$check_2_9"
info " * Confirm cgroup usage"
else
pass "$check_2_9"
fi
if [[ $(get_docker_configuration_file_args 'userns-remap' | grep -v '""') ]] && [[ $(get_docker_configuration_file_args 'userns-remap' | grep -v '""') != "null" ]] ; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if get_docker_effective_command_line_args '--userns-remap' | grep "userns-remap" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
# 2.10
check_2_10="2.10 - Do not change base device size until needed"
if get_docker_configuration_file_args 'storage-opts' | grep "dm.basesize" >/dev/null 2>&1; then
warn "$check_2_10"
elif get_docker_effective_command_line_args '--storage-opt' | grep "dm.basesize" >/dev/null 2>&1; then
warn "$check_2_10"
else
pass "$check_2_10"
fi
check_2_10() {
local id="2.10"
local desc="Ensure the default cgroup usage has been confirmed (Scored)"
local remediation="The default setting is in line with good security practice and can be left in situ."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.11
check_2_11="2.11 - Use authorization plugin"
if get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]'; then
pass "$check_2_11"
elif get_docker_effective_command_line_args '--authorization-plugin' | grep "authorization-plugin" >/dev/null 2>&1; then
pass "$check_2_11"
else
warn "$check_2_11"
fi
if get_docker_configuration_file_args 'cgroup-parent' | grep -v ''; then
warn -s "$check"
info " * Confirm cgroup usage"
logcheckresult "WARN" "Confirm cgroup usage"
return
fi
if get_docker_effective_command_line_args '--cgroup-parent' | grep "cgroup-parent" >/dev/null 2>&1; then
warn -s "$check"
info " * Confirm cgroup usage"
logcheckresult "WARN" "Confirm cgroup usage"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
# 2.12
check_2_12="2.12 - Configure centralized and remote logging"
if docker info --format '{{ .LoggingDriver }}' | grep 'json-file' >/dev/null 2>&1; then
warn "$check_2_12"
else
pass "$check_2_12"
fi
check_2_11() {
local id="2.11"
local desc="Ensure base device size is not changed until needed (Scored)"
local remediation="Do not set --storage-opt dm.basesize until needed."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.13
check_2_13="2.13 - Disable operations on legacy registry (v1)"
if get_docker_configuration_file_args 'disable-legacy-registry' | grep 'true' >/dev/null 2>&1; then
pass "$check_2_13"
elif get_docker_effective_command_line_args '--disable-legacy-registry' | grep "disable-legacy-registry" >/dev/null 2>&1; then
pass "$check_2_13"
else
warn "$check_2_13"
fi
if get_docker_configuration_file_args 'storage-opts' | grep "dm.basesize" >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
if get_docker_effective_command_line_args '--storage-opt' | grep "dm.basesize" >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
# 2.14
check_2_14="2.14 - Enable live restore"
if docker info 2>/dev/null | grep -e "Live Restore Enabled:\s*true\s*" >/dev/null 2>&1; then
pass "$check_2_14"
else
check_2_12() {
local id="2.12"
local desc="Ensure that authorization for Docker client commands is enabled (Scored)"
local remediation="Install/Create an authorization plugin. Configure the authorization policy as desired. Start the docker daemon using command dockerd --authorization-plugin=<PLUGIN_ID>"
local remediationImpact="Each Docker command needs to pass through the authorization plugin mechanism. This may have a performance impact"
local check="$id - $desc"
starttestjson "$id" "$desc"
if [[ $(get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]') ]] && [[ $(get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]') != "null" ]] ; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if get_docker_effective_command_line_args '--authorization-plugin' | grep "authorization-plugin" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
check_2_13() {
local id="2.13"
local desc="Ensure centralized and remote logging is configured (Scored)"
local remediation="Set up the desired log driver following its documentation. Start the docker daemon using that logging driver. Example: dockerd --log-driver=syslog --log-opt syslog-address=tcp://192.xxx.xxx.xxx"
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info --format '{{ .LoggingDriver }}' | grep 'json-file' >/dev/null 2>&1; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}
check_2_14() {
local id="2.14"
local desc="Ensure containers are restricted from acquiring new privileges (Scored)"
local remediation="You should run the Docker daemon using command: dockerd --no-new-privileges"
local remediationImpact="no_new_priv prevents LSMs such as SELinux from escalating the privileges of individual containers."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_effective_command_line_args '--no-new-privileges' | grep "no-new-privileges" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if get_docker_configuration_file_args 'no-new-privileges' | grep true >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
check_2_15() {
local id="2.15"
local desc="Ensure live restore is enabled (Scored)"
local remediation="Run Docker in daemon mode and pass --live-restore option."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Live Restore Enabled:\s*true\s*" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
pass "$check_2_14 (Incompatible with swarm mode)"
else
warn "$check_2_14"
pass -s "$check (Incompatible with swarm mode)"
logcheckresult "PASS"
return
fi
fi
# 2.15
check_2_15="2.15 - Do not enable swarm mode, if not needed"
if docker info 2>/dev/null | grep -e "Swarm:*\sinactive\s*" >/dev/null 2>&1; then
pass "$check_2_15"
else
warn "$check_2_15"
fi
# 2.16
check_2_16="2.16 - Control the number of manager nodes in a swarm"
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
managernodes=$(docker node ls | grep -c "Leader")
if [ "$managernodes" -le 1 ]; then
pass "$check_2_16"
else
warn "$check_2_16"
if get_docker_effective_command_line_args '--live-restore' | grep "live-restore" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
else
pass "$check_2_16 (Swarm mode not enabled)"
fi
warn -s "$check"
logcheckresult "WARN"
}
# 2.17
check_2_17="2.17 - Bind swarm services to a specific host interface"
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
netstat -lnt | grep -e '\[::]:2377 ' -e ':::2377' -e '*:2377 ' -e ' 0\.0\.0\.0:2377 ' >/dev/null 2>&1
if [ $? -eq 1 ]; then
pass "$check_2_17"
else
warn "$check_2_17"
check_2_16() {
local id="2.16"
local desc="Ensure Userland Proxy is Disabled (Scored)"
local remediation="You should run the Docker daemon using command: dockerd --userland-proxy=false"
local remediationImpact="Some systems with older Linux kernels may not be able to support hairpin NAT and therefore require the userland proxy service. Also, some networking setups can be impacted by the removal of the userland proxy."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_configuration_file_args 'userland-proxy' | grep false >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
else
pass "$check_2_17 (Swarm mode not enabled)"
fi
if get_docker_effective_command_line_args '--userland-proxy=false' 2>/dev/null | grep "userland-proxy=false" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
# 2.18
check_2_18="2.18 - Disable Userland Proxy"
if get_docker_configuration_file_args 'userland-proxy' | grep false >/dev/null 2>&1; then
pass "$check_2_18"
elif get_docker_effective_command_line_args '--userland-proxy=false' 2>/dev/null | grep "userland-proxy=false" >/dev/null 2>&1; then
pass "$check_2_18"
else
warn "$check_2_18"
fi
check_2_17() {
local id="2.17"
local desc="Ensure that a daemon-wide custom seccomp profile is applied if appropriate (Manual)"
local remediation="By default, Docker's default seccomp profile is applied. If this is adequate for your environment, no action is necessary."
local remediationImpact="A misconfigured seccomp profile could possibly interrupt your container environment. You should therefore exercise extreme care if you choose to override the default settings."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 2.19
check_2_19="2.19 - Encrypt data exchanged between containers on different nodes on the overlay network"
if docker network ls --filter driver=overlay --quiet | \
xargs docker network inspect --format '{{.Name}} {{ .Options }}' 2>/dev/null | \
grep -v 'encrypted:' 2>/dev/null 1>&2; then
warn "$check_2_19"
for encnet in $(docker network ls --filter driver=overlay --quiet); do
if docker network inspect --format '{{.Name}} {{ .Options }}' "$encnet" | \
grep -v 'encrypted:' 2>/dev/null 1>&2; then
warn " * Unencrypted overlay network: $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")"
if docker info --format '{{ .SecurityOptions }}' | grep 'name=seccomp,profile=default' 2>/dev/null 1>&2; then
pass -c "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
logcheckresult "INFO"
}
check_2_18() {
docker_version=$(docker version | grep -i -A2 '^server' | grep ' Version:' \
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,.' | cut -c 1-4)
local id="2.18"
local desc="Ensure that experimental features are not implemented in production (Scored)"
local remediation="You should not pass --experimental as a runtime parameter to the Docker daemon on production systems."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if [ "$docker_version" -le 1903 ]; then
if docker version -f '{{.Server.Experimental}}' | grep false 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
done
else
pass "$check_2_19"
fi
# 2.20
check_2_20="2.20 - Apply a daemon-wide custom seccomp profile, if needed"
if docker info --format '{{ .SecurityOptions }}' | grep 'name=seccomp,profile=default' 2>/dev/null 1>&2; then
pass "$check_2_20"
else
info "$check_2_20"
fi
# 2.21
check_2_21="2.21 - Avoid experimental features in production"
if docker info 2>/dev/null | grep -e "Experimental:\s*false*" 2>/dev/null 1>&2; then
pass "$check_2_21"
else
warn "$check_2_21"
fi
# 2.22
check_2_22="2.22 - Use Docker's secret management commands for managing secrets in a Swarm cluster"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
if [ "$(docker secret ls -q | wc -l)" -ge 1 ]; then
pass "$check_2_22"
else
info "$check_2_22"
warn -s "$check"
logcheckresult "WARN"
return
fi
else
pass "$check_2_22 (Swarm mode not enabled)"
fi
local desc="$desc (Deprecated)"
local check="$id - $desc"
info -c "$desc"
logcheckresult "INFO"
}
# 2.23
check_2_23="2.23 - Run swarm manager in auto-lock mode"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
if ! docker swarm unlock-key 2>/dev/null | grep 'SWMKEY' 2>/dev/null 1>&2; then
warn "$check_2_23"
else
pass "$check_2_23"
fi
else
pass "$check_2_23 (Swarm mode not enabled)"
fi
# 2.24
check_2_24="2.24 - Rotate swarm manager auto-lock key periodically"
note "$check_2_24"
check_2_end() {
endsectionjson
}

View File

@ -1,342 +1,646 @@
#!/bin/sh
#!/bin/bash
logit "\n"
info "3 - Docker Daemon Configuration Files"
check_3() {
logit ""
local id="3"
local desc="Docker daemon configuration files"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
# 3.1
check_3_1="3.1 - Verify that docker.service file ownership is set to root:root"
file="$(get_systemd_service_file docker.service)"
if [ -f "$file" ]; then
if [ "$(stat -c %u%g $file)" -eq 00 ]; then
pass "$check_3_1"
else
warn "$check_3_1"
warn " * Wrong ownership for $file"
fi
else
info "$check_3_1"
info " * File not found"
fi
check_3_1() {
local id="3.1"
local desc="Ensure that the docker.service file ownership is set to root:root (Automated)"
local remediation="Find out the file location: systemctl show -p FragmentPath docker.service. If the file does not exist, this recommendation is not applicable. If the file does exist, you should run the command chown root:root <path>, in order to set the ownership and group ownership for the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.2
check_3_2="3.2 - Verify that docker.service file permissions are set to 644 or more restrictive"
file="$(get_systemd_service_file docker.service)"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
pass "$check_3_2"
else
warn "$check_3_2"
warn " * Wrong permissions for $file"
fi
else
info "$check_3_2"
info " * File not found"
fi
# 3.3
check_3_3="3.3 - Verify that docker.socket file ownership is set to root:root"
file="$(get_systemd_service_file docker.socket)"
if [ -f "$file" ]; then
if [ "$(stat -c %u%g $file)" -eq 00 ]; then
pass "$check_3_3"
else
warn "$check_3_3"
warn " * Wrong ownership for $file"
fi
else
info "$check_3_3"
info " * File not found"
fi
# 3.4
check_3_4="3.4 - Verify that docker.socket file permissions are set to 644 or more restrictive"
file="$(get_systemd_service_file docker.socket)"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
pass "$check_3_4"
else
warn "$check_3_4"
warn " * Wrong permissions for $file"
fi
else
info "$check_3_4"
info " * File not found"
fi
# 3.5
check_3_5="3.5 - Verify that /etc/docker directory ownership is set to root:root"
directory="/etc/docker"
if [ -d "$directory" ]; then
if [ "$(stat -c %u%g $directory)" -eq 00 ]; then
pass "$check_3_5"
else
warn "$check_3_5"
warn " * Wrong ownership for $directory"
fi
else
info "$check_3_5"
info " * Directory not found"
fi
# 3.6
check_3_6="3.6 - Verify that /etc/docker directory permissions are set to 755 or more restrictive"
directory="/etc/docker"
if [ -d "$directory" ]; then
if [ "$(stat -c %a $directory)" -eq 755 -o "$(stat -c %a $directory)" -eq 700 ]; then
pass "$check_3_6"
else
warn "$check_3_6"
warn " * Wrong permissions for $directory"
fi
else
info "$check_3_6"
info " * Directory not found"
fi
# 3.7
check_3_7="3.7 - Verify that registry certificate file ownership is set to root:root"
directory="/etc/docker/certs.d/"
if [ -d "$directory" ]; then
fail=0
owners=$(find "$directory" -type f -name '*.crt')
for p in $owners; do
if [ "$(stat -c %u $p)" -ne 0 ]; then
fail=1
file=$(get_service_file docker.service)
if [ -f "$file" ]; then
if [ "$(stat -c %u%g "$file")" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
done
if [ $fail -eq 1 ]; then
warn "$check_3_7"
warn " * Wrong ownership for $directory"
else
pass "$check_3_7"
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
else
info "$check_3_7"
info " * Directory not found"
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
# 3.8
check_3_8="3.8 - Verify that registry certificate file permissions are set to 444 or more restrictive"
directory="/etc/docker/certs.d/"
if [ -d "$directory" ]; then
fail=0
perms=$(find "$directory" -type f -name '*.crt')
for p in $perms; do
if [ "$(stat -c %a $p)" -ne 444 -a "$(stat -c %a $p)" -ne 400 ]; then
fail=1
check_3_2() {
local id="3.2"
local desc="Ensure that docker.service file permissions are appropriately set (Automated)"
local remediation="Find out the file location: systemctl show -p FragmentPath docker.service. If the file does not exist, this recommendation is not applicable. If the file exists, run the command chmod 644 <path> to set the file permissions to 644."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file=$(get_service_file docker.service)
if [ -f "$file" ]; then
if [ "$(stat -c %a "$file")" -le 644 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
done
if [ $fail -eq 1 ]; then
warn "$check_3_8"
warn " * Wrong permissions for $directory"
else
pass "$check_3_8"
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
else
info "$check_3_8"
info " * Directory not found"
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_3() {
local id="3.3"
local desc="Ensure that docker.socket file ownership is set to root:root (Automated)"
local remediation="Find out the file location: systemctl show -p FragmentPath docker.socket. If the file does not exist, this recommendation is not applicable. If the file exists, run the command chown root:root <path> to set the ownership and group ownership for the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file=$(get_service_file docker.socket)
if [ -f "$file" ]; then
if [ "$(stat -c %u%g "$file")" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_4() {
local id="3.4"
local desc="Ensure that docker.socket file permissions are set to 644 or more restrictive (Automated)"
local remediation="Find out the file location: systemctl show -p FragmentPath docker.socket. If the file does not exist, this recommendation is not applicable. If the file does exist, you should run the command chmod 644 <path> to set the file permissions to 644."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file=$(get_service_file docker.socket)
if [ -f "$file" ]; then
if [ "$(stat -c %a "$file")" -le 644 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_5() {
local id="3.5"
local desc="Ensure that the /etc/docker directory ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /etc/docker. This sets the ownership and group ownership for the directory to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
directory="/etc/docker"
if [ -d "$directory" ]; then
if [ "$(stat -c %u%g $directory)" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $directory"
logcheckresult "WARN" "Wrong ownership for $directory"
return
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
check_3_6() {
local id="3.6"
local desc="Ensure that /etc/docker directory permissions are set to 755 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 755 /etc/docker. This sets the permissions for the directory to 755."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
directory="/etc/docker"
if [ -d "$directory" ]; then
if [ "$(stat -c %a $directory)" -le 755 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $directory"
logcheckresult "WARN" "Wrong permissions for $directory"
return
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
check_3_7() {
local id="3.7"
local desc="Ensure that registry certificate file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /etc/docker/certs.d/<registry-name>/*. This would set the individual ownership and group ownership for the registry certificate files to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
directory="/etc/docker/certs.d/"
if [ -d "$directory" ]; then
fail=0
owners=$(find "$directory" -type f -name '*.crt')
for p in $owners; do
if [ "$(stat -c %u "$p")" -ne 0 ]; then
fail=1
fi
done
if [ $fail -eq 1 ]; then
warn -s "$check"
warn " * Wrong ownership for $directory"
logcheckresult "WARN" "Wrong ownership for $directory"
return
fi
pass -s "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
check_3_8() {
local id="3.8"
local desc="Ensure that registry certificate file permissions are set to 444 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 444 /etc/docker/certs.d/<registry-name>/*. This would set the permissions for the registry certificate files to 444."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
directory="/etc/docker/certs.d/"
if [ -d "$directory" ]; then
fail=0
perms=$(find "$directory" -type f -name '*.crt')
for p in $perms; do
if [ "$(stat -c %a "$p")" -gt 444 ]; then
fail=1
fi
done
if [ $fail -eq 1 ]; then
warn -s "$check"
warn " * Wrong permissions for $directory"
logcheckresult "WARN" "Wrong permissions for $directory"
return
fi
pass -s "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
info " * Directory not found"
logcheckresult "INFO" "Directory not found"
}
check_3_9() {
local id="3.9"
local desc="Ensure that TLS CA certificate file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root <path to TLS CA certificate file>. This sets the individual ownership and group ownership for the TLS CA certificate file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.9
check_3_9="3.9 - Verify that TLS CA certificate file ownership is set to root:root"
if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then
tlscacert=$(get_docker_configuration_file_args 'tlscacert')
else
tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlscacert" ]; then
if [ "$(stat -c %u%g "$tlscacert")" -eq 00 ]; then
pass "$check_3_9"
else
warn "$check_3_9"
if [ -n "$(get_docker_configuration_file_args 'tlscacert')" ]; then
tlscacert=$(get_docker_configuration_file_args 'tlscacert')
fi
if [ -f "$tlscacert" ]; then
if [ "$(stat -c %u%g "$tlscacert")" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $tlscacert"
logcheckresult "WARN" "Wrong ownership for $tlscacert"
return
fi
else
info "$check_3_9"
info -c "$check"
info " * No TLS CA certificate found"
fi
logcheckresult "INFO" "No TLS CA certificate found"
}
check_3_10() {
local id="3.10"
local desc="Ensure that TLS CA certificate file permissions are set to 444 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 444 <path to TLS CA certificate file>. This sets the file permissions on the TLS CA file to 444."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.10
check_3_10="3.10 - Verify that TLS CA certificate file permissions are set to 444 or more restrictive"
if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then
tlscacert=$(get_docker_configuration_file_args 'tlscacert')
else
tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlscacert" ]; then
if [ "$(stat -c %a $tlscacert)" -eq 444 -o "$(stat -c %a $tlscacert)" -eq 400 ]; then
pass "$check_3_10"
else
warn "$check_3_10"
warn " * Wrong permissions for $tlscacert"
if [ -n "$(get_docker_configuration_file_args 'tlscacert')" ]; then
tlscacert=$(get_docker_configuration_file_args 'tlscacert')
fi
else
info "$check_3_10"
info " * No TLS CA certificate found"
fi
if [ -f "$tlscacert" ]; then
if [ "$(stat -c %a "$tlscacert")" -le 444 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $tlscacert"
logcheckresult "WARN" "Wrong permissions for $tlscacert"
return
fi
info -c "$check"
info " * No TLS CA certificate found"
logcheckresult "INFO" "No TLS CA certificate found"
}
check_3_11() {
local id="3.11"
local desc="Ensure that Docker server certificate file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root <path to Docker server certificate file>. This sets the individual ownership and the group ownership for the Docker server certificate file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.11
check_3_11="3.11 - Verify that Docker server certificate file ownership is set to root:root"
if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then
tlscert=$(get_docker_configuration_file_args 'tlscert')
else
tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlscert" ]; then
if [ "$(stat -c %u%g "$tlscert")" -eq 00 ]; then
pass "$check_3_11"
else
warn "$check_3_11"
warn " * Wrong ownership for $tlscert"
if [ -n "$(get_docker_configuration_file_args 'tlscert')" ]; then
tlscert=$(get_docker_configuration_file_args 'tlscert')
fi
else
info "$check_3_11"
info " * No TLS Server certificate found"
fi
if [ -f "$tlscert" ]; then
if [ "$(stat -c %u%g "$tlscert")" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $tlscert"
logcheckresult "WARN" "Wrong ownership for $tlscert"
return
fi
info -c "$check"
info " * No TLS Server certificate found"
logcheckresult "INFO" "No TLS Server certificate found"
}
check_3_12() {
local id="3.12"
local desc="Ensure that the Docker server certificate file permissions are set to 444 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 444 <path to Docker server certificate file>. This sets the file permissions of the Docker server certificate file to 444."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.12
check_3_12="3.12 - Verify that Docker server certificate file permissions are set to 444 or more restrictive"
if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then
tlscert=$(get_docker_configuration_file_args 'tlscert')
else
tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlscert" ]; then
if [ "$(stat -c %a $tlscert)" -eq 444 -o "$(stat -c %a $tlscert)" -eq 400 ]; then
pass "$check_3_12"
else
warn "$check_3_12"
warn " * Wrong permissions for $tlscert"
if [ -n "$(get_docker_configuration_file_args 'tlscert')" ]; then
tlscert=$(get_docker_configuration_file_args 'tlscert')
fi
else
info "$check_3_12"
info " * No TLS Server certificate found"
fi
if [ -f "$tlscert" ]; then
if [ "$(stat -c %a "$tlscert")" -le 444 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $tlscert"
logcheckresult "WARN" "Wrong permissions for $tlscert"
return
fi
info -c "$check"
info " * No TLS Server certificate found"
logcheckresult "INFO" "No TLS Server certificate found"
}
check_3_13() {
local id="3.13"
local desc="Ensure that the Docker server certificate key file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root <path to Docker server certificate key file>. This sets the individual ownership and group ownership for the Docker server certificate key file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.13
check_3_13="3.13 - Verify that Docker server key file ownership is set to root:root"
if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then
tlskey=$(get_docker_configuration_file_args 'tlskey')
else
tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlskey" ]; then
if [ "$(stat -c %u%g "$tlskey")" -eq 00 ]; then
pass "$check_3_13"
else
warn "$check_3_13"
warn " * Wrong ownership for $tlskey"
if [ -n "$(get_docker_configuration_file_args 'tlskey')" ]; then
tlskey=$(get_docker_configuration_file_args 'tlskey')
fi
else
info "$check_3_13"
info " * No TLS Key found"
fi
if [ -f "$tlskey" ]; then
if [ "$(stat -c %u%g "$tlskey")" -eq 00 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $tlskey"
logcheckresult "WARN" "Wrong ownership for $tlskey"
return
fi
info -c "$check"
info " * No TLS Key found"
logcheckresult "INFO" "No TLS Key found"
}
check_3_14() {
local id="3.14"
local desc="Ensure that the Docker server certificate key file permissions are set to 400 (Automated)"
local remediation="You should run the following command: chmod 400 <path to Docker server certificate key file>. This sets the Docker server certificate key file permissions to 400."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.14
check_3_14="3.14 - Verify that Docker server key file permissions are set to 400 or more restrictive"
if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then
tlskey=$(get_docker_configuration_file_args 'tlskey')
else
tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
fi
if [ -f "$tlskey" ]; then
if [ "$(stat -c %a $tlskey)" -eq 444 -o "$(stat -c %a $tlskey)" -eq 400 ]; then
pass "$check_3_14"
else
warn "$check_3_14"
warn " * Wrong permissions for $tlskey"
if [ -n "$(get_docker_configuration_file_args 'tlskey')" ]; then
tlskey=$(get_docker_configuration_file_args 'tlskey')
fi
else
info "$check_3_14"
info " * No TLS Key found"
fi
if [ -f "$tlskey" ]; then
if [ "$(stat -c %a "$tlskey")" -eq 400 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $tlskey"
logcheckresult "WARN" "Wrong permissions for $tlskey"
return
fi
info -c "$check"
info " * No TLS Key found"
logcheckresult "INFO" "No TLS Key found"
}
# 3.15
check_3_15="3.15 - Verify that Docker socket file ownership is set to root:docker"
file="/var/run/docker.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:docker' ]; then
pass "$check_3_15"
else
warn "$check_3_15"
warn " * Wrong ownership for $file"
fi
else
info "$check_3_15"
info " * File not found"
fi
check_3_15() {
local id="3.15"
local desc="Ensure that the Docker socket file ownership is set to root:docker (Automated)"
local remediation="You should run the following command: chown root:docker /var/run/docker.sock. This sets the ownership to root and group ownership to docker for the default Docker socket file."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.16
check_3_16="3.16 - Verify that Docker socket file permissions are set to 660 or more restrictive"
file="/var/run/docker.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %a $file)" -eq 660 -o "$(stat -c %a $file)" -eq 600 ]; then
pass "$check_3_16"
else
warn "$check_3_16"
warn " * Wrong permissions for $file"
file="/var/run/docker.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:docker' ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
else
info "$check_3_16"
info " * File not found"
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
# 3.17
check_3_17="3.17 - Verify that daemon.json file ownership is set to root:root"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass "$check_3_17"
else
warn "$check_3_17"
warn " * Wrong ownership for $file"
fi
else
info "$check_3_17"
info " * File not found"
fi
check_3_16() {
local id="3.16"
local desc="Ensure that the Docker socket file permissions are set to 660 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 660 /var/run/docker.sock. This sets the file permissions of the Docker socket file to 660."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.18
check_3_18="3.18 - Verify that daemon.json file permissions are set to 644 or more restrictive"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
pass "$check_3_18"
else
warn "$check_3_18"
warn " * Wrong permissions for $file"
file="/var/run/docker.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %a $file)" -le 660 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
else
info "$check_3_18"
info " * File not found"
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
# 3.19
check_3_19="3.19 - Verify that /etc/default/docker file ownership is set to root:root"
file="/etc/default/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass "$check_3_19"
else
warn "$check_3_19"
warn " * Wrong ownership for $file"
fi
else
info "$check_3_19"
info " * File not found"
fi
check_3_17() {
local id="3.17"
local desc="Ensure that the daemon.json file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /etc/docker/daemon.json. This sets the ownership and group ownership for the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 3.20
check_3_20="3.20 - Verify that /etc/default/docker file permissions are set to 644 or more restrictive"
file="/etc/default/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
pass "$check_3_20"
else
warn "$check_3_20"
warn " * Wrong permissions for $file"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
else
info "$check_3_20"
info " * File not found"
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_18() {
local id="3.18"
local desc="Ensure that daemon.json file permissions are set to 644 or more restrictive (Automated)"
local remediation="You should run the following command: chmod 644 /etc/docker/daemon.json. This sets the file permissions for this file to 644."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/docker/daemon.json"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -le 644 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_19() {
local id="3.19"
local desc="Ensure that the /etc/default/docker file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /etc/default/docker. This sets the ownership and group ownership of the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/default/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_20() {
local id="3.20"
local desc="Ensure that the /etc/default/docker file permissions are set to 644 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 644 /etc/default/docker. This sets the file permissions for this file to 644."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/default/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -le 644 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_21() {
local id="3.21"
local desc="Ensure that the /etc/sysconfig/docker file permissions are set to 644 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 644 /etc/sysconfig/docker. This sets the file permissions for this file to 644."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/sysconfig/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %a $file)" -le 644 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_22() {
local id="3.22"
local desc="Ensure that the /etc/sysconfig/docker file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /etc/sysconfig/docker. This sets the ownership and group ownership for the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/etc/sysconfig/docker"
if [ -f "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_23() {
local id="3.23"
local desc="Ensure that the Containerd socket file ownership is set to root:root (Automated)"
local remediation="You should run the following command: chown root:root /run/containerd/containerd.sock. This sets the ownership and group ownership for the file to root."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/run/containerd/containerd.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong ownership for $file"
logcheckresult "WARN" "Wrong ownership for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_24() {
local id="3.24"
local desc="Ensure that the Containerd socket file permissions are set to 660 or more restrictively (Automated)"
local remediation="You should run the following command: chmod 660 /run/containerd/containerd.sock. This sets the file permissions for this file to 660."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
file="/run/containerd/containerd.sock"
if [ -S "$file" ]; then
if [ "$(stat -c %a $file)" -le 660 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
warn " * Wrong permissions for $file"
logcheckresult "WARN" "Wrong permissions for $file"
return
fi
info -c "$check"
info " * File not found"
logcheckresult "INFO" "File not found"
}
check_3_end() {
endsectionjson
}

View File

@ -1,131 +1,260 @@
#!/bin/sh
#!/bin/bash
logit "\n"
info "4 - Container Images and Build Files"
check_4() {
logit ""
local id="4"
local desc="Container Images and Build File"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
# 4.1
check_4_1="4.1 - Create a user for the container"
check_4_1() {
local id="4.1"
local desc="Ensure that a user for the container has been created (Automated)"
local remediation="You should ensure that the Dockerfile for each container image contains the information: USER <username or ID>. If there is no specific user created in the container base image, then make use of the useradd command to add a specific user before the USER instruction in the Dockerfile."
local remediationImpact="Running as a non-root user can present challenges where you wish to bind mount volumes from the underlying host. In this case, care should be taken to ensure that the user running the contained process can read and write to the bound directory, according to their requirements."
local check="$id - $desc"
starttestjson "$id" "$desc"
# If container_users is empty, there are no running containers
if [ -z "$containers" ]; then
info "$check_4_1"
info " * No containers running"
else
# If container_users is empty, there are no running containers
if [ -z "$containers" ]; then
info -c "$check"
info " * No containers running"
logcheckresult "INFO" "No containers running"
return
fi
# We have some containers running, set failure flag to 0. Check for Users.
fail=0
# Make the loop separator be a new-line in POSIX compliant fashion
set -f; IFS=$'
'
'
root_containers=""
for c in $containers; do
user=$(docker inspect --format 'User={{.Config.User}}' "$c")
if [ "$user" = "User=" -o "$user" = "User=[]" -o "$user" = "User=<no value>" ]; then
if [ "$user" = "User=0" ] || [ "$user" = "User=root" ] || [ "$user" = "User=" ] || [ "$user" = "User=[]" ] || [ "$user" = "User=<no value>" ]; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn "$check_4_1"
warn -s "$check"
warn " * Running as root: $c"
root_containers="$root_containers $c"
fail=1
else
warn " * Running as root: $c"
continue
fi
warn " * Running as root: $c"
root_containers="$root_containers $c"
fi
done
# We went through all the containers and found none running as root
if [ $fail -eq 0 ]; then
pass "$check_4_1"
pass -s "$check"
logcheckresult "PASS"
return
fi
fi
# Make the loop separator go back to space
set +f; unset IFS
logcheckresult "WARN" "running as root" "$root_containers"
# Make the loop separator go back to space
set +f; unset IFS
}
images=$(docker images -q)
check_4_2() {
local id="4.2"
local desc="Ensure that containers use only trusted base images (Manual)"
local remediation="Configure and use Docker Content trust. View the history of each Docker image to evaluate its risk, dependent on the sensitivity of the application you wish to deploy using it. Scan Docker images for vulnerabilities at regular intervals."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 4.2
check_4_2="4.2 - Use trusted base images for containers"
note "$check_4_2"
note -c "$check"
logcheckresult "NOTE"
}
# 4.3
check_4_3="4.3 - Do not install unnecessary packages in the container"
note "$check_4_3"
check_4_3() {
local id="4.3"
local desc="Ensure that unnecessary packages are not installed in the container (Manual)"
local remediation="You should not install anything within the container that is not required. You should consider using a minimal base image if you can. Some of the options available include BusyBox and Alpine. Not only can this trim your image size considerably, but there would also be fewer pieces of software which could contain vectors for attack."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 4.4
check_4_4="4.4 - Scan and rebuild the images to include security patches"
note "$check_4_4"
note -c "$check"
logcheckresult "NOTE"
}
# 4.5
check_4_5="4.5 - Enable Content trust for Docker"
if [ "x$DOCKER_CONTENT_TRUST" = "x1" ]; then
pass "$check_4_5"
else
warn "$check_4_5"
fi
check_4_4() {
local id="4.4"
local desc="Ensure images are scanned and rebuilt to include security patches (Manual)"
local remediation="Images should be re-built ensuring that the latest version of the base images are used, to keep the operating system patch level at an appropriate level. Once the images have been re-built, containers should be re-started making use of the updated images."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 4.6
check_4_6="4.6 - Add HEALTHCHECK instruction to the container image"
fail=0
for img in $images; do
if docker inspect --format='{{.Config.Healthcheck}}' "$img" 2>/dev/null | grep -e "<nil>" >/dev/null 2>&1; then
if [ $fail -eq 0 ]; then
fail=1
warn "$check_4_6"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
warn " * No Healthcheck found: $imgName"
fi
note -c "$check"
logcheckresult "NOTE"
}
check_4_5() {
local id="4.5"
local desc="Ensure Content trust for Docker is Enabled (Automated)"
local remediation="Add DOCKER_CONTENT_TRUST variable to the /etc/environment file using command echo DOCKER_CONTENT_TRUST=1 | sudo tee -a /etc/environment."
local remediationImpact="This prevents users from working with tagged images unless they contain a signature."
local check="$id - $desc"
starttestjson "$id" "$desc"
if [ "$DOCKER_CONTENT_TRUST" = "1" ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
done
if [ $fail -eq 0 ]; then
pass "$check_4_6"
fi
warn -s "$check"
logcheckresult "WARN"
}
# 4.7
check_4_7="4.7 - Do not use update instructions alone in the Dockerfile"
fail=0
for img in $images; do
if docker history "$img" 2>/dev/null | grep -e "update" >/dev/null 2>&1; then
if [ $fail -eq 0 ]; then
fail=1
info "$check_4_7"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
info " * Update instruction found: $imgName"
check_4_6() {
local id="4.6"
local desc="Ensure that HEALTHCHECK instructions have been added to container images (Automated)"
local remediation="You should follow the Docker documentation and rebuild your container images to include the HEALTHCHECK instruction."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
no_health_images=""
for img in $images; do
if docker inspect --format='{{.Config.Healthcheck}}' "$img" 2>/dev/null | grep -e "<nil>" >/dev/null 2>&1; then
if [ $fail -eq 0 ]; then
fail=1
warn -s "$check"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
warn " * No Healthcheck found: $imgName"
no_health_images="$no_health_images $imgName"
else
warn " * No Healthcheck found: $img"
no_health_images="$no_health_images $img"
fi
fi
done
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
done
if [ $fail -eq 0 ]; then
pass "$check_4_7"
fi
logcheckresult "WARN" "Images w/o HEALTHCHECK" "$no_health_images"
}
# 4.8
check_4_8="4.8 - Remove setuid and setgid permissions in the images"
note "$check_4_8"
check_4_7() {
local id="4.7"
local desc="Ensure update instructions are not used alone in the Dockerfile (Manual)"
local remediation="You should use update instructions together with install instructions and version pinning for packages while installing them. This prevent caching and force the extraction of the required versions. Alternatively, you could use the --no-cache flag during the docker build process to avoid using cached layers."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 4.9
check_4_9="4.9 - Use COPY instead of ADD in Dockerfile"
fail=0
for img in $images; do
docker history "$img" 2> /dev/null | grep 'ADD' >/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ $fail -eq 0 ]; then
fail=1
info "$check_4_9"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
info " * ADD in image history: $imgName"
fail=0
update_images=""
for img in $images; do
if docker history "$img" 2>/dev/null | grep -e "update" >/dev/null 2>&1; then
if [ $fail -eq 0 ]; then
fail=1
info -c "$check"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
info " * Update instruction found: $imgName"
update_images="$update_images $imgName"
fi
fi
done
if [ $fail -eq 0 ]; then
pass -c "$check"
logcheckresult "PASS"
return
fi
done
if [ $fail -eq 0 ]; then
pass "$check_4_9"
fi
logcheckresult "INFO" "Update instructions found" "$update_images"
}
# 4.10
check_4_10="4.10 - Do not store secrets in Dockerfiles"
note "$check_4_10"
check_4_8() {
local id="4.8"
local desc="Ensure setuid and setgid permissions are removed (Manual)"
local remediation="You should allow setuid and setgid permissions only on executables which require them. You could remove these permissions at build time by adding the following command in your Dockerfile, preferably towards the end of the Dockerfile: RUN find / -perm /6000 -type f -exec chmod a-s {} ; || true"
local remediationImpact="The above command would break all executables that depend on setuid or setgid permissions including legitimate ones. You should therefore be careful to modify the command to suit your requirements so that it does not reduce the permissions of legitimate programs excessively. Because of this, you should exercise a degree of caution and examine all processes carefully before making this type of modification in order to avoid outages."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 4.11
check_4_11="4.11 - Install verified packages only"
note "$check_4_11"
note -c "$check"
logcheckresult "NOTE"
}
check_4_9() {
local id="4.9"
local desc="Ensure that COPY is used instead of ADD in Dockerfiles (Manual)"
local remediation="You should use COPY rather than ADD instructions in Dockerfiles."
local remediationImpact="Care needs to be taken in implementing this control if the application requires functionality that is part of the ADD instruction, for example, if you need to retrieve files from remote URLS."
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
add_images=""
for img in $images; do
if docker history --format "{{ .CreatedBy }}" --no-trunc "$img" | \
sed '$d' | grep -q 'ADD'; then
if [ $fail -eq 0 ]; then
fail=1
info -c "$check"
fi
imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null)
if ! [ "$imgName" = '[]' ]; then
info " * ADD in image history: $imgName"
add_images="$add_images $imgName"
fi
fi
done
if [ $fail -eq 0 ]; then
pass -c "$check"
logcheckresult "PASS"
return
fi
logcheckresult "INFO" "Images using ADD" "$add_images"
}
check_4_10() {
local id="4.10"
local desc="Ensure secrets are not stored in Dockerfiles (Manual)"
local remediation="Do not store any kind of secrets within Dockerfiles. Where secrets are required during the build process, make use of a secrets management tool, such as the buildkit builder included with Docker."
local remediationImpact="A proper secrets management process will be required for Docker image building."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "NOTE"
}
check_4_11() {
local id="4.11"
local desc="Ensure only verified packages are installed (Manual)"
local remediation="You should use a secure package distribution mechanism of your choice to ensure the authenticity of software packages."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "NOTE"
}
check_4_12() {
local id="4.12"
local desc="Ensure all signed artifacts are validated (Manual)"
local remediation="Validate artifacts signatures before uploading to the package registry."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "NOTE"
}
check_4_end() {
endsectionjson
}

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +1,60 @@
#!/bin/sh
#!/bin/bash
logit "\n"
info "6 - Docker Security Operations"
check_6() {
logit ""
local id="6"
local desc="Docker Security Operations"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
# 6.1
check_6_1="6.1 - Perform regular security audits of your host system and containers"
info "$check_6_1"
check_6_1() {
local id="6.1"
local desc="Ensure that image sprawl is avoided (Manual)"
local remediation="You should keep only the images that you actually need and establish a workflow to remove old or stale images from the host. Additionally, you should use features such as pull-by-digest to get specific images from the registry."
local remediationImpact="docker system prune -a removes all exited containers as well as all images and volumes that are not referenced by running containers, including for UCP and DTR."
local check="$id - $desc"
starttestjson "$id" "$desc"
# 6.2
check_6_2="6.2 - Monitor Docker containers usage, performance and metering"
info "$check_6_2"
images=$(docker images -q | sort -u | wc -l | awk '{print $1}')
active_images=0
# 6.3
check_6_3="6.3 - Backup container data"
info "$check_6_3"
for c in $(docker inspect --format "{{.Image}}" $(docker ps -qa) 2>/dev/null); do
if docker images --no-trunc -a | grep "$c" > /dev/null ; then
active_images=$(( active_images += 1 ))
fi
done
# 6.4
check_6_4="6.4 - Avoid image sprawl"
images=$(docker images -q | sort -u | wc -l | awk '{print $1}')
active_images=0
for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do
if docker images --no-trunc -a | grep "$c" > /dev/null ; then
active_images=$(( active_images += 1 ))
fi
done
info "$check_6_4"
info -c "$check"
info " * There are currently: $images images"
if [ "$active_images" -lt "$((images / 2))" ]; then
info " * Only $active_images out of $images are in use"
fi
if [ "$active_images" -lt "$((images / 2))" ]; then
info " * Only $active_images out of $images are in use"
fi
logcheckresult "INFO" "$active_images active/$images in use"
}
# 6.5
check_6_5="6.5 - Avoid container sprawl"
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
diff="$((total_containers - running_containers))"
if [ "$diff" -gt 25 ]; then
info "$check_6_5"
info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
else
info "$check_6_5"
info " * There are currently a total of $total_containers containers, with $running_containers of them currently running"
fi
check_6_2() {
local id="6.2"
local desc="Ensure that container sprawl is avoided (Manual)"
local remediation="You should periodically check your container inventory on each host and clean up containers which are not in active use with the command: docker container prune"
local remediationImpact="You should retain containers that are actively in use, and delete ones which are no longer needed."
local check="$id - $desc"
starttestjson "$id" "$desc"
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
diff="$((total_containers - running_containers))"
info -c "$check"
if [ "$diff" -gt 25 ]; then
info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
else
info " * There are currently a total of $total_containers containers, with $running_containers of them currently running"
fi
logcheckresult "INFO" "$total_containers total/$running_containers running"
}
check_6_end() {
endsectionjson
}

View File

@ -0,0 +1,208 @@
#!/bin/bash
check_7() {
logit ""
local id="7"
local desc="Docker Swarm Configuration"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
check_7_1() {
local id="7.1"
local desc="Ensure that the minimum number of manager nodes have been created in a swarm (Automated)"
local remediation="If an excessive number of managers is configured, the excess nodes can be demoted to workers using command: docker node demote <manager node ID to be demoted>"
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
managernodes=$(docker node ls | grep -c "Leader")
if [ "$managernodes" -eq 1 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_2() {
local id="7.2"
local desc="Ensure that swarm services are bound to a specific host interface (Automated)"
local remediation="Resolving this issues requires re-initialization of the swarm, specifying a specific interface for the --listen-addr parameter."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then
$netbin -lnt | grep -e '\[::]:2377 ' -e ':::2377' -e '*:2377 ' -e ' 0\.0\.0\.0:2377 ' >/dev/null 2>&1
if [ $? -eq 1 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_3() {
local id="7.3"
local desc="Ensure that all Docker swarm overlay networks are encrypted (Automated)"
local remediation="You should create overlay networks the with --opt encrypted flag."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
unencrypted_networks=""
for encnet in $(docker network ls --filter driver=overlay --quiet); do
if docker network inspect --format '{{.Name}} {{ .Options }}' "$encnet" | \
grep -v 'encrypted:' 2>/dev/null 1>&2; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn -s "$check"
fail=1
fi
warn " * Unencrypted overlay network: $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")"
unencrypted_networks="$unencrypted_networks $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")"
fi
done
# We went through all the networks and found none that are unencrypted
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
logcheckresult "WARN" "Unencrypted overlay networks:" "$unencrypted_networks"
}
check_7_4() {
local id="7.4"
local desc="Ensure that Docker's secret management commands are used for managing secrets in a swarm cluster (Manual)"
local remediation="You should follow the docker secret documentation and use it to manage secrets effectively."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
if [ "$(docker secret ls -q | wc -l)" -ge 1 ]; then
pass -c "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
logcheckresult "INFO"
return
fi
pass -c "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_5() {
local id="7.5"
local desc="Ensure that swarm manager is run in auto-lock mode (Automated)"
local remediation="If you are initializing a swarm, use the command: docker swarm init --autolock. If you want to set --autolock on an existing swarm manager node, use the command: docker swarm update --autolock."
local remediationImpact="A swarm in auto-lock mode will not recover from a restart without manual intervention from an administrator to enter the unlock key. This may not always be desirable, and should be reviewed at a policy level."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
if ! docker swarm unlock-key 2>/dev/null | grep 'SWMKEY' 2>/dev/null 1>&2; then
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
return
fi
pass -s "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_6() {
local id="7.6"
local desc="Ensure that the swarm manager auto-lock key is rotated periodically (Manual)"
local remediation="You should run the command docker swarm unlock-key --rotate to rotate the keys. To facilitate auditing of this recommendation, you should maintain key rotation records and ensure that you establish a pre-defined frequency for key rotation."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
note -c "$check"
logcheckresult "NOTE"
return
fi
pass -c "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_7() {
local id="7.7"
local desc="Ensure that node certificates are rotated as appropriate (Manual)"
local remediation="You should run the command docker swarm update --cert-expiry 48h to set the desired expiry time on the node certificate."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
if docker info 2>/dev/null | grep "Expiry Duration: 2 days"; then
pass -c "$check"
logcheckresult "PASS"
return
fi
info -c "$check"
logcheckresult "INFO"
return
fi
pass -c "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_8() {
local id="7.8"
local desc="Ensure that CA certificates are rotated as appropriate (Manual)"
local remediation="You should run the command docker swarm ca --rotate to rotate a certificate."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
info -c "$check"
logcheckresult "INFO"
return
fi
pass -c "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_9() {
local id="7.9"
local desc="Ensure that management plane traffic is separated from data plane traffic (Manual)"
local remediation="You should initialize the swarm with dedicated interfaces for management and data planes respectively. Example: docker swarm init --advertise-addr=192.168.0.1 --data-path-addr=17.1.0.3"
local remediationImpact="This requires two network interfaces per node."
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then
info -c "$check"
logcheckresult "INFO"
return
fi
pass -c "$check (Swarm mode not enabled)"
logcheckresult "PASS"
}
check_7_end() {
endsectionjson
}

View File

@ -0,0 +1,170 @@
#!/bin/bash
check_8() {
logit ""
local id="8"
local desc="Docker Enterprise Configuration"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
check_product_license() {
enterprise_license=1
if docker version | grep -Eqi '^Server.*Community$|Version.*-ce$'; then
info " * Community Engine license, skipping section 8"
enterprise_license=0
fi
}
check_8_1() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1"
local desc="Universal Control Plane Configuration"
local check="$id - $desc"
info "$check"
}
check_8_1_1() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.1"
local desc="Configure the LDAP authentication service (Automated)"
local remediation="You can configure LDAP integration via the UCP Admin Settings UI. LDAP integration can also be enabled via a configuration file"
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_2() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.2"
local desc="Use external certificates (Automated)"
local remediation="You can configure your own certificates for UCP either during installation or after installation via the UCP Admin Settings user interface."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_3() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.3"
local desc="Enforce the use of client certificate bundles for unprivileged users (Not Scored)"
local remediation="Client certificate bundles can be created in one of two ways. User Management UI: UCP Administrators can provision client certificate bundles on behalf of users. Self-Provision: Users with access to the UCP console can create client certificate bundles themselves."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_4() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.4"
local desc="Configure applicable cluster role-based access control policies (Not Scored)"
local remediation="UCP RBAC components can be configured as required via the UCP User Management UI."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_5() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.5"
local desc="Enable signed image enforcement (Automated)"
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_6() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.6"
local desc="Set the Per-User Session Limit to a value of '3' or lower (Automated)"
local remediation="Retrieve a UCP API token. Retrieve and save UCP config. Open the ucp-config.toml file, set the per_user_limit entry under the [auth.sessions] section to a value of 3 or lower, but greater than 0. Update UCP with the new configuration."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_1_7() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.1.7"
local desc="Set the 'Lifetime Minutes' and 'Renewal Threshold Minutes' values to '15' or lower and '0' respectively (Automated)"
local remediation="Retrieve a UCP API token. Retrieve and save UCP config. Open the ucp-config.toml file, set the lifetime_minutes and renewal_threshold_minutes entries under the [auth.sessions] section to values of 15 or lower and 0 respectively. Update UCP with the new configuration."
local remediationImpact="Setting the Lifetime Minutes setting to a value that is too lower would result in users having to constantly re-authenticate to their Docker Enterprise cluster."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_2() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.2"
local desc="Docker Trusted Registry Configuration"
local check="$id - $desc"
info "$check"
}
check_8_2_1() {
if [ "$enterprise_license" -ne 1 ]; then
return
fi
local id="8.2.1"
local desc="Enable image vulnerability scanning (Automated)"
local remediation="You can navigate to DTR Settings UI and select the Security tab to access the image scanning configuration. Select the Enable Scanning slider to enable this functionality."
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
note -c "$check"
logcheckresult "INFO"
}
check_8_end() {
endsectionjson
}

View File

@ -0,0 +1,234 @@
#!/bin/bash
check_c() {
logit ""
local id="99"
local desc="Community contributed checks"
checkHeader="$id - $desc"
info "$checkHeader"
startsectionjson "$id" "$desc"
}
check_c_1() {
local id="C.1"
local desc="This is a example check for a Automated check"
local remediation="This is an example remediation measure for a Automated check"
local remediationImpact="This is an example remediation impact for a Automated check"
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info --format='{{ .Architecture }}' | grep 'x86_64' 2>/dev/null 1>&2; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if docker info --format='{{ .Architecture }}' | grep 'aarch64' 2>/dev/null 1>&2; then
info -c "$check"
logcheckresult "INFO"
return
fi
warn -s "$check"
logcheckresult "WARN"
}
check_c_1_1() {
local id="C.1.1"
local desc="This is a example check for a Manual check"
local remediation="This is an example remediation measure for a Manual check"
local remediationImpact="This is an example remediation impact for a Manual check"
local check="$id - $desc"
starttestjson "$id" "$desc"
if docker info --format='{{ .Architecture }}' | grep 'x86_64' 2>/dev/null 1>&2; then
pass -c "$check"
logcheckresult "PASS"
return
fi
if docker info --format='{{ .Architecture }}' | grep 'aarch64' 2>/dev/null 1>&2; then
info -c "$check"
logcheckresult "INFO"
return
fi
warn -c "$check"
logcheckresult "WARN"
}
check_c_2() {
docker_version=$(docker version | grep -i -A2 '^server' | grep ' Version:' \
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,.' | cut -c 1-4)
local id="C.2"
local desc="Ensure operations on legacy registry (v1) are Disabled"
local remediation="Start docker daemon with --disable-legacy-registry=false flag. Starting with Docker 17.12, support for V1 registries has been removed, and the --disable-legacy-registry flag can no longer be used."
local remediationImpact="Prevents the docker daemon from pull, push, and login operations against v1 registries."
local check="$id - $desc"
starttestjson "$id" "$desc"
if [ "$docker_version" -lt 1712 ]; then
if get_docker_configuration_file_args 'disable-legacy-registry' | grep 'true' >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if get_docker_effective_command_line_args '--disable-legacy-registry' | grep "disable-legacy-registry" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
local desc="$desc (Deprecated)"
local check="$id - $desc"
info -c "$check"
logcheckresult "INFO"
}
check_c_5_3_1() {
local id="C.5.3.1"
local desc="Ensure that CAP_DAC_READ_SEARCH Linux kernel capability is disabled (Automated)"
local remediation="Please refer to https://github.com/cdk-team/CDK/wiki/Exploit:-cap-dac-read-search for PoC."
local remediationImpact=""
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
caps_containers=""
for c in $containers; do
container_caps=$(docker inspect --format 'CapAdd={{ .HostConfig.CapAdd }}' "$c")
caps=$(echo "$container_caps" | tr "[:lower:]" "[:upper:]" | \
sed 's/CAPADD/CapAdd/')
if echo "$caps" | grep -q "DAC_READ_SEARCH"; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn -s "$check"
warn " * CAP_DAC_READ_SEARCH added to $c"
caps_containers="$caps_containers $c"
fail=1
continue
fi
warn " * CAP_DAC_READ_SEARCH added to $c"
caps_containers="$caps_containers $c"
fi
done
# We went through all the containers and found none with extra capabilities
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
logcheckresult "WARN" "CAP_DAC_READ_SEARCH capability added for containers" "$caps_containers"
}
check_c_5_3_2() {
local id="C.5.3.2"
local desc="Ensure that CAP_SYS_MODULE Linux kernel capability is disabled (Automated)"
local remediation="Please refer to https://xcellerator.github.io/posts/docker_escape/ for PoC."
local remediationImpact=""
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
caps_containers=""
for c in $containers; do
container_caps=$(docker inspect --format 'CapAdd={{ .HostConfig.CapAdd }}' "$c")
caps=$(echo "$container_caps" | tr "[:lower:]" "[:upper:]" | \
sed 's/CAPADD/CapAdd/')
if echo "$caps" | grep -q "SYS_MODULE"; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn -s "$check"
warn " * CAP_SYS_MODULE added to $c"
caps_containers="$caps_containers $c"
fail=1
continue
fi
warn " * CAP_SYS_MODULE added to $c"
caps_containers="$caps_containers $c"
fi
done
# We went through all the containers and found none with extra capabilities
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
logcheckresult "WARN" "CAP_SYS_MODULE capability added for containers" "$caps_containers"
}
check_c_5_3_3() {
local id="C.5.3.3"
local desc="Ensure that CAP_SYS_ADMIN Linux kernel capability is disabled (Automated)"
local remediation="Please refer to https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/ for PoC."
local remediationImpact=""
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
caps_containers=""
for c in $containers; do
container_caps=$(docker inspect --format 'CapAdd={{ .HostConfig.CapAdd }}' "$c")
caps=$(echo "$container_caps" | tr "[:lower:]" "[:upper:]" | \
sed 's/CAPADD/CapAdd/')
if echo "$caps" | grep -q "SYS_ADMIN"; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn -s "$check"
warn " * CAP_SYS_ADMIN added to $c"
caps_containers="$caps_containers $c"
fail=1
continue
fi
warn " * CAP_SYS_ADMIN added to $c"
caps_containers="$caps_containers $c"
fi
done
# We went through all the containers and found none with extra capabilities
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
logcheckresult "WARN" "CAP_SYS_ADMIN capability added for containers" "$caps_containers"
}
check_c_5_3_4() {
local id="C.5.3.4"
local desc="Ensure that CAP_SYS_PTRACE Linux kernel capability is disabled (Automated)"
local remediation="Please refer to https://0xn3va.gitbook.io/cheat-sheets/container/escaping/excessive-capabilities#cap_sys_ptrace"
local remediationImpact=""
local check="$id - $desc"
starttestjson "$id" "$desc"
fail=0
caps_containers=""
for c in $containers; do
container_caps=$(docker inspect --format 'CapAdd={{ .HostConfig.CapAdd }}' "$c")
caps=$(echo "$container_caps" | tr "[:lower:]" "[:upper:]" | \
sed 's/CAPADD/CapAdd/')
if echo "$caps" | grep -q "SYS_PTRACE"; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
warn -s "$check"
warn " * CAP_SYS_PTRACE added to $c"
caps_containers="$caps_containers $c"
fail=1
continue
fi
warn " * CAP_SYS_PTRACE added to $c"
caps_containers="$caps_containers $c"
fi
done
# We went through all the containers and found none with extra capabilities
if [ $fail -eq 0 ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
logcheckresult "WARN" "CAP_SYS_PTRACE capability added for containers" "$caps_containers"
}
check_c_end() {
endsectionjson
}