Top Banner
DO YOU LOSE SLEEP AT NIGHT?
72

Do you lose sleep at night?

Jan 25, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Do you lose sleep at night?

DO YOU LOSE SLEEP AT NIGHT?

Page 2: Do you lose sleep at night?

Introductions

Nathan Van GheemDirector of Solutions Engineering at Wildcard Corp@[email protected]

Page 3: Do you lose sleep at night?

Wildcard Corp

wildcardcorp.comsecure web solutions

Page 4: Do you lose sleep at night?

More about what I do

• Plone(CMS)

• Python

• JavaScript

• NoSQL

• Linux

Page 5: Do you lose sleep at night?

Purpose

• Learn more about common security issues

• Change attitude and culture toward security

• You, the site owner, can sleep at night

• We, the site developers/system administrators, can sleep at night

Page 6: Do you lose sleep at night?

Why you should care about security

• Responsibility

• Reputation

• Legal implications

• $$$

Page 7: Do you lose sleep at night?
Page 8: Do you lose sleep at night?
Page 9: Do you lose sleep at night?
Page 10: Do you lose sleep at night?
Page 11: Do you lose sleep at night?
Page 12: Do you lose sleep at night?
Page 13: Do you lose sleep at night?

Zero Days

Page 14: Do you lose sleep at night?

CMS focus

• Exposure

• Complexity

• Users

• Features

• Add-ons

Page 15: Do you lose sleep at night?

Covering the basics

• firewall

• open ports

• vulnerability patches

• mailing lists

• server configuration

• unprivileged user running server process

Page 16: Do you lose sleep at night?

What won’t be covered

• DNS, DNSSEC

• Physical security

• Social engineering

• Not in depth on OS Security

Page 17: Do you lose sleep at night?

Top 5 Security Vulnerabilities/Risks

Page 18: Do you lose sleep at night?

Top 5

• No particular order

• Call em as I see em

• We can quibble on what makes the top 5 and the order

• From my experience

• https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project

Page 19: Do you lose sleep at night?

1) SQLi - SQL Injection

“A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application.” - OWASP

Page 20: Do you lose sleep at night?

SQLi Risk Level: HIGH

• Full data compromise

• Access compromise

• Availability compromise

• Possible to issue commands to operating system

Page 21: Do you lose sleep at night?

SQLi: How it works

Page 22: Do you lose sleep at night?

SQLi: How it works

• Input from URL

• Or input from form data

Page 23: Do you lose sleep at night?

Source: http://hackaday.com/2014/04/04/sql-injection-fools-speed-traps-and-clears-your-record/

Page 24: Do you lose sleep at night?

Source: https://xkcd.com/327/

Page 25: Do you lose sleep at night?

1) SQLi Prevention/Solutions

• If you can, do not write SQL yourself, EVER(ORD)

• Use parameterized statements

• Stored procedures

• Escape all input

• WAF(Web Application Firewall)

• Do not use a SQL database

Page 26: Do you lose sleep at night?

2) (D)DOS - Denial of Service

“The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.” - OWASP

Page 27: Do you lose sleep at night?

(D)DOS Risk Level: MEDIUM

• Availability compromise

• No sensitive data compromised

• Easiest attack to perform

Page 28: Do you lose sleep at night?

(D)DOS: How it works

• Known slow resources

• Overload server

• Bypass caching

• Example: Script that when run, will make many simultaneous requests to a server in an attempt to overwhelm it

Page 29: Do you lose sleep at night?

DDOS: Distributed Denial of Service

• Distributed to many machines

• Zombie machines for hire

• Botnets

Page 30: Do you lose sleep at night?

DDOS: LOIC: Low Orbit Ion Cannon

• Hosted service DDOS

• Powered by JavaScript

• Socially driven attack

• Generate random urls to bypass cache and overload target

Page 31: Do you lose sleep at night?

2) (D)DOS Solutions

• WAF(Web Application Firewall)

• CDN(Content Delivery Network)

• Caching, Load balancing

• Keep cache warm

• Serve stale content

• Backup static copy of site

Page 32: Do you lose sleep at night?

2) (D)DOS Solutions continued…

• Profile code

• Monitor traffic, use regular expressions to block request types

• Rate limiting

• LOIC: watch and block from known bad referrer header

Page 33: Do you lose sleep at night?

3) XSS - Cross site scripting

“Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted web sites. XSS attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user.” - OWASP

Page 34: Do you lose sleep at night?

XSS Risk Level: HIGH

• Full data compromise

• Access compromise

Page 35: Do you lose sleep at night?

XSS: Continued

• Injects JavaScript into target web application

• Input/output not validated(server side)

• Targets already logged in users to cause malicious actions

• Persistent: attack stored in application and rendered directly from application

• Reflexive: attack is part of URL

Page 36: Do you lose sleep at night?

XSS: Reflexive example

Source: http://www.codeproject.com/KB/web-security/617043/ReflectedXSS2.jpg

Page 37: Do you lose sleep at night?

XSS: How it’s exploited

• Malicious user has ability to add attack to site

• Social engineering gets logged in user to click exploited URL

• JavaScript renders html that it assumes is safe

Page 38: Do you lose sleep at night?

3) XSS Solutions

• WAF(Web Application Firewall)

• Validated user input

• Escaped output

• Use JavaScript libraries that are safe by default(ReactJS)

Page 39: Do you lose sleep at night?

4) CSRF - Cross-Site Request Forgery

“Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.” - OWASP

Page 40: Do you lose sleep at night?

CSRF Risk Level: MEDIUM

• Data compromise

• Availability compromise

Page 41: Do you lose sleep at night?

CSRF: How it works

• Target website needs privileged user logged in

• Draw targeted user to view page with exploited URLs

• Or click exploited URLs

Page 42: Do you lose sleep at night?

CSRF: Example

• Malicious user makes a comment

• Then logged in user reviews comment and executes that URL

Page 43: Do you lose sleep at night?

4) CSRF Solutions

• Force every operation to require unique authentication token to the logged in user

• Authentication token protection implemented at the database layer

• Well thought out frameworks require use of CSRF tokens for database changes are allowed

Page 44: Do you lose sleep at night?

5) Access control

• Broken, misconfigured access control

• Information disclosure

• misconfigured workflows

• file uploads containing metadata

• pre-package REST APIs giving out too much data

Page 45: Do you lose sleep at night?

5) Access control solutions

• Assume users will be lazy

• Private by default

• Scrub files

• exiftool(linux)

• Block any potential problem areas with web server rules

Page 46: Do you lose sleep at night?

Going DeeperSource: http://wallpapercow.com/wp-content/uploads/2014/06/Deep-Iceberg-HD-Desktop-Wallpaper.jpg

Page 47: Do you lose sleep at night?

Caching

• Sits in front of web application

• Caches content for a configured duration so the user does not hit the backend

• Varnish**

• Nginx(proxy_cache), Apache(mod_cache) do simple caching okay

• Apache Traffic Server

• Know your content, how to tune your cache

Page 48: Do you lose sleep at night?

Caching: server diagram

Page 49: Do you lose sleep at night?

CDN - Content Delivery Network

• Geographically dispersed caching servers

• WAF(Web Application Firewall)

• Serve stale content

• Keep cache warm

• Cloudflare

• Prepared for a stampede

Page 50: Do you lose sleep at night?

CDN network diagram

Page 51: Do you lose sleep at night?

WAF - Web Application Firewall

• CDN(Content Delivery Network)s often provide WAF

• Cloudflare

• Modsecurity(Apache)

• Naxsi(nginx)

Page 52: Do you lose sleep at night?

WAF diagram

Page 53: Do you lose sleep at night?

Load balancing

• Provide multiple application servers to handle requests from users

• Better, more resilient performance

• HAProxy**

• Nginx

• Apache

• Varnish

• CDN

Page 54: Do you lose sleep at night?

Load balancing diagram

Page 55: Do you lose sleep at night?

Database Selection

• NOSQL

• CouchDB/Couchbase

• ZODB(Python/Plone)

• RDMS: Support for replication

Page 56: Do you lose sleep at night?

Replication

• All database engines provide some sort of solution for replication

• Multiple servers can then server web application: better performance

• Different networks if possible

• Geographically dispersed

Page 57: Do you lose sleep at night?

Replication diagram

Page 58: Do you lose sleep at night?

Read-only / Read-write

• Can your web application be readonly?

• What parts of your solution require writes? Can they be done differently?

• For example: Disqus for commenting

• Different backend/frontend URLs

• Are there tools for your platform to do pseudo read-only mode?

• wildcard.readonly(Plone)

• https://github.com/collective/wildcard.readonly

• wildcard.lockdown(Plone)

• https://github.com/collective/wildcard.lockdown

Page 59: Do you lose sleep at night?

Performance and security

• Caching, CDN provide better performance

• Warm caches provide improved performance

• Keeps backends healthy to serve requests fast

• Replicated database provides added performance

• Geographically dispersed servers can provide lower latency

Page 60: Do you lose sleep at night?

Web server techniques

• Understand your application/deployment

• Minimize exposure

• Robust, fail resistant configurations

• Failover to back up replicated server, to static copy, etc

• Can you block certain types of requests?

• Rate limiting

• Careful not to on IP

Page 61: Do you lose sleep at night?

Two Factor Authentication

• Additional security for users

• Does your 2-factor solution work as a wrapper around your web application or is it just another token passed into the login form?

• https://github.com/wildcardcorp/factored

• Proxy

• Or Python WSGI filter

Page 62: Do you lose sleep at night?

Monitoring

• Know what is going on your systems

• Know traffic patterns

• CDN/Proxy reporting

• Log stash(https://www.elastic.co/products/logstash)

• Pingdom(https://www.pingdom.com/)

• Zabbix/Nagios/Munin/etc

• New relic, Sentry

• Cloud monitoring tools

• ossec(http://ossec.github.io/)

Page 63: Do you lose sleep at night?

Vulnerability Scanning Tools

• Will test web application against known exploit types

• Acunetix, Netsparker, etc

• https://www.owasp.org/index.php/Category:Vulnerability_Scanning_Tools

• Or google “vulnerability scanners”

• Some open source

• Some cloud solutions

Page 64: Do you lose sleep at night?

Add-ons and customizations

Source: http://cheezburger.com/5158827264

Page 65: Do you lose sleep at night?

Add-ons

• Assume ownership of every add-on you integrate

• You are responsible for security

• Audit code

• Do NOT just install any add-on you find

• Consider if you really need add-ons you install

Page 66: Do you lose sleep at night?

Add-ons and customizations

• How do you install?

• How do you update?

• What kind of access do they have?

• Are they allowed to execute arbitrary SQL queries?

• Do they run in a sandboxed mode?

• Reproducible builds?

Page 67: Do you lose sleep at night?

PHP

The most popular open source CMS systems are written in PHP; which has a suspect security track record.

Page 68: Do you lose sleep at night?

PHP: Problems

• Register globals: off

• Remote file inclusion: off

• Safe mode

• Works by executing scripts on filesystem

• Common to install/update add-ons through the web

• Common to patch it’s own code

Page 69: Do you lose sleep at night?
Page 70: Do you lose sleep at night?

What Plone does well

• Permissions checked *before* view code is executed

• CSRF protection at the database layer

• Input and output filtering on everything

• Add-ons must be installed by system administrators, process restart

• Through the web customizations run in sandboxed mode

• Monkey patching

Page 71: Do you lose sleep at night?

Final thoughts

• A small investment in security, resiliency = big payoff

• Understand web vulnerabilities

• Understand risks

• Be comfortable with your risks, exposure and technology

• Secure sites can be beautiful. The security of a site has nothing to do with it’s design