protecting plone from the big, bad internet

97
Protecting Plone From The Big, Bad Internet Steve McMahon Reid-McMahon, LLC Erik Rose WebLion, Pennsylvania State University

Upload: erik-rose

Post on 29-Nov-2014

3.237 views

Category:

Technology


4 download

DESCRIPTION

Steve McMahon and Erik Rose’s presentation on Plone security from Plone Conference 2008 in Washington, D.C.

TRANSCRIPT

Page 1: Protecting Plone from the Big, Bad Internet

Protecting Plone From

The Big, Bad Internet

Steve McMahonReid-McMahon, LLC

Erik RoseWebLion, Pennsylvania State University

Page 2: Protecting Plone from the Big, Bad Internet

<SteveM>

Page 3: Protecting Plone from the Big, Bad Internet

CVE Vulnerability Records

Page 4: Protecting Plone from the Big, Bad Internet

CVE Vulnerability Records

Common Vulnerabilities & Exposures

Page 5: Protecting Plone from the Big, Bad Internet

CVE Vulnerability Records

Common Vulnerabilities & Exposures

Page 6: Protecting Plone from the Big, Bad Internet

CVE Vulnerability Records

Common Vulnerabilities & Exposures

Page 7: Protecting Plone from the Big, Bad Internet
Page 8: Protecting Plone from the Big, Bad Internet

So, why

worry?

Page 9: Protecting Plone from the Big, Bad Internet

<Basics>

Page 10: Protecting Plone from the Big, Bad Internet

Defense in Depth

Page 11: Protecting Plone from the Big, Bad Internet

Defense in Depth

Page 12: Protecting Plone from the Big, Bad Internet
Page 13: Protecting Plone from the Big, Bad Internet

Single Wall Defense

Page 14: Protecting Plone from the Big, Bad Internet

Maginot Line

Page 15: Protecting Plone from the Big, Bad Internet

Maginot Line

Page 16: Protecting Plone from the Big, Bad Internet

Maginot Line

Page 17: Protecting Plone from the Big, Bad Internet

Maginot Line

Page 18: Protecting Plone from the Big, Bad Internet

Maginot Line

Page 19: Protecting Plone from the Big, Bad Internet

Failure of single wall defense

Page 20: Protecting Plone from the Big, Bad Internet

Failure of single wall defense

Page 21: Protecting Plone from the Big, Bad Internet

Proposition:

Zope is our Maginot Line

Page 22: Protecting Plone from the Big, Bad Internet

CVE-2007-5741

Original release date:11/07/2007

Last revised:09/05/2008

Source: US-CERT/NIST

Overview

Plone 2.5 through 2.5.4 and 3.0 through 3.0.2 allows remote attackers to

execute arbitrary Python code via network data

containing pickled objects for the (1) statusmessages or (2) linkintegrity

module, which the module unpickles and executes.

Page 23: Protecting Plone from the Big, Bad Internet

Principle of Least Privileges

Page 24: Protecting Plone from the Big, Bad Internet

Principle of Least Privileges

Page 25: Protecting Plone from the Big, Bad Internet

Principle of Least Privileges

Page 26: Protecting Plone from the Big, Bad Internet

</Basics>

Page 27: Protecting Plone from the Big, Bad Internet

Daemon Security

Page 28: Protecting Plone from the Big, Bad Internet

No Rights

Page 29: Protecting Plone from the Big, Bad Internet

Bad Example: Sendmail (1990s)

mailbox file

Sendmail*

/bin/mail*

to networkfrom network

local submission

local delivery * uses root privileges

to |command**

to /file/name**

** in ~/.forward files and in /etc/aliases

owned by recipient

executed as recipient

Page 30: Protecting Plone from the Big, Bad Internet

Good Example: Postfix

Compartmentalization

smtpd

local

pickup

smtpdinternet

smtp

server

other

programs

smtpdsmtpd

local

delivery

smtpdsmtpdsmtpclient

internet

mailbox

|command

/file/name

queue

directories

privileged

smtpdsmtpd

to external

transports

uucp

fax

pager

privileged

unprivileged

unprivileged

unprivileged

unprivileged

smtp

client

(local submission)

= root privilege

= postfix privilege

Page 31: Protecting Plone from the Big, Bad Internet

Good Example: Postfix

Compartmentalization

smtpd

local

pickup

smtpdinternet

smtp

server

other

programs

smtpdsmtpd

local

delivery

smtpdsmtpdsmtpclient

internet

mailbox

|command

/file/name

queue

directories

privileged

smtpdsmtpd

to external

transports

uucp

fax

pager

privileged

unprivileged

unprivileged

unprivileged

unprivileged

smtp

client

(local submission)

= root privilege

= postfix privilege

Page 32: Protecting Plone from the Big, Bad Internet

<Implementation>

Page 33: Protecting Plone from the Big, Bad Internet

<Implementation>

<File & Process>

Page 34: Protecting Plone from the Big, Bad Internet

Typical Installation

Process UID:

Plone

File Owner:

Plone

./var

./logs}

Page 35: Protecting Plone from the Big, Bad Internet

Typical Installation

Process UID:

Plone

File Owner:

Plone./parts

*.pyc

./var

./logs}

Page 36: Protecting Plone from the Big, Bad Internet

Why is that so bad?

Page 37: Protecting Plone from the Big, Bad Internet

Why is that so bad?

Daemon can write

into its own code

space.

Page 38: Protecting Plone from the Big, Bad Internet

A Better Way

Process UID:

Plone

File Owner:

Plone

./var

./logs}File Owner:

root./parts

*.py*}

Page 39: Protecting Plone from the Big, Bad Internet

Making it happen

Page 40: Protecting Plone from the Big, Bad Internet

Making it happen

Python-2.4/lib/python2.4/compileall.py

Via buildout:

[precompile]

recipe = plone.recipe.precompiler

Page 41: Protecting Plone from the Big, Bad Internet

Even Better: ZEO

Process UID:

zclient

./var

File Owner:

zeo

Process UID:

zeo

./parts

File Owner:

root

./client-log

File Owner:

zclient

Page 42: Protecting Plone from the Big, Bad Internet

Windows

Page 43: Protecting Plone from the Big, Bad Internet

</File & Process>

Page 44: Protecting Plone from the Big, Bad Internet

</Implementation>

</File & Process>

Page 45: Protecting Plone from the Big, Bad Internet

</Implementation>

</File & Process>

</SteveM>

Page 46: Protecting Plone from the Big, Bad Internet

<Port Security>

Page 47: Protecting Plone from the Big, Bad Internet

Reverse Proxy

Zope

Evil,

Monstrous

Internet

Page 48: Protecting Plone from the Big, Bad Internet

Reverse Proxy

Zope

Evil,

Monstrous

Internet

Page 49: Protecting Plone from the Big, Bad Internet

Reverse Proxy

Zope

Evil,

Monstrous

InternetApache

Page 50: Protecting Plone from the Big, Bad Internet

Reverse Proxy

Zope

Evil,

Monstrous

InternetApache

SSL

Page 51: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

8080

Page 52: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

zope.conf:

ip-address 127.0.0.1

Listen Locally

8080

Page 53: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

zope.conf:

ip-address 127.0.0.1

Listen Locally

Page 54: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ssh -L 3333:127.0.0.1:8080 [email protected] -N

Page 55: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ZEO

Page 56: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ZEO

8100

Page 57: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ZEO

zeo.conf:

address 127.0.0.1:8100

8100

Page 58: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ZEO

zeo.conf:

address 127.0.0.1:8100

Page 59: Protecting Plone from the Big, Bad Internet

Zope

Evil,

Monstrous

InternetApache

SSL

Listen Locally

ZEO

Page 60: Protecting Plone from the Big, Bad Internet

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Your Server

Page 61: Protecting Plone from the Big, Bad Internet

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

Your Server

Page 62: Protecting Plone from the Big, Bad Internet

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

Your Server

Page 63: Protecting Plone from the Big, Bad Internet

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

Your Server

Page 64: Protecting Plone from the Big, Bad Internet

iptables -A OUTPUT -p tcp --dport 81 -o lo \ -m owner ! --uid-owner www-data -j REJECT

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

Your Server

Page 65: Protecting Plone from the Big, Bad Internet

iptables -A OUTPUT -p tcp --dport 81 -o lo \ -m owner ! --uid-owner www-data -j REJECT

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

iptables -A OUTPUT -p tcp --dport 8100 -o lo \ -m owner ! --uid-owner zope -j REJECT

Your Server

Page 66: Protecting Plone from the Big, Bad Internet

iptables -A OUTPUT -p tcp --dport 81 -o lo \ -m owner ! --uid-owner www-data -j REJECT

Untrusted Local Users

Zope

(81)

ZEO

(8100)

Evil Dude

iptables -A OUTPUT -p tcp --dport 8100 -o lo \ -m owner ! --uid-owner zope -j REJECT

Your Server

Page 67: Protecting Plone from the Big, Bad Internet

Zope

(8080)

ZEO

(8100)

Your Server

Privileged Ports

Page 68: Protecting Plone from the Big, Bad Internet

Zope

(8080)

ZEO

(8100)

Your Server

Privileged Ports

Page 69: Protecting Plone from the Big, Bad Internet

ZEO

(8100)

Your Server

Privileged Ports

Page 70: Protecting Plone from the Big, Bad Internet

Evil Zope

(also 8080)

ZEO

(8100)

Evil Dude

Your Server

Privileged Ports

Page 71: Protecting Plone from the Big, Bad Internet

Evil Zope

(also 8080)

ZEO

(8100)

Evil Dude

Your Server

Privileged Ports

Page 72: Protecting Plone from the Big, Bad Internet

Evil Zope

(also 8080)

ZEO

(8100)

Evil Dude

Your Server

(2032) DO (1001) NEXT

(2036) PLEASE FORGET #1

DO .5 <- '?.1$.2'~'#0$#65535'

DO .5 <- '?"'&"!2~.5'~'"?'?.5~.

5'$#32768"~"#0$#65535"'"$

".5~.5"'~#1"$#2'~#3

DO (2034) NEXT

DO .5 <- .3

DO (1010) NEXT

PLEASE DO .1 <- .3

DO .3 <- 'V.4$.5'~'#0$#65535'

DO (2035) NEXT

(2034) PLEASE DO (1001) NEXT

(2035) DO FORGET #1

DO .5 <- "?'.4~#1'$#2"~#3

DO (2031) NEXT

DO .2 <- .2~#65534

(3010) PLEASE STASH .1 + .4 +

.5

PLEASE DO (1020) NEXT

DO .2 <- #0

DO .3 <- #2

DO .4 <- .1

DO (3012) NEXT

(3011) DO (1001) NEXT

(3012) PLEASE FORGET #1

DO (3000) NEXT

DO .5 <- '?"?.1~#256"$

#2'~#3

DO (3013) NEXT

DO .5 <- '?"'#65535~"'

?.

1$#10'~#21845"'~#1"$#1

'~#3

DO (3013) NEXT

DO .5 <- .1

DO .1 <- .2

(2536) PLEASE FORGET #1 DO :5 <- "'?":1~'#65535$#0'"$":2~'#65535$#0'"' ~'#0$#65535'"$"'?":1~'#0$#65535'"$":2~'#0$ #65535'"'~'#0$#65535'" DO .5 <- '?"'&"':2~:5'~'"'?"'?":5~:5"~"#65535$ #65535"'~'#65535$#0'"$#32768'~'#0$#65535'" $"'?":5~:5"~"#65535$#65535"'~'#0$#65535'"' "$"':5~:5'~#1"'~#1"$#2'~#3 DO (2534) NEXT DO :5 <- :3

Privileged Ports

Page 73: Protecting Plone from the Big, Bad Internet

</Port Security>

<Within Zope>

Page 74: Protecting Plone from the Big, Bad Internet

PluggableAuthService (PAS)

Page 75: Protecting Plone from the Big, Bad Internet

WebServerAutha PluggableAuthService plugin

Page 76: Protecting Plone from the Big, Bad Internet

WebServerAutha PluggableAuthService plugin

Redirects to HTTPS(Challenge)

Page 77: Protecting Plone from the Big, Bad Internet

WebServerAutha PluggableAuthService plugin

Redirects to HTTPS(Challenge)

Makes Zope believe the username header(Extraction, Authentication)

Page 78: Protecting Plone from the Big, Bad Internet

WebServerAutha PluggableAuthService plugin

Redirects to HTTPS(Challenge)

Makes Zope believe the username header(Extraction, Authentication)

Makes PAS behave(User Enumerator)

Page 79: Protecting Plone from the Big, Bad Internet

WebServerAutha PluggableAuthService plugin

Page 80: Protecting Plone from the Big, Bad Internet

<VirtualHost *:443> ServerName www.example.com # Prompt for authentication: <Location /> SSLRequireSSL AuthType Basic AuthName "My Funky Web Site" AuthUserFile /etc/such-and-such # (etc.) Require valid-user

WebServerAutha PluggableAuthService plugin

Page 81: Protecting Plone from the Big, Bad Internet

# Put the username (stored below) into the HTTP_X_REMOTE_USER # request header. This has to be in the <Location> block for # some Apache auth modules, such as PubCookie, which don't set # REMOTE_USER until very late. RequestHeader set X_REMOTE_USER %{remoteUser}e </Location> # Do the typical VirtualHostMonster rewrite, adding an E= option # that puts the Apache-provided username into the remoteUser # variable. RewriteEngine On RewriteRule ^/(.*)$ http://127.0.0.1:81/VirtualHostBase/https/ %{SERVER_NAME}:443/VirtualHostRoot/ $1 [L,P,E=remoteUser:%{LA-U:REMOTE_USER}]</VirtualHost>

WebServerAutha PluggableAuthService plugin

Page 82: Protecting Plone from the Big, Bad Internet

<VirtualHost *:80> ... RequestHeader unset X_REMOTE_USER ...</VirtualHost>

WebServerAutha PluggableAuthService plugin

Page 83: Protecting Plone from the Big, Bad Internet

LDAP

Page 84: Protecting Plone from the Big, Bad Internet

LDAPPloneLDAP + plone.app.ldap

Page 85: Protecting Plone from the Big, Bad Internet

LDAPPloneLDAP + plone.app.ldap

Users & groups in LDAP

Page 86: Protecting Plone from the Big, Bad Internet

LDAPPloneLDAP + plone.app.ldap

Users & groups in LDAP

Create & delete through Plone

Page 87: Protecting Plone from the Big, Bad Internet

LDAPPloneLDAP + plone.app.ldap

Users & groups in LDAP

Create & delete through Plone

Relax—written by Wiggy

Page 88: Protecting Plone from the Big, Bad Internet
Page 89: Protecting Plone from the Big, Bad Internet

Writing PAS Plugins

Page 90: Protecting Plone from the Big, Bad Internet

Writing PAS Plugins

PAS Reference Manualhttp://plone.org/documentation/manual/pas-reference-manual/referencemanual-all-pages

Page 95: Protecting Plone from the Big, Bad Internet

Questions?

• Reactor defense in depth:http://www.nea.fr/html/brief/images/br-8-1.gif

• Gate: Nuclear Power Plant Dungeness - Corey Holms 2008, CC Attribution

• Locks on door: Kansir, flikr, CC attribution license

• What me worry? Rev. Voodoo, flikr, CC Attribution, NC

• BSD Daemon: Created by Poul-Henning Kamp

• No Right Turn: greefus groinks' photostream, CC Attribution

• Sendmail and Postfix architecture diagrams: The Postfix mail server as a secure programming example, Wietse VenemaIBM T.J. Watson Research Center

• The Scream: Edvard Munk

• Shrug: spamily, flikr, CC by A

• Zope Pope photo: MrTopf

• PB&J photo: Northern Miniatures

• Other photos: Wikimedia Commons

• INTERCAL Numerical I/O lib: Brian Raiter

• Crown jewels of Denmark: King Christian IV

Image Credits

Steve [email protected]

Erik [email protected]

Page 97: Protecting Plone from the Big, Bad Internet

WebServerAuthAdvantages over apachepas + AutoMemberMaker

Redirects to HTTPS

No user clutter

Member and Authenticated roles are distinct

Sets up Log In link for you

Better test coverage; death to doctests

One product, not two