Hello everyone,
first of all, thanks for these controls, this helps alot. Unfortunately I have problems running this profile after upgrading to inspec 2.x.
It seems to be, that every control, which checks the content of a file, fails. After downgrading to inspec 1.51.25 the controls worked fine again.
I ran the control from my local machine (running macOS) against a EC2-Instance via ssh. Here is the command I run:
inspec exec -i ssh_key -t ssh://ubuntu@x.x.x.x spec/webserver --sudo
Output with inspec v2.045/2.1.83
Profile: DevSec Nginx Baseline (nginx-baseline)
Version: 2.0.2
Target: ssh://ubuntu@x.x.x.x:22
× nginx-01: Running worker process as non-privileged user (1 failed)
✔ User www-data should exist
× Parse Config File /etc/nginx/nginx.conf user should eq "www-data"
expected: "www-data"
got: nil
(compared using ==)
✔ Parse Config File /etc/nginx/nginx.conf group should not eq "root"
✔ nginx-02: Check NGINX config file owner, group and permissions.
✔ File /etc/nginx/nginx.conf should be owned by "root"
✔ File /etc/nginx/nginx.conf should be grouped into "root"
✔ File /etc/nginx/nginx.conf should not be readable by others
✔ File /etc/nginx/nginx.conf should not be writable by others
✔ File /etc/nginx/nginx.conf should not be executable by others
✔ nginx-03: Nginx default files
✔ File /etc/nginx/conf.d/default.conf should not be file
✔ File /etc/nginx/sites-enabled/default should not be file
✔ File /etc/nginx/nginx.conf should be file
✔ File /etc/nginx/conf.d/90.hardening.conf should be file
✔ nginx-04: Check for multiple instances
✔ Command ps aux | egrep "nginx: master" | egrep -v "grep" | wc -l stdout should match /^1$/
× nginx-05: Disable server_tokens directive
× Parse Config File /etc/nginx/nginx.conf server_tokens should eq "off"
expected: "off"
got: nil
(compared using ==)
× nginx-06: Prevent buffer overflow attacks (4 failed)
× Parse Config File /etc/nginx/nginx.conf client_body_buffer_size should eq "1k"
expected: "1k"
got: nil
(compared using ==)
× Parse Config File /etc/nginx/nginx.conf client_max_body_size should eq "1k"
expected: "1k"
got: nil
(compared using ==)
× Parse Config File /etc/nginx/conf.d/90.hardening.conf client_header_buffer_size should eq "1k"
expected: "1k"
got: nil
(compared using ==)
× Parse Config File /etc/nginx/conf.d/90.hardening.conf large_client_header_buffers should eq "2 1k"
expected: "2 1k"
got: nil
(compared using ==)
× nginx-07: Control simultaneous connections (2 failed)
× Parse Config File /etc/nginx/conf.d/90.hardening.conf limit_conn_zone should eq "$binary_remote_addr zone=default:10m"
expected: "$binary_remote_addr zone=default:10m"
got: nil
(compared using ==)
× Parse Config File /etc/nginx/conf.d/90.hardening.conf limit_conn should eq "default 5"
expected: "default 5"
got: nil
(compared using ==)
× nginx-08: Prevent clickjacking
× Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Frame-Options SAMEORIGIN"
expected nil to include "X-Frame-Options SAMEORIGIN", but it does not respond to `include?`
× nginx-09: Enable Cross-site scripting filter
× Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-XSS-Protection \"1; mode=block\""
expected nil to include "X-XSS-Protection \"1; mode=block\"", but it does not respond to `include?`
× nginx-10: Disable content-type sniffing
× Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Content-Type-Options nosniff"
expected nil to include "X-Content-Type-Options nosniff", but it does not respond to `include?`
Profile Summary: 3 successful controls, 5 control failures, 0 controls skipped
Test Summary: 12 successful, 5 failures, 0 skipped
inspec v1.51.25:
Profile: DevSec Nginx Baseline (nginx-baseline)
Version: 2.0.2
Target: ssh://ubuntu@x.x.x.x:22
✔ nginx-01: Running worker process as non-privileged user
✔ User www-data should exist
✔ Parse Config File /etc/nginx/nginx.conf user should eq "www-data"
✔ Parse Config File /etc/nginx/nginx.conf group should not eq "root"
✔ nginx-02: Check NGINX config file owner, group and permissions.
✔ File /etc/nginx/nginx.conf should be owned by "root"
✔ File /etc/nginx/nginx.conf should be grouped into "root"
✔ File /etc/nginx/nginx.conf should not be readable by others
✔ File /etc/nginx/nginx.conf should not be writable by others
✔ File /etc/nginx/nginx.conf should not be executable by others
✔ nginx-03: Nginx default files
✔ File /etc/nginx/conf.d/default.conf should not be file
✔ File /etc/nginx/sites-enabled/default should not be file
✔ File /etc/nginx/nginx.conf should be file
✔ File /etc/nginx/conf.d/90.hardening.conf should be file
✔ nginx-04: Check for multiple instances
✔ Command ps aux | egrep "nginx: master" | egrep -v "grep" | wc -l stdout should match /^1$/
✔ nginx-05: Disable server_tokens directive
✔ Parse Config File /etc/nginx/nginx.conf server_tokens should eq "off"
✔ nginx-08: Prevent clickjacking
✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Frame-Options SAMEORIGIN"
✔ nginx-09: Enable Cross-site scripting filter
✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-XSS-Protection \"1; mode=block\""
✔ nginx-10: Disable content-type sniffing
✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Content-Type-Options nosniff"
Profile Summary: 8 successful controls, 0 control failures, 0 controls skipped
Test Summary: 17 successful, 0 failures, 0 skipped
Anyone an idea, what's going on here?
Hello everyone,
first of all, thanks for these controls, this helps alot. Unfortunately I have problems running this profile after upgrading to inspec 2.x.
It seems to be, that every control, which checks the content of a file, fails. After downgrading to inspec 1.51.25 the controls worked fine again.
I ran the control from my local machine (running macOS) against a EC2-Instance via ssh. Here is the command I run:
inspec exec -i ssh_key -t ssh://ubuntu@x.x.x.x spec/webserver --sudoOutput with inspec v2.045/2.1.83
Profile: DevSec Nginx Baseline (nginx-baseline) Version: 2.0.2 Target: ssh://ubuntu@x.x.x.x:22 × nginx-01: Running worker process as non-privileged user (1 failed) ✔ User www-data should exist × Parse Config File /etc/nginx/nginx.conf user should eq "www-data" expected: "www-data" got: nil (compared using ==) ✔ Parse Config File /etc/nginx/nginx.conf group should not eq "root" ✔ nginx-02: Check NGINX config file owner, group and permissions. ✔ File /etc/nginx/nginx.conf should be owned by "root" ✔ File /etc/nginx/nginx.conf should be grouped into "root" ✔ File /etc/nginx/nginx.conf should not be readable by others ✔ File /etc/nginx/nginx.conf should not be writable by others ✔ File /etc/nginx/nginx.conf should not be executable by others ✔ nginx-03: Nginx default files ✔ File /etc/nginx/conf.d/default.conf should not be file ✔ File /etc/nginx/sites-enabled/default should not be file ✔ File /etc/nginx/nginx.conf should be file ✔ File /etc/nginx/conf.d/90.hardening.conf should be file ✔ nginx-04: Check for multiple instances ✔ Command ps aux | egrep "nginx: master" | egrep -v "grep" | wc -l stdout should match /^1$/ × nginx-05: Disable server_tokens directive × Parse Config File /etc/nginx/nginx.conf server_tokens should eq "off" expected: "off" got: nil (compared using ==) × nginx-06: Prevent buffer overflow attacks (4 failed) × Parse Config File /etc/nginx/nginx.conf client_body_buffer_size should eq "1k" expected: "1k" got: nil (compared using ==) × Parse Config File /etc/nginx/nginx.conf client_max_body_size should eq "1k" expected: "1k" got: nil (compared using ==) × Parse Config File /etc/nginx/conf.d/90.hardening.conf client_header_buffer_size should eq "1k" expected: "1k" got: nil (compared using ==) × Parse Config File /etc/nginx/conf.d/90.hardening.conf large_client_header_buffers should eq "2 1k" expected: "2 1k" got: nil (compared using ==) × nginx-07: Control simultaneous connections (2 failed) × Parse Config File /etc/nginx/conf.d/90.hardening.conf limit_conn_zone should eq "$binary_remote_addr zone=default:10m" expected: "$binary_remote_addr zone=default:10m" got: nil (compared using ==) × Parse Config File /etc/nginx/conf.d/90.hardening.conf limit_conn should eq "default 5" expected: "default 5" got: nil (compared using ==) × nginx-08: Prevent clickjacking × Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Frame-Options SAMEORIGIN" expected nil to include "X-Frame-Options SAMEORIGIN", but it does not respond to `include?` × nginx-09: Enable Cross-site scripting filter × Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-XSS-Protection \"1; mode=block\"" expected nil to include "X-XSS-Protection \"1; mode=block\"", but it does not respond to `include?` × nginx-10: Disable content-type sniffing × Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Content-Type-Options nosniff" expected nil to include "X-Content-Type-Options nosniff", but it does not respond to `include?` Profile Summary: 3 successful controls, 5 control failures, 0 controls skipped Test Summary: 12 successful, 5 failures, 0 skippedinspec v1.51.25:
Profile: DevSec Nginx Baseline (nginx-baseline) Version: 2.0.2 Target: ssh://ubuntu@x.x.x.x:22 ✔ nginx-01: Running worker process as non-privileged user ✔ User www-data should exist ✔ Parse Config File /etc/nginx/nginx.conf user should eq "www-data" ✔ Parse Config File /etc/nginx/nginx.conf group should not eq "root" ✔ nginx-02: Check NGINX config file owner, group and permissions. ✔ File /etc/nginx/nginx.conf should be owned by "root" ✔ File /etc/nginx/nginx.conf should be grouped into "root" ✔ File /etc/nginx/nginx.conf should not be readable by others ✔ File /etc/nginx/nginx.conf should not be writable by others ✔ File /etc/nginx/nginx.conf should not be executable by others ✔ nginx-03: Nginx default files ✔ File /etc/nginx/conf.d/default.conf should not be file ✔ File /etc/nginx/sites-enabled/default should not be file ✔ File /etc/nginx/nginx.conf should be file ✔ File /etc/nginx/conf.d/90.hardening.conf should be file ✔ nginx-04: Check for multiple instances ✔ Command ps aux | egrep "nginx: master" | egrep -v "grep" | wc -l stdout should match /^1$/ ✔ nginx-05: Disable server_tokens directive ✔ Parse Config File /etc/nginx/nginx.conf server_tokens should eq "off" ✔ nginx-08: Prevent clickjacking ✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Frame-Options SAMEORIGIN" ✔ nginx-09: Enable Cross-site scripting filter ✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-XSS-Protection \"1; mode=block\"" ✔ nginx-10: Disable content-type sniffing ✔ Parse Config File /etc/nginx/conf.d/90.hardening.conf add_header should include "X-Content-Type-Options nosniff" Profile Summary: 8 successful controls, 0 control failures, 0 controls skipped Test Summary: 17 successful, 0 failures, 0 skippedAnyone an idea, what's going on here?