SlideShare a Scribd company logo
1
Akash Mahajan
Founder/Director at Appsecco
ALLDAYDEVOPS 2016
SYSTEM HARDENING
USING ANSIBLE
(APPLICATION DEPLOYMENT + CONFIGURATION
MANAGEMENT + CONTINUOUS SECURITY)
THAT WEB APPLICATION SECURITY GUY
“Start with Why?
- Simon Sinek
THIS IS A STORY ABOUT APPSEC
OWASP TOP 10 - A5 SECURITY MISCONFIGURATION
http://cheezburger.com/4834698752 https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
AM I VULNERABLE TO ‘SECURITY MISCONFIGURATION’?
Is any of your software out of date?
Are there any un-necessary features enabled/installed?
Ports, Services, Accounts, Pages, Privileges
Are default accounts and their passwords enabled/
unchanged?
Are security settings and libraries not set to secure
values?
OWASP TOP 10 - A5 SECURITY MISCONFIGURATION
https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
EXAMPLE ATTACK SCENARIOS
Attacker discovers the standard admin pages are on your server, logs
in with default passwords, and takes over.
Attacker finds due to directory listing and downloads all your
compiled Java classes, which she decompiles and reverse engineers to
get all your custom code. She then finds a serious access control flaw in
your application.
App server configuration allows stack traces to be returned to users,
potentially exposing underlying flaws. Attackers love the extra
information error messages provide.
https://twitter.com/SwiftOnSecurity/status/793976943276265472
OWASP TOP 10 - A5 SECURITY MISCONFIGURATION
https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
PREVENTING SECURITY MISCONFIGURATION
A repeatable hardening process that makes it fast and easy to deploy a
properly locked down environment
Dev/QA/Prod should be configured identically but with different passwords
used
This process should be automated to minimise the effort required to setup a
new secure environment.
A process for deploying all new software updates and patches in a
timely manner to each deployed environment
Consider running scans and doing audits periodically to help detect
future misconfigurations or missing patches.
http://www.failking.com/41473-security-fail.html
OUR SECURITY REQUIREMENTS DERIVED (0/5)
A repeatable hardening process
Dev/QA/Prod should be configured identically but with different passwords used
This process should be automated to minimise the effort required to setup a new
secure environment.
A process for deploying all new software updates and patches in a timely manner
to each deployed environment
Consider running scans and doing audits periodically to help detect future
misconfigurations or missing patches
Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
Deploying software once may not be rocket science,
but doing that repeatedly eliminating human error is
Satellite deploying solar panels - From Wikipedia
HOW DO WE DEPLOY SOFTWARE, APPS & CODE?
CUSTOM BASH SCRIPTS CUSTOM PROGRAMS PROVISIONING TOOLS
➤ rsync
➤ ssh/scp
➤ FTP
➤ curl/wget
Many others as well
PROS AND CONS OF THE APPROACHES
CUSTOM BASH SCRIPTS CUSTOM PROGRAMS PROVISIONING TOOLS
➤ GUI tools discourage
automation
➤ For folks like me custom
scripts are inherently
difficult to
➤ maintain,
➤ track
➤ reuse
➤ Great for programmers and
devs
➤ As custom as it can get
➤ Non-programmers find it
difficult
➤ Overhead of a
programming language and
syntax
➤ Meant for provisioning and
deploying code, software &
applications
➤ Automation is a primary
objective
➤ Allows for repeatability in
deployment
➤ Reduces human errors
WHAT IS SECURITY HARDENING?
Security hardening is the process where we identify insecure default configuration present on a
system and apply changes that will change the configuration to secure values.
The process can be applied to all the layers
Network - Enable firewall/security groups with restrictive rule sets
Transport - Enable TCP wrappers for a service/subnet matching
Application - Enable web server to allow specific IPs to admin panel
Kernel Networking parameters - Enable defences for the networking
stack
WHY USE ANSIBLE FOR SECURITY HARDENING?
➤ playbook by Nick Bluth from the Noun Project
➤ github stargazers, ansible search results
ANSIBLE IS MADE FOR SECURITY AUTOMATION
Attribute Benefit
YAML language
Provides a structured way to define
applications, systems
Modular Makes it deployment friendly
Enables Automation Makes it easy to script, program
Uses SSH for access
Secure by default with encrypted
transmission and host authentication
Python FOSS Easy to integrate and get started
Community Driven
Lots of helpful samples and
documentation available
ANSIBLE PLAYBOOK + IDEMPOTENT == WIN
Ansible uses playbooks to execute a series of commands/modules
on the target
An Ansible playbook is written in YAML which makes it machine
readable and provides structure
Ansible follows the concept of idempotent, which translates into
describing the state that we would like the system to be in
All we need to do is express our security assertions in the YAML
format in a playbook and we get a codified security document
ANSIBLE PLAYBOOK CAN BE A CODIFIED SECURITY DOCUMENT
ANSIBLE PLAYBOOK SNIPPET - MYSQL HARDENING
1. Delete anonymous MySQL user 2. Change MySQL root user password 3. Remove test database
1
2
3
The concept that change commands should only
be applied when they need to be applied, and
that it is better to describe the desired state of a
system than the process of how to get to that
state
THE CONCEPT OF IDEMPOTENCY
OUR JOB IS NOW TO ENSURE THAT WE NEED TO DEFINE WHAT CONSTITUTES A SECURE
AND HARDENED SYSTEM
http://docs.ansible.com/ansible/glossary.html#term-idempotency
All playbooks are written in YAML providing us with
structure that we can learn and train on
Since playbooks are text files, we can use Git to do version
control on them
By using Git or another version control software, managing
the playbooks is just like managing any software project.
Therefore infrastructure as code but for security
STRUCTURED MANUALS (PLAYBOOKS) + GIT == WIN
help by Viktor Vorobyev from the Noun Project
repository by Nick Bluth from the Noun Project
secure document by Creative Stall from the Noun Project
VARIABLES ALLOW FOR CREATING GENERIC INSTRUCTION MANUALS
OUR SECURITY REQUIREMENTS DERIVED (2/5)
A repeatable hardening process
Dev/QA/Prod should be configured identically but with different passwords used
This process should be automated to minimise the effort required to setup a new
secure environment.
A process for deploying all new software updates and patches in a timely manner
to each deployed environment
Consider running scans and doing audits periodically to help detect future
misconfigurations or missing patches
Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
Various organisations publish best practices
CIS Benchmarks
DISA-STIG
NIST Guidelines
Linux Distribution specific guidelines
Application security specific guidelines
HOW DO WE CREATE SECURITY BEST PRACTICES?
YOU DON’T NEED TO, BEST PRACTICES HAVE ALREADY BEEN CREATED
Dahi Handi by Ramnath Bhat under CC2.0 license
https://www.flickr.com/photos/ramnath1971/7943196628
Ansible Roles are the moving parts of a playbook
Roles are how we should be organising a playbook
Grouping content by roles allows easy sharing of roles with
other users
By using roles_path configuration variable, roles can be
downloaded from git, Ansible Galaxy and stored in one
location, to use with multiple playbooks
ANSIBLE PLAYBOOK IS MADE UP OF ROLES
ROLES CAN EASILY BE ADDED TO A PLAYBOOK FOR MAXIMUM FLEXIBILITY
Notable projects to get started with, right now
Hardening Framework - Server Hardening Framework
Ansible role for DISA STIG
OpenStack-Ansible - Host Security Hardening
CIS Ansible Role against CentOS/RHEL
Linux Security Hardening with OpenSCAP and Ansible
First Five Minutes on a Server with Ansible
WHERE DO WE FIND REFERENCE ANSIBLE PLAYBOOKS
GREAT NEWS IS THAT THERE ARE MANY HARDENING PROJECTS ALREADY
Dahi Handi by Ramnath Bhat under CC2.0 license
https://www.flickr.com/photos/ramnath1971/7943196628
ANSIBLE GALAXY IS LIKE GITHUB BUT FOR ROLES
GALAXY IS NOW OSS, SO THAT YOU CAN SETUP PRIVATE GALAXY SERVERS
$ ansible-galaxy 
search hardening
$ ansible-galaxy 
install
username.rolename
Galaxy is an online tool to manage Ansible roles
Using the CLI client, roles can be searched for and
installed with just one command
Galaxy is like the central repository information for roles
Galaxy offers automated testing of roles as well
OUR SECURITY REQUIREMENTS DERIVED (3/5)
A repeatable hardening process
Dev/QA/Prod should be configured identically but with different passwords used
This process should be automated to minimise the effort required to setup a new
secure environment.
A process for deploying all new software updates and patches in a timely manner
to each deployed environment
Consider running scans and doing audits periodically to help detect future
misconfigurations or missing patches
Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
CONTINUOUS MONITORING FOR SECURITY
ANSIBLE CAN BECOME PART OF YOUR CI/CD WORKFLOW
Integrate with your favourite CI/CD tool
Schedule regular runs against the targets as specified
Get information on when your run (build) failed and why
Get granular control to secure credentials and secrets and
get Role Based Access Control (RBAC) as well
Jenkins logo from https://jenkins.io/ Go.cd logo from https://go.cd
Ansible Tower logo from https://ansible.com Rundeck logo from https://xebialabs.com
OUR SECURITY REQUIREMENTS DERIVED (5/5)
A repeatable hardening process
Dev/QA/Prod should be configured identically but with different passwords used
This process should be automated to minimise the effort required to setup a new
secure environment.
A process for deploying all new software updates and patches in a timely manner
to each deployed environment
Consider running scans and doing audits periodically to help detect future
misconfigurations or missing patches
Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
TAKEAWAYS AND CONCLUSION
1. Using Ansible (and others) we can build a security automation workflow
2. Since the security part is codified in documents, we can do version control
3. A lot of work has already been done in finding out the best practices
4. For Ansible, using the above mentioned best practices, there are already
multitude of playbooks and roles available on github and Ansible Galaxy
5. Using CI/CD tools like Jenkins/Go.cd or specialised software like Ansible Tower/
Rundeck we can repeatedly schedule Ansible playbooks and monitor their outcome
BONUS TAKEAWAY - FREE EBOOK
https://github.com/appsecco/alldaydevops-shua
Ebook in PDF/Mobi/Epub format
Will keep it updated and add more integrations
Available with the presentation and other
materials at the above mentioned github repo
System Hardening Using Ansible
System Hardening Using Ansible
QUESTIONS
@makash | https://linkd.in/webappsecguy | akash@appsecco.com

More Related Content

PDF
OpenShift Virtualization- Technical Overview.pdf
ODP
Openshift Container Platform
ODP
ansible why ?
PPTX
Introduction to openshift
PDF
Introduction to kubernetes
PDF
Gitlab, GitOps & ArgoCD
PDF
What Is OpenStack | OpenStack Tutorial For Beginners | OpenStack Training | E...
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
OpenShift Virtualization- Technical Overview.pdf
Openshift Container Platform
ansible why ?
Introduction to openshift
Introduction to kubernetes
Gitlab, GitOps & ArgoCD
What Is OpenStack | OpenStack Tutorial For Beginners | OpenStack Training | E...
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand

What's hot (20)

PDF
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
PDF
Scale Kubernetes to support 50000 services
PPTX
Kubernetes
PDF
OpenShift 4, the smarter Kubernetes platform
PDF
Jenkins
PPTX
Introduction to jenkins
PPSX
Microservices Architecture - Cloud Native Apps
PDF
GitOps with ArgoCD
PDF
Open shift 4 infra deep dive
PPTX
Jenkins CI presentation
PPTX
Knative with .NET Core and Quarkus with GraalVM
PDF
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
PDF
Deep dive into Kubernetes Networking
PDF
OpenShift-Technical-Overview.pdf
PDF
Kubernetes Introduction
PDF
Jenkins tutorial
PDF
Red Hat OpenShift Container Platform Overview
PDF
Quarkus - a next-generation Kubernetes Native Java framework
PDF
Quarkus tips, tricks, and techniques
PDF
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
Scale Kubernetes to support 50000 services
Kubernetes
OpenShift 4, the smarter Kubernetes platform
Jenkins
Introduction to jenkins
Microservices Architecture - Cloud Native Apps
GitOps with ArgoCD
Open shift 4 infra deep dive
Jenkins CI presentation
Knative with .NET Core and Quarkus with GraalVM
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Deep dive into Kubernetes Networking
OpenShift-Technical-Overview.pdf
Kubernetes Introduction
Jenkins tutorial
Red Hat OpenShift Container Platform Overview
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus tips, tricks, and techniques
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
Ad

Similar to System Hardening Using Ansible (20)

PPTX
Security workflow with ansible
PDF
Automated Security Hardening with OpenStack-Ansible
ODP
Introduction to Ansible
PDF
Managing MySQL with Ansible
PPTX
ansible : Infrastructure automation,idempotent and more
PDF
Managing Postgres with Ansible
PDF
Case Study: Ansible and NASA
PPTX
Ansible as configuration management tool for devops
PDF
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
PDF
Ansible Case Studies
PDF
Ansible is Our Wishbone
PDF
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
PDF
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
PDF
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
PDF
Devops_and_Legacy_Ansible
PDF
Learning Ansible 2 2nd Edition Fabio Alessandro Locati
PPTX
SESSION Ansible how to deploy and push resources
PDF
WAG the Blog
PDF
Ansible a tool for dev ops
PPTX
Introduction to Ansible - Jan 28 - Austin MeetUp
Security workflow with ansible
Automated Security Hardening with OpenStack-Ansible
Introduction to Ansible
Managing MySQL with Ansible
ansible : Infrastructure automation,idempotent and more
Managing Postgres with Ansible
Case Study: Ansible and NASA
Ansible as configuration management tool for devops
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Ansible Case Studies
Ansible is Our Wishbone
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
"Using Automation Tools To Deploy And Operate Applications In Real World Scen...
Devops_and_Legacy_Ansible
Learning Ansible 2 2nd Edition Fabio Alessandro Locati
SESSION Ansible how to deploy and push resources
WAG the Blog
Ansible a tool for dev ops
Introduction to Ansible - Jan 28 - Austin MeetUp
Ad

More from Sonatype (20)

PPTX
DevOps Days Columbus - Derek Weeks - 2019
PDF
2019 DevSecOps Reference Architectures
PDF
RSAC DevSecOpsDays 2018 - We are all Equifax
PPTX
DevSecOps reference architectures 2018
PDF
30+ Nexus Integrations to Accelerate DevOps
PDF
2017 DevSecOps Survey
PPTX
Starting and Scaling DevOps In the Enterprise
PPTX
DevOps Friendly Doc Publishing for APIs & Microservices
PDF
The Unrealized Role of Monitoring & Alerting w/ Jason Hand
PPTX
DevOps and All the Continuouses w/ Helen Beal
PDF
Serverless and the Way Forward
PDF
A Small Association's Journey to DevOps w/ Edward Ruiz
PDF
What's My Security Policy Doing to My Help Desk w/ Chris Swan
PDF
Characterizing and Contrasting Kuhn-tey-ner Awr-kuh-streyt-ors
PDF
Static Analysis For Security and DevOps Happiness w/ Justin Collins
PDF
Automated Infrastructure Security: Monitoring using FOSS
PDF
There is No Server: Immutable Infrastructure and Serverless Architecture
PDF
Getting out of the Job Jungle with Jenkins
PDF
Modern Infrastructure Automation
PDF
Continuous Everyone: Engaging People Across the Continuous Pipeline
DevOps Days Columbus - Derek Weeks - 2019
2019 DevSecOps Reference Architectures
RSAC DevSecOpsDays 2018 - We are all Equifax
DevSecOps reference architectures 2018
30+ Nexus Integrations to Accelerate DevOps
2017 DevSecOps Survey
Starting and Scaling DevOps In the Enterprise
DevOps Friendly Doc Publishing for APIs & Microservices
The Unrealized Role of Monitoring & Alerting w/ Jason Hand
DevOps and All the Continuouses w/ Helen Beal
Serverless and the Way Forward
A Small Association's Journey to DevOps w/ Edward Ruiz
What's My Security Policy Doing to My Help Desk w/ Chris Swan
Characterizing and Contrasting Kuhn-tey-ner Awr-kuh-streyt-ors
Static Analysis For Security and DevOps Happiness w/ Justin Collins
Automated Infrastructure Security: Monitoring using FOSS
There is No Server: Immutable Infrastructure and Serverless Architecture
Getting out of the Job Jungle with Jenkins
Modern Infrastructure Automation
Continuous Everyone: Engaging People Across the Continuous Pipeline

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PPTX
history of c programming in notes for students .pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
System and Network Administration Chapter 2
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction Database Management System for Course Database
history of c programming in notes for students .pptx
Digital Strategies for Manufacturing Companies
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
How Creative Agencies Leverage Project Management Software.pdf
System and Network Administration Chapter 2
How to Migrate SBCGlobal Email to Yahoo Easily
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Nekopoi APK 2025 free lastest update
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
VVF-Customer-Presentation2025-Ver1.9.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Navsoft: AI-Powered Business Solutions & Custom Software Development
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
CHAPTER 2 - PM Management and IT Context
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

System Hardening Using Ansible

  • 1. 1 Akash Mahajan Founder/Director at Appsecco ALLDAYDEVOPS 2016 SYSTEM HARDENING USING ANSIBLE (APPLICATION DEPLOYMENT + CONFIGURATION MANAGEMENT + CONTINUOUS SECURITY)
  • 2. THAT WEB APPLICATION SECURITY GUY
  • 3. “Start with Why? - Simon Sinek
  • 4. THIS IS A STORY ABOUT APPSEC
  • 5. OWASP TOP 10 - A5 SECURITY MISCONFIGURATION http://cheezburger.com/4834698752 https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration AM I VULNERABLE TO ‘SECURITY MISCONFIGURATION’? Is any of your software out of date? Are there any un-necessary features enabled/installed? Ports, Services, Accounts, Pages, Privileges Are default accounts and their passwords enabled/ unchanged? Are security settings and libraries not set to secure values?
  • 6. OWASP TOP 10 - A5 SECURITY MISCONFIGURATION https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration EXAMPLE ATTACK SCENARIOS Attacker discovers the standard admin pages are on your server, logs in with default passwords, and takes over. Attacker finds due to directory listing and downloads all your compiled Java classes, which she decompiles and reverse engineers to get all your custom code. She then finds a serious access control flaw in your application. App server configuration allows stack traces to be returned to users, potentially exposing underlying flaws. Attackers love the extra information error messages provide. https://twitter.com/SwiftOnSecurity/status/793976943276265472
  • 7. OWASP TOP 10 - A5 SECURITY MISCONFIGURATION https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration PREVENTING SECURITY MISCONFIGURATION A repeatable hardening process that makes it fast and easy to deploy a properly locked down environment Dev/QA/Prod should be configured identically but with different passwords used This process should be automated to minimise the effort required to setup a new secure environment. A process for deploying all new software updates and patches in a timely manner to each deployed environment Consider running scans and doing audits periodically to help detect future misconfigurations or missing patches. http://www.failking.com/41473-security-fail.html
  • 8. OUR SECURITY REQUIREMENTS DERIVED (0/5) A repeatable hardening process Dev/QA/Prod should be configured identically but with different passwords used This process should be automated to minimise the effort required to setup a new secure environment. A process for deploying all new software updates and patches in a timely manner to each deployed environment Consider running scans and doing audits periodically to help detect future misconfigurations or missing patches Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
  • 9. Deploying software once may not be rocket science, but doing that repeatedly eliminating human error is Satellite deploying solar panels - From Wikipedia
  • 10. HOW DO WE DEPLOY SOFTWARE, APPS & CODE? CUSTOM BASH SCRIPTS CUSTOM PROGRAMS PROVISIONING TOOLS ➤ rsync ➤ ssh/scp ➤ FTP ➤ curl/wget Many others as well
  • 11. PROS AND CONS OF THE APPROACHES CUSTOM BASH SCRIPTS CUSTOM PROGRAMS PROVISIONING TOOLS ➤ GUI tools discourage automation ➤ For folks like me custom scripts are inherently difficult to ➤ maintain, ➤ track ➤ reuse ➤ Great for programmers and devs ➤ As custom as it can get ➤ Non-programmers find it difficult ➤ Overhead of a programming language and syntax ➤ Meant for provisioning and deploying code, software & applications ➤ Automation is a primary objective ➤ Allows for repeatability in deployment ➤ Reduces human errors
  • 12. WHAT IS SECURITY HARDENING? Security hardening is the process where we identify insecure default configuration present on a system and apply changes that will change the configuration to secure values. The process can be applied to all the layers Network - Enable firewall/security groups with restrictive rule sets Transport - Enable TCP wrappers for a service/subnet matching Application - Enable web server to allow specific IPs to admin panel Kernel Networking parameters - Enable defences for the networking stack
  • 13. WHY USE ANSIBLE FOR SECURITY HARDENING? ➤ playbook by Nick Bluth from the Noun Project ➤ github stargazers, ansible search results ANSIBLE IS MADE FOR SECURITY AUTOMATION Attribute Benefit YAML language Provides a structured way to define applications, systems Modular Makes it deployment friendly Enables Automation Makes it easy to script, program Uses SSH for access Secure by default with encrypted transmission and host authentication Python FOSS Easy to integrate and get started Community Driven Lots of helpful samples and documentation available
  • 14. ANSIBLE PLAYBOOK + IDEMPOTENT == WIN Ansible uses playbooks to execute a series of commands/modules on the target An Ansible playbook is written in YAML which makes it machine readable and provides structure Ansible follows the concept of idempotent, which translates into describing the state that we would like the system to be in All we need to do is express our security assertions in the YAML format in a playbook and we get a codified security document ANSIBLE PLAYBOOK CAN BE A CODIFIED SECURITY DOCUMENT
  • 15. ANSIBLE PLAYBOOK SNIPPET - MYSQL HARDENING 1. Delete anonymous MySQL user 2. Change MySQL root user password 3. Remove test database 1 2 3
  • 16. The concept that change commands should only be applied when they need to be applied, and that it is better to describe the desired state of a system than the process of how to get to that state THE CONCEPT OF IDEMPOTENCY OUR JOB IS NOW TO ENSURE THAT WE NEED TO DEFINE WHAT CONSTITUTES A SECURE AND HARDENED SYSTEM http://docs.ansible.com/ansible/glossary.html#term-idempotency
  • 17. All playbooks are written in YAML providing us with structure that we can learn and train on Since playbooks are text files, we can use Git to do version control on them By using Git or another version control software, managing the playbooks is just like managing any software project. Therefore infrastructure as code but for security STRUCTURED MANUALS (PLAYBOOKS) + GIT == WIN help by Viktor Vorobyev from the Noun Project repository by Nick Bluth from the Noun Project secure document by Creative Stall from the Noun Project VARIABLES ALLOW FOR CREATING GENERIC INSTRUCTION MANUALS
  • 18. OUR SECURITY REQUIREMENTS DERIVED (2/5) A repeatable hardening process Dev/QA/Prod should be configured identically but with different passwords used This process should be automated to minimise the effort required to setup a new secure environment. A process for deploying all new software updates and patches in a timely manner to each deployed environment Consider running scans and doing audits periodically to help detect future misconfigurations or missing patches Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
  • 19. Various organisations publish best practices CIS Benchmarks DISA-STIG NIST Guidelines Linux Distribution specific guidelines Application security specific guidelines HOW DO WE CREATE SECURITY BEST PRACTICES? YOU DON’T NEED TO, BEST PRACTICES HAVE ALREADY BEEN CREATED Dahi Handi by Ramnath Bhat under CC2.0 license https://www.flickr.com/photos/ramnath1971/7943196628
  • 20. Ansible Roles are the moving parts of a playbook Roles are how we should be organising a playbook Grouping content by roles allows easy sharing of roles with other users By using roles_path configuration variable, roles can be downloaded from git, Ansible Galaxy and stored in one location, to use with multiple playbooks ANSIBLE PLAYBOOK IS MADE UP OF ROLES ROLES CAN EASILY BE ADDED TO A PLAYBOOK FOR MAXIMUM FLEXIBILITY
  • 21. Notable projects to get started with, right now Hardening Framework - Server Hardening Framework Ansible role for DISA STIG OpenStack-Ansible - Host Security Hardening CIS Ansible Role against CentOS/RHEL Linux Security Hardening with OpenSCAP and Ansible First Five Minutes on a Server with Ansible WHERE DO WE FIND REFERENCE ANSIBLE PLAYBOOKS GREAT NEWS IS THAT THERE ARE MANY HARDENING PROJECTS ALREADY Dahi Handi by Ramnath Bhat under CC2.0 license https://www.flickr.com/photos/ramnath1971/7943196628
  • 22. ANSIBLE GALAXY IS LIKE GITHUB BUT FOR ROLES GALAXY IS NOW OSS, SO THAT YOU CAN SETUP PRIVATE GALAXY SERVERS $ ansible-galaxy search hardening $ ansible-galaxy install username.rolename Galaxy is an online tool to manage Ansible roles Using the CLI client, roles can be searched for and installed with just one command Galaxy is like the central repository information for roles Galaxy offers automated testing of roles as well
  • 23. OUR SECURITY REQUIREMENTS DERIVED (3/5) A repeatable hardening process Dev/QA/Prod should be configured identically but with different passwords used This process should be automated to minimise the effort required to setup a new secure environment. A process for deploying all new software updates and patches in a timely manner to each deployed environment Consider running scans and doing audits periodically to help detect future misconfigurations or missing patches Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
  • 24. CONTINUOUS MONITORING FOR SECURITY ANSIBLE CAN BECOME PART OF YOUR CI/CD WORKFLOW Integrate with your favourite CI/CD tool Schedule regular runs against the targets as specified Get information on when your run (build) failed and why Get granular control to secure credentials and secrets and get Role Based Access Control (RBAC) as well Jenkins logo from https://jenkins.io/ Go.cd logo from https://go.cd Ansible Tower logo from https://ansible.com Rundeck logo from https://xebialabs.com
  • 25. OUR SECURITY REQUIREMENTS DERIVED (5/5) A repeatable hardening process Dev/QA/Prod should be configured identically but with different passwords used This process should be automated to minimise the effort required to setup a new secure environment. A process for deploying all new software updates and patches in a timely manner to each deployed environment Consider running scans and doing audits periodically to help detect future misconfigurations or missing patches Basically taken from https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
  • 26. TAKEAWAYS AND CONCLUSION 1. Using Ansible (and others) we can build a security automation workflow 2. Since the security part is codified in documents, we can do version control 3. A lot of work has already been done in finding out the best practices 4. For Ansible, using the above mentioned best practices, there are already multitude of playbooks and roles available on github and Ansible Galaxy 5. Using CI/CD tools like Jenkins/Go.cd or specialised software like Ansible Tower/ Rundeck we can repeatedly schedule Ansible playbooks and monitor their outcome
  • 27. BONUS TAKEAWAY - FREE EBOOK https://github.com/appsecco/alldaydevops-shua Ebook in PDF/Mobi/Epub format Will keep it updated and add more integrations Available with the presentation and other materials at the above mentioned github repo