building a hyper secure vpc on aws with puppet

48
Puppetconf 2013 Building a Hyper Secure VPC on AWS with Puppet Tim Nolet

Upload: tim-nolet

Post on 08-May-2015

498 views

Category:

Technology


0 download

DESCRIPTION

This presentation was given at PuppetConf 2013. It addresses a set of security concerns on AWS VPC and how we used Puppet to address these concerns.

TRANSCRIPT

Page 1: Building a Hyper Secure VPC on AWS with Puppet

Puppetconf2013

BuildingaHyperSecureVPConAWS

withPuppet

TimNolet

Page 2: Building a Hyper Secure VPC on AWS with Puppet

ArchitectatXebia(theNetherlands)

Linux/Java/Cloud/Automation/Operations

[email protected]

github.com/tnolet

nl.linkedin.com/in/tnolet

Page 3: Building a Hyper Secure VPC on AWS with Puppet

Holland=TheNetherlands

Image:xkcd.com

Page 4: Building a Hyper Secure VPC on AWS with Puppet
Page 5: Building a Hyper Secure VPC on AWS with Puppet

Itendtoramble...

Page 6: Building a Hyper Secure VPC on AWS with Puppet

TheAssignment

Page 7: Building a Hyper Secure VPC on AWS with Puppet
Page 8: Building a Hyper Secure VPC on AWS with Puppet

TheAssignment(1)

1. BuildageneralpurposeVPConAWS

2. Standardizeapplicationdeployment

3. Applycompanysecuritypolicies

Page 9: Building a Hyper Secure VPC on AWS with Puppet

TheAssignment(2)

1. DoitwithOpenSource

2. UseAWSstandards

3. Stayclosetoreferenceimplementations

Page 10: Building a Hyper Secure VPC on AWS with Puppet

AWSandsecurity

IAM,MFA,HSMSSL,SSH,VPNISO27001PCI-DSSPGP

..andprobablysomemoreacronyms

Page 11: Building a Hyper Secure VPC on AWS with Puppet

DesignPrinciples

AGridbasedon:

3xAvailabilityZone

3xTier:web,app,data

1xManagementsubnet

Page 12: Building a Hyper Secure VPC on AWS with Puppet
Page 13: Building a Hyper Secure VPC on AWS with Puppet
Page 14: Building a Hyper Secure VPC on AWS with Puppet

DesignPrinciples

Referencestacks

ImplementedinCloudFormation

Provision:

EC2instances

SecurityGroups

RDSinstances

ELBloadbalancers

RDSinstances

etc.

Page 15: Building a Hyper Secure VPC on AWS with Puppet

public_three_tier_stack_redundant_rds.template

Page 16: Building a Hyper Secure VPC on AWS with Puppet
Page 17: Building a Hyper Secure VPC on AWS with Puppet

AMIHardening

1. ApplyCISBenchmarkforRedHatLinux

2. Log+Alertonanydiscrepancies

3. MonitorYUMsecurityupdates

Benchmark:https://benchmarks.cisecurity.org/tools2/linux/CIS_Redhat_Linux_5_Benchmark_v2.0.0.pdf

Page 18: Building a Hyper Secure VPC on AWS with Puppet

CISBenchmarkModule

manifests/1_software.pp2_osservices.pp3_specialservices.pp4_network.pp5_logaudit.pp6_accessauth.pp7_user.pp8_banners.pp9_maintenance.ppinit.pp

=>

Page 19: Building a Hyper Secure VPC on AWS with Puppet

Coooode!

#1.6AdditionalProcessHardening

#1.6.1RestrictCoreDumps

file{"/etc/security/limits.conf":source=>"puppet:///modules/cis_baseline/limits.conf",ensure=>"present",group=>"0",mode=>"644",owner=>"0",}

#1.6.2ConfigureExecShieldfile_line{"Execshield":path=>"/etc/sysctl.conf",line=>"kernel.exec-shield=1",}

Page 20: Building a Hyper Secure VPC on AWS with Puppet

Hacking/etc/pam.d/su

Allowsonlyusersinthe`wheel`grouptouse`su`

#6.5RestrictAccesstothesuCommand

augeas{"pam.d/su":context=>"/files/etc/pam.d/su/",changes=>["ins01after*[module='pam_rootok.so'][control='sufficient'][type='auth'][last()]","set01/typeauth","set01/controlrequired","set01/modulepam_wheel.so","set01/argumentuse_uid",],onlyif=>"match*[type='auth'][control='required'][module='pam_wheel.so'][argument='use_uid']size==0",}

Page 21: Building a Hyper Secure VPC on AWS with Puppet

Taggingdependentmodules

IPtablesismanagedbyitownmoduleWecheckifitisincludedusingthe`tagged`function

#4.7EnableIPtables

#CISRule4.7shouldbeenforcedthroughtheiptables/firewallmodule.#Weonlynotifyifitisnotrunning

iftagged("firewall_base"){notice("CISrule4.7EnableIPtablesisinstalledandenabled")}else{alert{"CISrule4.7EnableIPtablesisnotinstalled":}}

Page 22: Building a Hyper Secure VPC on AWS with Puppet

Tags:orderisimportant

Page 23: Building a Hyper Secure VPC on AWS with Puppet

ActualIPoftheGraylog2hostisinHiera

CentralLogging

Rsyslog=>Graylog2

/etc/rsyslog.conf#Forwardalllogstocentralloggingserver*.*@<%=central_log_app_server%>#udpforwarding

Page 24: Building a Hyper Secure VPC on AWS with Puppet
Page 25: Building a Hyper Secure VPC on AWS with Puppet

SortingSearchingAlertingGraphing

...basicallyaSIEMonthecheap

Page 26: Building a Hyper Secure VPC on AWS with Puppet

Networktrafficlogging

Why?

AWSSecurityGroupsandNetworkACL'sdon'tloganything

Page 27: Building a Hyper Secure VPC on AWS with Puppet

Networktrafficlogging

How?

Puppet+IPtables+Rsyslog+Graylog2

Extendingthepuppetlabs_firewallmodulefromtheforgehttps://forge.puppetlabs.com/puppetlabs/firewall

Page 28: Building a Hyper Secure VPC on AWS with Puppet

Allow/Drop/Log

1. AlloworDropconnections2. Taginitialconnections,onbothdroppedandallowed3. Don'ttagestablishedandrelatedconnections4. LogtoGraylog2viarsyslog

Page 29: Building a Hyper Secure VPC on AWS with Puppet

LetRelatedandEstablishedpassthroughunharmed

Allow/Drop/Log

firewall{"000INPUTallowrelatedandestablished":state=>["RELATED","ESTABLISHED"],action=>"accept",chain=>"INPUT",proto=>"all",}

Page 30: Building a Hyper Secure VPC on AWS with Puppet

Allow/Drop/Log

firewallchain{'LOGNEW:filter:IPv4':ensure=>present,}

firewall{"100LogallNEWconnections":chain=>"LOGNEW",log_level=>"info",log_prefix=>"FIREWALLTCPINBOUND",jump=>"LOG",}

firewall{"101Accepttheconnection":chain=>"LOGNEW",action=>"accept",}

Createa"LOGNEW"chainforallNEWconnectionsTagthemwithaprefixandjumpthemtotheLOGtargetThenaccepttheconnections

Page 31: Building a Hyper Secure VPC on AWS with Puppet

JumpyourallowedtraffictotheLOGNEWchain

Allow/Drop/Log

firewall{"100allowssh":state=>["NEW"],dport=>"22",proto=>"tcp",jump=>"LOGNEW"}

Page 32: Building a Hyper Secure VPC on AWS with Puppet

Exceptions...

ProxiesDNSDatabaserunningnodesOtherbridgingtypenodes

Page 33: Building a Hyper Secure VPC on AWS with Puppet

CustomFactertotherescue!

IPrangesmatchtheGRID

AvailabilityzoneTier

Page 34: Building a Hyper Secure VPC on AWS with Puppet

Av.ZonecustomFact

defget_avzoneipaddress=Facter.value(:ipaddress)ifFacter.value(:tier)=="management"av_zone="zone_1b"elsifipaddress=~(/^.*\.*\.*\.([012345][0-9]|6[0-2])$/)avzone="zone_1a"elsifipaddress=~(/^.*\.*\.*\.(6[5-9]|[789][0-9]|1[0-1][0-9]|12[0-6])$/)avzone="zone_1b"elsifipaddress=~(/^.*\.*\.*\.(129|1[3-8][0-9]|190)$/)avzone="zone_1c"elseavzone="default"endend

Page 35: Building a Hyper Secure VPC on AWS with Puppet

Done!

Page 36: Building a Hyper Secure VPC on AWS with Puppet

Good/Bad/PlainUgly

Page 37: Building a Hyper Secure VPC on AWS with Puppet

Good

Community!

Page 38: Building a Hyper Secure VPC on AWS with Puppet

Good

Graylog2isgreatandextremelyflexible

Page 39: Building a Hyper Secure VPC on AWS with Puppet

Good

VPCisthewaytogoonAWS

CloudFormation'spowerisincredible

Page 40: Building a Hyper Secure VPC on AWS with Puppet

Bad

PerformanceoflargecatalogswithPuppet2.7

file{"/etc/somedirectory":recurse=>true,ignore=>["work","temp","log"],checksum=>none}

Hiera-GPGiscumbersometosaytheleast

Page 41: Building a Hyper Secure VPC on AWS with Puppet

Bad

JSONnotationofCloudFormationtemplates

...meh

Tip:CFNDSL=RubyDSLforCloudFormationtemplates

https://github.com/howech/cfndsl

Page 42: Building a Hyper Secure VPC on AWS with Puppet

Ugly

Unifiedstateandlifecyclemanagement

Page 43: Building a Hyper Secure VPC on AWS with Puppet

Ugly

Everythingisautomated,butusingit'sown:

1. DSL2. Authentication/Authorization3. Paradigms4. Versioning5. Younameit...

Page 44: Building a Hyper Secure VPC on AWS with Puppet

Ugly

Onesinglesourceoftruthfor:

1. Audittrail/logging2. Instancestatus3. Applicationstatus4. CRUDactionsonthewholeinfrastructure

Page 45: Building a Hyper Secure VPC on AWS with Puppet

Hope?!

RightScale,Scalr,Cloudifyandsimilar?AWSOpsWorks?

Page 46: Building a Hyper Secure VPC on AWS with Puppet

Hope?!

NotthirdpartyorapluginPartofthecoreNotSaaSonlyEnterprise

CloudProvisioning,ConfigurationManagementandApplicationDeployment

Page 47: Building a Hyper Secure VPC on AWS with Puppet

Rantover...

Page 48: Building a Hyper Secure VPC on AWS with Puppet

Questions?