melbourne infracoders: compliance as code with inspec

63
Compliance as Code Melbourne Infrastructure Coders November 8, 2016

Upload: matt-ray

Post on 14-Jan-2017

188 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Melbourne Infracoders: Compliance as Code with InSpec

Compliance as CodeMelbourne Infrastructure Coders

November 8, 2016

Page 2: Melbourne Infracoders: Compliance as Code with InSpec
Page 3: Melbourne Infracoders: Compliance as Code with InSpec
Page 4: Melbourne Infracoders: Compliance as Code with InSpec

Chef Workflow

Page 5: Melbourne Infracoders: Compliance as Code with InSpec
Page 6: Melbourne Infracoders: Compliance as Code with InSpec
Page 7: Melbourne Infracoders: Compliance as Code with InSpec

SSH Control

"SSH supports two different protocol versions. The original version, SSHv1, was subject to a number of security issues. Please use SSHv2 instead to avoid these."

Page 8: Melbourne Infracoders: Compliance as Code with InSpec

How will I verify this?

Page 9: Melbourne Infracoders: Compliance as Code with InSpec

Whip up a one-liner!

grep "^Protocol" /etc/ssh/sshd_config | sed 's/Protocol //'

Page 10: Melbourne Infracoders: Compliance as Code with InSpec

Apache Server Information Leakage - Server Token Directive

• Description

This Directive Controls wheather Server response field is sent back to clients includes a description of Generic OS Type of the Server.

This allows attackers to identify web servers details greatly and increases the efficiency of any attack,as security vulnerabilities are dependent upon specific software versions.

• How to Test

In order to test for ServerToken configuration, one should check the Apache configuration file.

• Misconfiguration

ServerTokens Full

• Remediation

Configure the ServerTokens directive in the Apache configuration to value of Prod or ProductOnly. This tells Apache to only return "Apache" in the Server header, returned on every page request.

ServerTokens ProdorServerTokens ProductOnly

https://www.owasp.org/index.php/SCG_WS_Apache

Page 11: Melbourne Infracoders: Compliance as Code with InSpec

More grep and sed!

grep "^ServerTokens" /etc/httpd/conf/httpd.conf | sed 's/ServerTokens //'

Page 12: Melbourne Infracoders: Compliance as Code with InSpec
Page 13: Melbourne Infracoders: Compliance as Code with InSpec
Page 14: Melbourne Infracoders: Compliance as Code with InSpec
Page 15: Melbourne Infracoders: Compliance as Code with InSpec
Page 16: Melbourne Infracoders: Compliance as Code with InSpec
Page 17: Melbourne Infracoders: Compliance as Code with InSpec

Compliance

Page 18: Melbourne Infracoders: Compliance as Code with InSpec
Page 19: Melbourne Infracoders: Compliance as Code with InSpec

“two-thirds of organizations did not adequately test the security of all in-scope systems”

Page 20: Melbourne Infracoders: Compliance as Code with InSpec

Key Trends

• While individual rule compliance is up, testing of security systems is down

• Sustainability is low. Fewer than a third of companies were found to be still fully compliant less than a year after successful validation.

Page 21: Melbourne Infracoders: Compliance as Code with InSpec
Page 22: Melbourne Infracoders: Compliance as Code with InSpec

Shell Scripts

grep "^Protocol" /etc/ssh/sshd_config | sed 's/Protocol //'grep "^ServerTokens" /etc/httpd/conf/httpd.conf | sed 's/ServerTokens //'

Page 23: Melbourne Infracoders: Compliance as Code with InSpec

Infrastructure Code

package 'httpd' doaction :install

end

service 'httpd' doaction [ :start, :enable ]

end

Page 24: Melbourne Infracoders: Compliance as Code with InSpec

What We Have Here Is A Communications Problem

Page 25: Melbourne Infracoders: Compliance as Code with InSpec
Page 26: Melbourne Infracoders: Compliance as Code with InSpec

Security != Compliance

Page 27: Melbourne Infracoders: Compliance as Code with InSpec
Page 28: Melbourne Infracoders: Compliance as Code with InSpec
Page 29: Melbourne Infracoders: Compliance as Code with InSpec
Page 30: Melbourne Infracoders: Compliance as Code with InSpec
Page 31: Melbourne Infracoders: Compliance as Code with InSpec
Page 32: Melbourne Infracoders: Compliance as Code with InSpec
Page 33: Melbourne Infracoders: Compliance as Code with InSpec
Page 34: Melbourne Infracoders: Compliance as Code with InSpec

Compliance Language

Page 35: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux

Page 36: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows

Page 37: Melbourne Infracoders: Compliance as Code with InSpec

Windows

Page 38: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Page 39: Melbourne Infracoders: Compliance as Code with InSpec

Available Resourcesapache_confapt

audit_policy

auditd_conf

auditd_rules

bondbridge

csv

command

directory

etc_groupfile

gemgroup

host

inetd_conf

interface

iptableskernel_module

kernel_parameter

limits_conf

login_defs

mountmysql_conf

mysql_sessionnpm

ntp_conf

oneget

os

os_envpackage

parse_config

parse_config_file

passwd

pipport

postgres_confpostgres_session

powershell

processes

registry_key

security_policyservice

ssh_config

sshd_config

user

windows_featureyaml

yum

Page 40: Melbourne Infracoders: Compliance as Code with InSpec

What is it not?

• IDS / IPS• Firewall• Antivirus• Pentesting tool

Page 41: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal

Page 42: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal, VMs

Page 43: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal, VMs, Containers

Page 44: Melbourne Infracoders: Compliance as Code with InSpec

Test Locally

$ inspec exec test.rb.

Finished in 0.00901 seconds (files took 0.98501 seconds to load)1 example, 0 failures

Page 45: Melbourne Infracoders: Compliance as Code with InSpec

Test Remote via SSH

$ inspec exec test.rb -i vagrant.key -t ssh://[email protected]:11022

No Ruby / agent on the node

Page 46: Melbourne Infracoders: Compliance as Code with InSpec

Test Remote via WinRM

$ inspec exec test.rb -t winrm://[email protected] --password super

No Ruby / agent on the node

Page 47: Melbourne Infracoders: Compliance as Code with InSpec

Test Docker Containers

$ inspec exec test.rb -t docker://3dda08e75838

No Ruby / agent on the container

Page 48: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal, VMs, Containers

Nodes

Page 49: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal, VMs, Containers

Nodes, GRUB, DBs

Page 50: Melbourne Infracoders: Compliance as Code with InSpec

DB Testing

Page 51: Melbourne Infracoders: Compliance as Code with InSpec

One LanguageLinux, Windows, BSD, Unixes, ...

Bare-metal, VMs, Containers

Nodes, GRUB, DBs, Endpoints, APIs, ...

Page 52: Melbourne Infracoders: Compliance as Code with InSpec

Cloud Testing

Page 53: Melbourne Infracoders: Compliance as Code with InSpec

Operating System and Application Coverage

• Red Hat Enterprise Linux• Ubuntu• SUSE• Oracle Linux• Microsoft Windows 7, 8• Microsoft Windows Server 2008,

2012• AIX• HP-UX

• VMware ESXi• Oracle • MySQL• Apache Tomcat• SQL Server• IIS• AWS

Page 54: Melbourne Infracoders: Compliance as Code with InSpec

Compliance as Code.

Page 55: Melbourne Infracoders: Compliance as Code with InSpec

Open Source Community

•InSpec•https://inspec.io•Chef Audit cookbook•https://github.com/chef-cookbooks/audit•Kitchen-InSpec•https://github.com/chef/kitchen-inspec•Supermarket.chef.io

Page 56: Melbourne Infracoders: Compliance as Code with InSpec
Page 57: Melbourne Infracoders: Compliance as Code with InSpec
Page 58: Melbourne Infracoders: Compliance as Code with InSpec
Page 59: Melbourne Infracoders: Compliance as Code with InSpec

New Workflow

Page 60: Melbourne Infracoders: Compliance as Code with InSpec
Page 61: Melbourne Infracoders: Compliance as Code with InSpec
Page 62: Melbourne Infracoders: Compliance as Code with InSpec
Page 63: Melbourne Infracoders: Compliance as Code with InSpec