SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Prescriptive System Security with
Chef InSpec
Mandi Walls | mandi@chef.io | All Things Open 2019
HI!
• Mandi Walls
• Technical Community Manager for Chef
• mandi@chef.io
• @lnxchk
• 3394 2531 4190
• https://www.chef.io/
• https://www.inspec.io/
EVERY business is a software business
We’re going to be a software
company with airplanes.
– CIO, Alaska Airlines
https://www.darkreading.com/attacks-breaches/wannacry-forces-honda-to-take-production-plant-offline-/d/d-id/1329192
https://www.datacenterknowledge.com/archives/2016/10/19/botched-server-install-results-in-2-14-million-hipaa-breach-fine
Different Sources for the Same Goals
Chef InSpec
• Human-readable language for tests related to security and compliance
• Create, share, and reuse complex profiles
• Extensible language - build your own rules
• Command-line tools plug into your existing workflow, build, deploy
• Test early, test often!
• InSpec is an open source project with commercialized distribution
The Community distribution is part of the CINC project
https://gitlab.com/cinc-project/auditor
Create and Consume
• Complex compliance requirements can slow you down
• Different information and expertise live in different teams, but
need to be used by many
• Security and compliance personnel can work with operations
and development to create comprehensive profiles
Chef InSpec is Code
• Check it into repos, publish as artifacts
• Include InSpec steps before code checkin
• Include InSpec steps in integration and pre-production
• Continue InSpec checks in production to guard against new
threats
Network Services
• If your security team sends you a directive:
Ensure that no legacy network services
are installed on all versions of Linux,
including inetd, xinetd, telnet, rsh, tftp,
and ypserv.
How Do You Go About Checking and Fixing?
• Identify the package names on your systems
• Remove all packages
• Does someone fix your source images?
Rebuild?
Remediate at launch?
• Ensure it doesn't get re-installed by accident at some point in the
future
Check for inetd and xinetd
control 'package-01' do
impact 1.0
title 'Do not run deprecated inetd or xinetd'
desc 'rhel5-guide-i731.pdf, Chapter 3.2.1'
describe package('inetd') do
it { should_not be_installed }
end
describe package('xinetd') do
it { should_not be_installed }
end
end
Lifecycle – How Often Do You Check Security?
• Single big scan, report mailed out with a “due date”?
Considered done, not checked again
• Yearly or twice-yearly massive scans with remediation firedrills?
Common audit cycles, large projects around fixing found issues
• Part of the software development lifecycle?
“To the left”
Regularly part of what is included in builds
Test Regularly with Chef InSpec
• Use InSpec before code checkin
No changes to allowed services
• Use InSpec during integration testing
Check transport protocols, port numbers, service configurations
• Use InSpec in production
Ensure no drift occurs in approved configurations over application
lifetime
Chef InSpec Components
• Resources
• Resource Characteristics
• Profiles
• Command Line Interface
Resources
• Chef InSpec includes built-in resources for common services,
system files, and configurations
• Built-in resources work on several platforms of Linux.
There are also Windows-specifics like registry_key
• A resource has characteristics that can be verified for your
requirements, and Matchers that work with those characteristics
Sample Resources
• System resources:
directory, file, user, group, crontab, service, package
• Specific services:
apache, nginx, rabbitmq, postgresql, IIS
• Programming language components:
gem, npm, powershell
• Network services:
port, http, sshd
• https://www.inspec.io/docs/reference/resources/
Advanced Resources – Cloud Components
• Added as libraries to your InSpec install
• AWS – aws_ec2_instance, aws_eks_cluster, aws_elb,
aws_iam_role, aws_s3_bucket
https://github.com/inspec/inspec-aws
• GCP – google_compute_*, google_container_clusters,
google_project
https://github.com/inspec/inspec-gcp
• Azure – azurerm_key_vaults,
azurerm_network_security_group, azurerm_virtual_machine
https://github.com/inspec/inspec-azure
Characteristic Tests
• it { should exist } – files, directories, groups that are present
• it { should be_installed } – packages that should be installed
• it { should be_enabled } – services that should be running
• its('max_log_file') { should cmp 6 } – rotate auditd logs
Check inside a config file for a specific setting
• its('exit_status') { should eq 0 } – run any arbitrary checks
Remediation scripts from upstream and OS vendors often come as shell
Run Chef InSpec
• InSpec is command line
Installs on your workstation as a ruby gem or as part of the
ChefWorkstation
• Can be run locally, to test the machine it is executing on
• Or remotely
InSpec will log into the target and run the tests for you
Execute InSpec
$ inspec exec ./test.rb
Profile: tests from ./test.rb
Version: (not specified)
Target: local://
File /tmp
✔ should exist
✔ should be directory
✔ should be owned by "root"
✔ mode should cmp == "01777"
Test Summary: 4 successful, 0 failures, 0 skipped
Test Any Target
Local: inspec exec test.rb
SSH Remote: inspec exec test.rb -i ~/.aws/mandi_eu.pem -t
ssh://ec2-user@54.152.7.203
WinRM: inspec exec test.rb -t winrm://Admin@192.168.1.2 --
password super
Docker Container: inspec exec test.rb -t docker://3dda08e75838
Profiles
• Collections of InSpec tests
Group by team, by application, by platform
• Each profile can have multiple test files included
• Flexible!
Create your own profiles for specific software you use
Use included matcher libraries or write your own – they live in the
profile
• https://dev-sec.io/ for samples
Sample Profile: linux-baseline
control 'os-02' do
impact 1.0
title 'Check owner and permissions for /etc/shadow'
desc 'Check periodically the owner and permissions for /etc/shadow'
describe file('/etc/shadow') do
it { should exist }
it { should be_file }
it { should be_owned_by 'root' }
its('group') { should eq shadow_group }
it { should_not be_executable }
it { should be_writable.by('owner') }
...
Demo
• Basic off-the-shelf CentOS system on AWS
• Install ChefWorkstation and git
• Download and run the linux-baseline profile
• Remediate with the corresponding Chef cookbook from
https://dev-sec.io
Resources
• https://inspec.io
• https://blog.chef.io/category/inspec
• https://learn.chef.io/
• http://www.anniehedgie.com/inspec-basics-1
• Whitepaper featuring Danske Bank:
https://www.chef.io/customers/danske-bank/
• Community Distros https://gitlab.com/cinc-project
• Join us on Slack: http://community-slack.chef.io/
Appendix: Demo Outputs
Select CentOS 7 from the Marketplace
• Use a small instance - .micro should be fine for this
• Tag X-Contact with your name and X-Customer with something like "InSpec Talk
Delete after 7/15/19" or similar
Security Group
• I use the default all-open security group, as there's nothing running but ssh on
this machine. If you have another security group that is more locked down, that's
fine, too.
Installs
• Install ChefWorkstation from https://downloads.chef.io/chef-workstation/
curl –o cw.rpm <url>
sudo yum install -y cw.rpm
• Install git via yum
sudo yum install -y git
Demo stage 1 – Detect with the linux-baseline profile
git clone https://github.com/dev-sec/linux-baseline.git
sudo inspec exec linux-baseline/
<<accept the product license here>>
You'll have some number of errors; the default installs will always have too
many things installed. This version:
Profile Summary: 26 successful controls, 27 control
failures, 1 control skipped
Test Summary: 80 successful, 45 failures, 1 skipped
Demo Stage 2 – Correct with Chef Infrastructure
Download the Chef cookbook that matches the linux-baseline profile via a
policyfile workflow
chef generate policyfile fix-security
<<accept the license>>
edit fix-security.rb
edit-> run_list 'os-hardening::default'
chef install fix-security.rb
chef export fix-security.rb harden-linux
cd harden-linux
sudo chef-client -z
Correct with Chef con't
...things happening...
Recipe: os-hardening::auditd
* yum_package[audit] action install (up to date)
Running handlers:
Running handlers complete
Chef Infra Client finished, 141/206 resources updated in 07
seconds
Demo Stage 3 – Re-check with InSpec
cd ..
sudo inspec exec linux-baseline
...
Profile Summary: 52 successful controls, 1 control failure, 1
control skipped
Test Summary: 124 successful, 1 failure, 1 skipped
There's almost always at least one failure. Depending on the time you have left,
you can work through the next part, creating a wrapper profile and skipping this
step, or, conversely, if you audience is already chef-aware, adding an additional
recipe to fix whatever it is.
The error in this example:
× package-08: Install auditd (1 failed)
✔ System Package audit should be installed
✔ Audit Daemon Config log_file should cmp == "/var/log/audit/audit.log"
✔ Audit Daemon Config log_format should cmp == "raw"
✔ Audit Daemon Config flush should match
/^incremental|INCREMENTAL|incremental_async|INCREMENTAL_ASYNC$/
× Audit Daemon Config max_log_file_action should cmp == "keep_logs"
expected: "keep_logs"
got: "ROTATE"
(compared using `cmp` matcher)
Demo stage 4 – prepare for Automate with wrapper
profile
• Create a wrapper profile:
inspec init profile my-hardening
• Edit my-hardening/inspec.yml
depends:
- name: linux-baseline
git: https://github.com/dev-sec/linux-baseline
• Remove the example
rm -f my-hardening/controls/example.rb
Stage 4
Create a new control file:
$ vi my-hardening/controls/skip-auditd.rb
include_controls 'linux-baseline' do
skip_control 'package-08'
end
Demo Stage 5 – run the wrapper profile
sudo inspec exec my-hardening
...
Profile Summary: 52 successful controls, 0 control failures, 1
control skipped
Test Summary: 113 successful, 0 failures, 1 skipped
Additional Note - --no-distinct-exit
When using InSpec in a build process that relies on non-zero return codes, any
intentionally skipped control will generate a return code of 101
$ sudo inspec exec my-hardening/
...
$ echo $?
101
If you want skips to generate 0 so the flow continues, use the flag --no-distinct-exit
sudo inspec exec my-hardening/ --no-distinct-exit
...
$ echo $?
0
Exit Codes For InSpec in Pipelines
https://github.com/inspec/inspec/issues/1825#issuecomment-382650911
0 run okay + all passed:
100 run okay + failures
101 run okay + skipped only
Additional discussion around whether to specify in the run output the reason for a
skip is also happening. For example, skipping due to platform, skipping due to not-
needed, skipping due to fix-coming.
Wrapper Profiles

Weitere ähnliche Inhalte

Was ist angesagt?

InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020Mandi Walls
 
InSpec For DevOpsDays Amsterdam 2017
InSpec For DevOpsDays Amsterdam 2017InSpec For DevOpsDays Amsterdam 2017
InSpec For DevOpsDays Amsterdam 2017Mandi Walls
 
Inspec: Turn your compliance, security, and other policy requirements into au...
Inspec: Turn your compliance, security, and other policy requirements into au...Inspec: Turn your compliance, security, and other policy requirements into au...
Inspec: Turn your compliance, security, and other policy requirements into au...Kangaroot
 
InSpec - June 2018 at Open28.be
InSpec - June 2018 at Open28.beInSpec - June 2018 at Open28.be
InSpec - June 2018 at Open28.beMandi Walls
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsNETWAYS
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Mandi Walls
 
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017adamleff
 
InSpec Workshop DevSecCon 2017
InSpec Workshop DevSecCon 2017InSpec Workshop DevSecCon 2017
InSpec Workshop DevSecCon 2017Mandi Walls
 
Compliance as Code
Compliance as CodeCompliance as Code
Compliance as CodeMatt Ray
 
Drupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsDrupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsJohn Smith
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure TestingRanjib Dey
 
Building Security into Your Workflow with InSpec
Building Security into Your Workflow with InSpecBuilding Security into Your Workflow with InSpec
Building Security into Your Workflow with InSpecMandi Walls
 
Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chefkamalikamj
 
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
DevOpsDays Singapore - Continuous Auditing with Compliance as CodeDevOpsDays Singapore - Continuous Auditing with Compliance as Code
DevOpsDays Singapore - Continuous Auditing with Compliance as CodeMatt Ray
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Chef
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
2019 Chef InSpec Jumpstart Part 1 of 2
2019 Chef InSpec Jumpstart Part 1 of 22019 Chef InSpec Jumpstart Part 1 of 2
2019 Chef InSpec Jumpstart Part 1 of 2Larry Eichenbaum
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentDan Stine
 
DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...DevSecCon
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerMandi Walls
 

Was ist angesagt? (20)

InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020
 
InSpec For DevOpsDays Amsterdam 2017
InSpec For DevOpsDays Amsterdam 2017InSpec For DevOpsDays Amsterdam 2017
InSpec For DevOpsDays Amsterdam 2017
 
Inspec: Turn your compliance, security, and other policy requirements into au...
Inspec: Turn your compliance, security, and other policy requirements into au...Inspec: Turn your compliance, security, and other policy requirements into au...
Inspec: Turn your compliance, security, and other policy requirements into au...
 
InSpec - June 2018 at Open28.be
InSpec - June 2018 at Open28.beInSpec - June 2018 at Open28.be
InSpec - June 2018 at Open28.be
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)
 
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
 
InSpec Workshop DevSecCon 2017
InSpec Workshop DevSecCon 2017InSpec Workshop DevSecCon 2017
InSpec Workshop DevSecCon 2017
 
Compliance as Code
Compliance as CodeCompliance as Code
Compliance as Code
 
Drupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsDrupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The Basics
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
 
Building Security into Your Workflow with InSpec
Building Security into Your Workflow with InSpecBuilding Security into Your Workflow with InSpec
Building Security into Your Workflow with InSpec
 
Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chef
 
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
DevOpsDays Singapore - Continuous Auditing with Compliance as CodeDevOpsDays Singapore - Continuous Auditing with Compliance as Code
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
2019 Chef InSpec Jumpstart Part 1 of 2
2019 Chef InSpec Jumpstart Part 1 of 22019 Chef InSpec Jumpstart Part 1 of 2
2019 Chef InSpec Jumpstart Part 1 of 2
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
 
DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 

Ähnlich wie Prescriptive System Security with Chef InSpec

OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecNETWAYS
 
DevOpsDays InSpec Workshop
DevOpsDays InSpec WorkshopDevOpsDays InSpec Workshop
DevOpsDays InSpec WorkshopMandi Walls
 
DevSecCon London 2017: Inspec workshop by Mandi Walls
DevSecCon London 2017: Inspec workshop by Mandi WallsDevSecCon London 2017: Inspec workshop by Mandi Walls
DevSecCon London 2017: Inspec workshop by Mandi WallsDevSecCon
 
InSpec Workshop at Velocity London 2018
InSpec Workshop at Velocity London 2018InSpec Workshop at Velocity London 2018
InSpec Workshop at Velocity London 2018Mandi Walls
 
BuildStuff.LT 2018 InSpec Workshop
BuildStuff.LT 2018 InSpec WorkshopBuildStuff.LT 2018 InSpec Workshop
BuildStuff.LT 2018 InSpec WorkshopMandi Walls
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack SummitMiguel Zuniga
 
Splunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsSplunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsAnthony D Hendricks
 
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?AFUP_Limoges
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityGeoff Harcourt
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateChef
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Amazon Web Services
 
Ingite Slides for InSpec
Ingite Slides for InSpecIngite Slides for InSpec
Ingite Slides for InSpecMandi Walls
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at ScaleKris Buytaert
 
Melbourne Chef Meetup: Automating Azure Compliance with InSpec
Melbourne Chef Meetup: Automating Azure Compliance with InSpecMelbourne Chef Meetup: Automating Azure Compliance with InSpec
Melbourne Chef Meetup: Automating Azure Compliance with InSpecMatt Ray
 
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017AgileNZ Conference
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous IntegrationGeff Henderson Chang
 
Automatize everything
Automatize everythingAutomatize everything
Automatize everythingBoris Bucha
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabAyush Sharma
 

Ähnlich wie Prescriptive System Security with Chef InSpec (20)

OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
 
DevOpsDays InSpec Workshop
DevOpsDays InSpec WorkshopDevOpsDays InSpec Workshop
DevOpsDays InSpec Workshop
 
DevSecCon London 2017: Inspec workshop by Mandi Walls
DevSecCon London 2017: Inspec workshop by Mandi WallsDevSecCon London 2017: Inspec workshop by Mandi Walls
DevSecCon London 2017: Inspec workshop by Mandi Walls
 
InSpec Workshop at Velocity London 2018
InSpec Workshop at Velocity London 2018InSpec Workshop at Velocity London 2018
InSpec Workshop at Velocity London 2018
 
BuildStuff.LT 2018 InSpec Workshop
BuildStuff.LT 2018 InSpec WorkshopBuildStuff.LT 2018 InSpec Workshop
BuildStuff.LT 2018 InSpec Workshop
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
Splunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsSplunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shells
 
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?
Comment amĂŠliorer le quotidien des DĂŠveloppeurs PHP ?
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
Ingite Slides for InSpec
Ingite Slides for InSpecIngite Slides for InSpec
Ingite Slides for InSpec
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
Melbourne Chef Meetup: Automating Azure Compliance with InSpec
Melbourne Chef Meetup: Automating Azure Compliance with InSpecMelbourne Chef Meetup: Automating Azure Compliance with InSpec
Melbourne Chef Meetup: Automating Azure Compliance with InSpec
 
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous Integration
 
Automatize everything
Automatize everythingAutomatize everything
Automatize everything
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 

Mehr von Mandi Walls

DOD Raleigh Gamedays with Chaos Engineering.pdf
DOD Raleigh Gamedays with Chaos Engineering.pdfDOD Raleigh Gamedays with Chaos Engineering.pdf
DOD Raleigh Gamedays with Chaos Engineering.pdfMandi Walls
 
Addo reducing trauma in organizations with SLOs and chaos engineering
Addo  reducing trauma in organizations with SLOs and chaos engineeringAddo  reducing trauma in organizations with SLOs and chaos engineering
Addo reducing trauma in organizations with SLOs and chaos engineeringMandi Walls
 
Full Service Ownership
Full Service OwnershipFull Service Ownership
Full Service OwnershipMandi Walls
 
PagerDuty: Best Practices for On Call Teams
PagerDuty: Best Practices for On Call TeamsPagerDuty: Best Practices for On Call Teams
PagerDuty: Best Practices for On Call TeamsMandi Walls
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Mandi Walls
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker budMandi Walls
 
Habitat at LinuxLab IT
Habitat at LinuxLab ITHabitat at LinuxLab IT
Habitat at LinuxLab ITMandi Walls
 
Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017Mandi Walls
 
Habitat at SRECon
Habitat at SREConHabitat at SRECon
Habitat at SREConMandi Walls
 
Containerdays Intro to Habitat
Containerdays Intro to HabitatContainerdays Intro to Habitat
Containerdays Intro to HabitatMandi Walls
 
Configuration Management is Old and Boring
Configuration Management is Old and BoringConfiguration Management is Old and Boring
Configuration Management is Old and BoringMandi Walls
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat OverviewMandi Walls
 
Lessons Learned From Cloud Migrations
Lessons Learned From Cloud MigrationsLessons Learned From Cloud Migrations
Lessons Learned From Cloud MigrationsMandi Walls
 
Lessons Learned from Continuous Delivery
Lessons Learned from Continuous DeliveryLessons Learned from Continuous Delivery
Lessons Learned from Continuous DeliveryMandi Walls
 
Community in a box
Community in a boxCommunity in a box
Community in a boxMandi Walls
 
Role of Pipelines in Continuous Delivery
Role of Pipelines in Continuous DeliveryRole of Pipelines in Continuous Delivery
Role of Pipelines in Continuous DeliveryMandi Walls
 

Mehr von Mandi Walls (16)

DOD Raleigh Gamedays with Chaos Engineering.pdf
DOD Raleigh Gamedays with Chaos Engineering.pdfDOD Raleigh Gamedays with Chaos Engineering.pdf
DOD Raleigh Gamedays with Chaos Engineering.pdf
 
Addo reducing trauma in organizations with SLOs and chaos engineering
Addo  reducing trauma in organizations with SLOs and chaos engineeringAddo  reducing trauma in organizations with SLOs and chaos engineering
Addo reducing trauma in organizations with SLOs and chaos engineering
 
Full Service Ownership
Full Service OwnershipFull Service Ownership
Full Service Ownership
 
PagerDuty: Best Practices for On Call Teams
PagerDuty: Best Practices for On Call TeamsPagerDuty: Best Practices for On Call Teams
PagerDuty: Best Practices for On Call Teams
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker bud
 
Habitat at LinuxLab IT
Habitat at LinuxLab ITHabitat at LinuxLab IT
Habitat at LinuxLab IT
 
Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017
 
Habitat at SRECon
Habitat at SREConHabitat at SRECon
Habitat at SRECon
 
Containerdays Intro to Habitat
Containerdays Intro to HabitatContainerdays Intro to Habitat
Containerdays Intro to Habitat
 
Configuration Management is Old and Boring
Configuration Management is Old and BoringConfiguration Management is Old and Boring
Configuration Management is Old and Boring
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat Overview
 
Lessons Learned From Cloud Migrations
Lessons Learned From Cloud MigrationsLessons Learned From Cloud Migrations
Lessons Learned From Cloud Migrations
 
Lessons Learned from Continuous Delivery
Lessons Learned from Continuous DeliveryLessons Learned from Continuous Delivery
Lessons Learned from Continuous Delivery
 
Community in a box
Community in a boxCommunity in a box
Community in a box
 
Role of Pipelines in Continuous Delivery
Role of Pipelines in Continuous DeliveryRole of Pipelines in Continuous Delivery
Role of Pipelines in Continuous Delivery
 

KĂźrzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

KĂźrzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Prescriptive System Security with Chef InSpec

  • 1. Prescriptive System Security with Chef InSpec Mandi Walls | mandi@chef.io | All Things Open 2019
  • 2. HI! • Mandi Walls • Technical Community Manager for Chef • mandi@chef.io • @lnxchk • 3394 2531 4190 • https://www.chef.io/ • https://www.inspec.io/
  • 3. EVERY business is a software business We’re going to be a software company with airplanes. – CIO, Alaska Airlines
  • 6. Different Sources for the Same Goals
  • 7.
  • 8. Chef InSpec • Human-readable language for tests related to security and compliance • Create, share, and reuse complex profiles • Extensible language - build your own rules • Command-line tools plug into your existing workflow, build, deploy • Test early, test often! • InSpec is an open source project with commercialized distribution The Community distribution is part of the CINC project https://gitlab.com/cinc-project/auditor
  • 9. Create and Consume • Complex compliance requirements can slow you down • Different information and expertise live in different teams, but need to be used by many • Security and compliance personnel can work with operations and development to create comprehensive profiles
  • 10. Chef InSpec is Code • Check it into repos, publish as artifacts • Include InSpec steps before code checkin • Include InSpec steps in integration and pre-production • Continue InSpec checks in production to guard against new threats
  • 11. Network Services • If your security team sends you a directive: Ensure that no legacy network services are installed on all versions of Linux, including inetd, xinetd, telnet, rsh, tftp, and ypserv.
  • 12. How Do You Go About Checking and Fixing? • Identify the package names on your systems • Remove all packages • Does someone fix your source images? Rebuild? Remediate at launch? • Ensure it doesn't get re-installed by accident at some point in the future
  • 13. Check for inetd and xinetd control 'package-01' do impact 1.0 title 'Do not run deprecated inetd or xinetd' desc 'rhel5-guide-i731.pdf, Chapter 3.2.1' describe package('inetd') do it { should_not be_installed } end describe package('xinetd') do it { should_not be_installed } end end
  • 14. Lifecycle – How Often Do You Check Security? • Single big scan, report mailed out with a “due date”? Considered done, not checked again • Yearly or twice-yearly massive scans with remediation firedrills? Common audit cycles, large projects around fixing found issues • Part of the software development lifecycle? “To the left” Regularly part of what is included in builds
  • 15. Test Regularly with Chef InSpec • Use InSpec before code checkin No changes to allowed services • Use InSpec during integration testing Check transport protocols, port numbers, service configurations • Use InSpec in production Ensure no drift occurs in approved configurations over application lifetime
  • 16. Chef InSpec Components • Resources • Resource Characteristics • Profiles • Command Line Interface
  • 17. Resources • Chef InSpec includes built-in resources for common services, system files, and configurations • Built-in resources work on several platforms of Linux. There are also Windows-specifics like registry_key • A resource has characteristics that can be verified for your requirements, and Matchers that work with those characteristics
  • 18. Sample Resources • System resources: directory, file, user, group, crontab, service, package • Specific services: apache, nginx, rabbitmq, postgresql, IIS • Programming language components: gem, npm, powershell • Network services: port, http, sshd • https://www.inspec.io/docs/reference/resources/
  • 19. Advanced Resources – Cloud Components • Added as libraries to your InSpec install • AWS – aws_ec2_instance, aws_eks_cluster, aws_elb, aws_iam_role, aws_s3_bucket https://github.com/inspec/inspec-aws • GCP – google_compute_*, google_container_clusters, google_project https://github.com/inspec/inspec-gcp • Azure – azurerm_key_vaults, azurerm_network_security_group, azurerm_virtual_machine https://github.com/inspec/inspec-azure
  • 20. Characteristic Tests • it { should exist } – files, directories, groups that are present • it { should be_installed } – packages that should be installed • it { should be_enabled } – services that should be running • its('max_log_file') { should cmp 6 } – rotate auditd logs Check inside a config file for a specific setting • its('exit_status') { should eq 0 } – run any arbitrary checks Remediation scripts from upstream and OS vendors often come as shell
  • 21. Run Chef InSpec • InSpec is command line Installs on your workstation as a ruby gem or as part of the ChefWorkstation • Can be run locally, to test the machine it is executing on • Or remotely InSpec will log into the target and run the tests for you
  • 22. Execute InSpec $ inspec exec ./test.rb Profile: tests from ./test.rb Version: (not specified) Target: local:// File /tmp ✔ should exist ✔ should be directory ✔ should be owned by "root" ✔ mode should cmp == "01777" Test Summary: 4 successful, 0 failures, 0 skipped
  • 23. Test Any Target Local: inspec exec test.rb SSH Remote: inspec exec test.rb -i ~/.aws/mandi_eu.pem -t ssh://ec2-user@54.152.7.203 WinRM: inspec exec test.rb -t winrm://Admin@192.168.1.2 -- password super Docker Container: inspec exec test.rb -t docker://3dda08e75838
  • 24. Profiles • Collections of InSpec tests Group by team, by application, by platform • Each profile can have multiple test files included • Flexible! Create your own profiles for specific software you use Use included matcher libraries or write your own – they live in the profile • https://dev-sec.io/ for samples
  • 25. Sample Profile: linux-baseline control 'os-02' do impact 1.0 title 'Check owner and permissions for /etc/shadow' desc 'Check periodically the owner and permissions for /etc/shadow' describe file('/etc/shadow') do it { should exist } it { should be_file } it { should be_owned_by 'root' } its('group') { should eq shadow_group } it { should_not be_executable } it { should be_writable.by('owner') } ...
  • 26. Demo • Basic off-the-shelf CentOS system on AWS • Install ChefWorkstation and git • Download and run the linux-baseline profile • Remediate with the corresponding Chef cookbook from https://dev-sec.io
  • 27. Resources • https://inspec.io • https://blog.chef.io/category/inspec • https://learn.chef.io/ • http://www.anniehedgie.com/inspec-basics-1 • Whitepaper featuring Danske Bank: https://www.chef.io/customers/danske-bank/ • Community Distros https://gitlab.com/cinc-project • Join us on Slack: http://community-slack.chef.io/
  • 28.
  • 30. Select CentOS 7 from the Marketplace • Use a small instance - .micro should be fine for this • Tag X-Contact with your name and X-Customer with something like "InSpec Talk Delete after 7/15/19" or similar
  • 31. Security Group • I use the default all-open security group, as there's nothing running but ssh on this machine. If you have another security group that is more locked down, that's fine, too.
  • 32. Installs • Install ChefWorkstation from https://downloads.chef.io/chef-workstation/ curl –o cw.rpm <url> sudo yum install -y cw.rpm • Install git via yum sudo yum install -y git
  • 33. Demo stage 1 – Detect with the linux-baseline profile git clone https://github.com/dev-sec/linux-baseline.git sudo inspec exec linux-baseline/ <<accept the product license here>> You'll have some number of errors; the default installs will always have too many things installed. This version: Profile Summary: 26 successful controls, 27 control failures, 1 control skipped Test Summary: 80 successful, 45 failures, 1 skipped
  • 34. Demo Stage 2 – Correct with Chef Infrastructure Download the Chef cookbook that matches the linux-baseline profile via a policyfile workflow chef generate policyfile fix-security <<accept the license>> edit fix-security.rb edit-> run_list 'os-hardening::default' chef install fix-security.rb chef export fix-security.rb harden-linux cd harden-linux sudo chef-client -z
  • 35. Correct with Chef con't ...things happening... Recipe: os-hardening::auditd * yum_package[audit] action install (up to date) Running handlers: Running handlers complete Chef Infra Client finished, 141/206 resources updated in 07 seconds
  • 36. Demo Stage 3 – Re-check with InSpec cd .. sudo inspec exec linux-baseline ... Profile Summary: 52 successful controls, 1 control failure, 1 control skipped Test Summary: 124 successful, 1 failure, 1 skipped There's almost always at least one failure. Depending on the time you have left, you can work through the next part, creating a wrapper profile and skipping this step, or, conversely, if you audience is already chef-aware, adding an additional recipe to fix whatever it is.
  • 37. The error in this example: × package-08: Install auditd (1 failed) ✔ System Package audit should be installed ✔ Audit Daemon Config log_file should cmp == "/var/log/audit/audit.log" ✔ Audit Daemon Config log_format should cmp == "raw" ✔ Audit Daemon Config flush should match /^incremental|INCREMENTAL|incremental_async|INCREMENTAL_ASYNC$/ × Audit Daemon Config max_log_file_action should cmp == "keep_logs" expected: "keep_logs" got: "ROTATE" (compared using `cmp` matcher)
  • 38. Demo stage 4 – prepare for Automate with wrapper profile • Create a wrapper profile: inspec init profile my-hardening • Edit my-hardening/inspec.yml depends: - name: linux-baseline git: https://github.com/dev-sec/linux-baseline • Remove the example rm -f my-hardening/controls/example.rb
  • 39. Stage 4 Create a new control file: $ vi my-hardening/controls/skip-auditd.rb include_controls 'linux-baseline' do skip_control 'package-08' end
  • 40. Demo Stage 5 – run the wrapper profile sudo inspec exec my-hardening ... Profile Summary: 52 successful controls, 0 control failures, 1 control skipped Test Summary: 113 successful, 0 failures, 1 skipped
  • 41. Additional Note - --no-distinct-exit When using InSpec in a build process that relies on non-zero return codes, any intentionally skipped control will generate a return code of 101 $ sudo inspec exec my-hardening/ ... $ echo $? 101 If you want skips to generate 0 so the flow continues, use the flag --no-distinct-exit sudo inspec exec my-hardening/ --no-distinct-exit ... $ echo $? 0
  • 42. Exit Codes For InSpec in Pipelines https://github.com/inspec/inspec/issues/1825#issuecomment-382650911 0 run okay + all passed: 100 run okay + failures 101 run okay + skipped only Additional discussion around whether to specify in the run output the reason for a skip is also happening. For example, skipping due to platform, skipping due to not- needed, skipping due to fix-coming.

Hinweis der Redaktion

  1. Honda shut down an automobile production plant because of WannaCry. This story is particularly interesting in an InSpec context not just because of the presence of a virus that had remediation available from the upstream vendor, but further down in the story it talks about coordinating the needs of several teams – IT and plant automation, for example – who have different needs, risk profiles, and resources available to work on something like WannaCry. It still has to be dealt with; this is real money coming off the line that is being disrupted by security shortcomings. Text of article: In an example of just how persistent modern cyberthreats can be, automaker Honda Motors had to temporarily stop production at its Sayama plant in Japan this week after being hit by WannaCry, a malware threat the company thought it had mitigated just one month ago. The nearly 48-hour shutdown impacted production of about 1,000 vehicles at the facility, which does engine production and assembly for a line of vehicles including the Odyssey minivan and the Accord. A statement from Honda North America said the interruption at the Sayama Auto Plant was caused by the shutdown of several older production-line computers infected with the WannaCry virus. Systems at multiple Honda plants in Asia, North America, Europe, and China were found similarly infected with WannaCry, according to a different Honda statement quoted by Reuters and other outlets. WannaCry infected hundreds of thousands of computers worldwide last month using a Windows exploit dubbed EternalBlue that the US National Security Agency (NSA) originally developed for use against adversaries. Threat group Shadow Brokers publicly leaked the exploit earlier this year. Honda has not said if the infection only impacted its industrial control system (ICS) network or its IT network as well, or both. Neither has the automaker so far explained why it decided to shut down operations only in Sayama and not at any of the other locations where WannaCry was reportedly spotted. Honda first discovered the outbreak Sunday and began recovery work immediately. But it wasn't until Tuesday morning that the company resumed production at Sayama. The infection occured despite Honda's implementation of new measures to mitigate WannaCry when news of the malware first broke. But Honda's efforts apparently were insufficient for several older computers installed at the Sayama Honda plant, some media outlets have quoted the company as saying. The incident highlights how difficult it is for large organizations to secure every system on their network, especially against self-propagating malware such as WannaCry, says Paul Norris, senior systems engineer at Tripwire. "Organizations will generally secure the systems they know about," he says. "But most will have assets that are not managed or secured and are old legacy systems that haven’t been decommissioned," and remain vulnerable, Norris says.   "It's harder for larger organizations to secure every asset within their environment, due to the size and complexity of corporate networks," he says. The challenges are exacerbated in an industrial control system environment where IT and cybersecurity organizations often have little visibility into all the assets that might be in place. In fact, up to 80% of all cyber assets in a plant can sometimes be invisible to cybersecurity personnel and often there is an incomplete inventory of IT-based assets as well, making them hard to protect, says David Zahn, general manager at ICS security vendor PAS. "If you can't see it, you can't protect it," he says. It is possible also that Honda may have known about the underlying vulnerabilities to WannaCry in its plant floor environment but decided not to patch right away because it did not want to disrupt operations. "Risk mitigation within an industrial process facility moves at industry pace – not hacker speed," Zahn says. Hopefully, incidents such as this will prompt organizations into answering basic cybersecurity questions for plant environments, he notes. "What are my cyber assets, where are my vulnerabilities, did an unauthorized change occur, and can I recover quickly if the worst case scenario happens." More details are needed to know how Honda got breached. But the incident shows the need for organizations to pay more attention to securing plant floors against cybersecurity threats, adds John Bambenek, threat intelligence manager at Fidelis Cybersecurity. "Large organizations have devices in low security environments that are necessary for their operations and in many cases, rely on factory employees not take actions that undermine the security of those environments," Bambanek says. That is a mistake, he adds. "These attacks can cause real impact and a factory not producing parts for a day has a large monetary impact to the organization."
  2. A second example of lax security resulting in real dollars being lost Text of article: A Catholic health care system has agreed to pay $2.14 million to settle claims it failed to change the default settings after installing new server, allowing public access to the private health records of 31,800 patients. St. Joseph Health – which operates hospitals, community clinics, nursing facilities and provides a range of other health care services – agreed it was in potential violation of security rules of the Health Insurance Portability and Accountability Act (HIPAA). The U.S. Department of Health and Human Services’ Office of Civil Rights (OCR) opened an investigation on Feb. 14, 2012, after St. Joseph Health reported that files containing electronic protected health information had been publicly accessible via Google and other browsers during the entire preceding year. “The server SJH purchased to store the files included a file sharing application whose default settings allowed anyone with an Internet connection to access them,” OCR said in an Oct. 17 statement announcing the settlement. “Upon implementation of this server and the file sharing application, SJH did not examine or modify it,” the statement continued. “As a result, the public had unrestricted access to PDF files containing the ePHI of 31,800 individuals, including patient names, health statuses, diagnoses, and demographic information.” See also: Merger of Two Healthcare Giants Makes IT Transformation Inevitable Federal investigators determined the health care nonprofit failed to coduct a thorough evaluation of the environmental and operational implications of installing the new server. Also, multiple contractors hired by St. Joseph to assess risks and vulnerabilities of ePHI were brought on in a patchwork fashion that did not result in the enterprise-wide risk analysis required by HIPAA. “Entities must not only conduct a comprehensive risk analysis, but must also evaluate and address potential security risks when implementing enterprise changes impacting ePHI,” OCR Director Jocelyn Samuels said in a statement. “The HIPAA Security Rule’s specific requirements to address environmental and operational changes are critical for the protection of patient information.” See also: HIPAA Breach Case Results in Record $5.5M Penalty In addition to the financial payment, St. Joseph Health agreed to a corrective action plan that includes a thorough risk analysis, implementation of a risk management plan and staff training. The $2.14 million penalty brings the total amount of settlements for HIPAA security violations to $22.84 million this year, up sharply from $6.2 million in all of 2015.
  3. Compliance requirements are often set out in flat documents. Sometimes PDFs, sometimes other formats, but they have a tendency to be a huge list of characteristics and checkboxes to be investigated and potentially remediated. They often come from industry standards bodies or governments. Security tools may be somewhat more flexible, encoded into a set of shell scripts that check and verify the systems after they are built. These are often shipped by upstream software providers when a breach or bug is found. Operational tools deal with the day-to-day building and management of systems, and might include components that are homegrown and some that come from vendors. These various sources and requirements play into the overall security picture of technical infrastructure.
  4. For the purposes of compliance, we actually wanted a common language, in code, that would allow all audiences – compliance, security, and devops – to collaborate on. And this code will then act on systems. This is whyInSpec was developed.
  5. Removing legacy network services helps prevent unwanted access to systems. Some of these services have their uses, but many have modern replacements that were built with more security in mind. You may still find these services included in full-distribution installs from various vendors. I've replaced the original SSH example; it no longer works on/applies to current releases of Linux; openssh no longer supports protocol 1, and the check for versions is not universal. http://undeadly.org/cgi?action=article&sid=20170501005206 The old version is here: SSH supports two different protocol versions. The original version, SSHv1, was subject to a number of security issues. All systems must use SSHv2 instead to avoid these issues. This directive is fairly common; it’s included in the security benchmarks published by CIS for a number of Linux and Unix systems that include SSH as a connection protocol. Many modern versions of these operating systems have version 2 as the default but include legacy support for version 1. It’s still a good idea to ensure that your systems are set to only use version 2.
  6. This test will tell you on red hat-related Linux hosts that the two packages xinetd and inetd are not installed on the system. This full control for InSpec has detailed information about what the requirement is – do not run these deprecated services – as well as a location of the documentation (here truncated to fit on the slide). This example uses the nsa guidelines, and the configuration follows the headers included in the documentation, so only xinetd and inetd are included in this control. The other services would also have similar controls that can be traced back to guidelines, or could have CVE numbers, ticket numbers from a ticketing system, or other notations for where the requirements were adopted from. "Steve in security sent an email on June 20 2019 telling us to clean this up". The control gives you the ability to group security requirements together – I could also include the other services here if I wanted to, but can also make them their own controls. The impact tells me this is a requirement – impacts range from 0.01 to 1.0. The InSpec resources, the two "describe package" directives, tell InSpec to go looking on the target systems for those packages. InSpec figures out the correct tools to do this with.
  7. Deprecated SSHv1 example
  8. For bits like the ssh configurations, or network services, or other components that are considered more infrastructure than application, these practices are common, changes are periodically rolled into the source images for new hosts (or containers) and the old configurations are eventually purged from production. It’s a herd-immunity approach. But what happens if the thing to be tested is affected by a continuously developed application? Like run time configurations for java, or your databases. Can you count on every team to always know all of the requirements? When the requirements change – we're moving all of our databases to a new port – how does that information get out to all teams, how is it rolled out across systems, and who ensures that nothing gets reverted in the future, even inadvertently?
  9. The point here is that running a twice-yearly audit and then spending six months remediating issues is a deadend task. With InSpec, applications can be shipped and deployed on hosts that you know meet your standards, and InSpec can then be used to make sure nothing drifts over time. Keep an eye on your systems regularly rather than just at audit.
  10. InSpec's resources have powerful libraries for matching and checking the characteristics of individual atomic resources – like files or services. They also have support for more sophisticated verifications on the system. Individual configuration files can be interrogated for settings, like the example here for auditd. Additionally, the ability to run arbitrary commands is powerful for situations where a fix for a vulnerability has been produced by an upstream vendor and includes some sort of shell script rather than a new package. These are fairly common for things like kernel-level issues that require multiple checks and changes in settings files and also verification in the running kernel filesystem
  11. A simple example that checks for settings on the /tmp directory.
  12. If you have time, walk through the layout of a profile on github. The dev-sec.io ones are pretty complex, but have a lot of important stuff in them.
  13. Large platform-focused profiles like linux-baseline include tests collected into subtopics for easier management and understanding. The os-* tests are in a separate file from tests that are looking at specific packages. This also shows again the amount of user-friendly information that can be included in the title and description of a control. This particular test I chose because it has a lot of tests for a single resource, giving a comprehensive set of checks for an important file.
  14. Add upcoming events, webinars, etc to this slide
  15. Using AWS. If you prefer some other cloud that provides CentOS 7, this example should still work fine!
  16. Nothing special. This is the default ami available.
  17. I'm going to do the next part with a wrapper profile example. Depending on current versions of linux, the default install, and the state of the linux-baseline, this error changes, but this setting for auditd turns up pretty often when using CentOS 7 on AWS. Other stuff includes settings for the random number generator, prng.
  18. 0 failures! Yay! A few minutes from a baseline off-the-shelf random image in the cloud to a system that meets our security needs!
  19. You can use this diagram to show the relationship between the baseline profile and the wrapper profile