move fast and secure things - owasp · 4/4/2019  · – continuous detection [+ prevention] •...

27
Move fast and secure things

Upload: others

Post on 27-Jul-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

Move fast and secure things

Page 2: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

About Me

$whoami – Security engineer @ Fb > 2 years – Security consultant – I <3 CTFs (LC/BC) – I <3 server side bugs and automating the

detection – @the_st0rm

Page 3: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Agenda – Setting the scene – Securing the codebase – Example of rules – Static analysis use cases – Myth busting – Demo! :O

!3

Page 4: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Engineering @ FB

!4

> 100k commits per week

Big Code: Developer Infrastructure at Facebook's Scale

https://www.facebook.com/FacebookforDevelopers/videos/10152800517193553/

Page 5: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Engineering @ FB

!5

Page 6: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

“Nothing at Facebook is somebody else's problem”

!6

Page 7: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Securing the codebase – Secure frameworks – Security reviews – Automation (static and dynamic analysis) – Whitehat

!7

Page 8: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Secure frameworks – XHP – Hack – Django

• Limitations – Enforcement – Depends on the engineer

!8

Page 9: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Manual security reviews – Find cool bugs

• Limitations – Time consuming – Does not scale – Completeness

!9

Page 10: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Automation (Program analysis) – Scales – Find low hanging fruits – And difficult bugs (Fuzzing) – Continuous detection [+ prevention]

• Limitations – False positives and negatives – Difficult to get right

!10

Page 11: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Whitehat – Continuous detection – Very unique bugs/talent

• Limitations – Test in prod! – Expensive for small companies? – Signal to noise ratio

!11

Page 12: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

Automation (static analysis)

!12

Page 13: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Automation (static analysis) – Scale

– Tens of millions LoC – Thousand commits/day

– Performance • No run-time overhead (e.g fuzzing) • Grepping millions of LoC

– Completeness – Proactive vs Reactive

!13

Page 14: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Static analysis design

!14

new bug can do with SA?

Yes

No

Oops

add a rule

refine with SWE

triage master

monitor diffs

bug is dead

whitehat

security review

Page 15: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Tips to build good static analysis – Coverage

• Understand the attack surface • Define sources • Define sinks

– Simplicity • Easy to use • Configuring the sources/sinks • Adding sanitizers

!15

Page 16: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Tips to build good static analysis – Improving signal

• Excluding False positives • Finding false negatives

– Feedback to the framework – Speed

!16

Page 17: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Security vulnerabilities we detect – We can currently detect more than 20 types of

security issues including • Higher-order command injection • HTTP status codes as privacy oracles • Arbitrary file reads/writes • Server-side Request Forgery (SSRF) • SQL • XSS

!17

Page 18: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Bug detection - Arbitrary file reads/writes – Filename going to dangerous function

!18

Page 19: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Bug detection - command injection

!19

$t = attacker_controlled();// … many lines …execx(“zip %s”, $t);

$t = attacker_controlled();// …execx(“zip a.zip -T '--unzip-command=%s'”, $t);

• Commands can execute other commands • Static analysis tool can understand format string

• Secure because of high-quality frameworks

Page 20: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Bug detection - Privacy oracles

!20

$group_id = attacker_controlled();if ($group_id === 100)

throw HTTP_404();

$group_id = attacker_controlled();// load with privacy check$data = isMember(auth_user(), group_id);if ($data === null) throw HTTP_404();

– Static analysis can check • action taken under attacker control? • action is influenced by privacy check?

Page 21: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Use cases – Regular analysis

• Triaged by security engineers • Triaged by team owners

– On-demand analysis • Whitehat report • Security reviews

Page 22: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Use cases – Diff analysis

• Analyze base repo • Analyze base repo + diff • Find new issues • High confidence issues => auto comment • Mid confidence => Oncall/product team

Page 23: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Myth busting – Does it scale?

• 20 mins for 10s millions of LoC – Is it precise?

• “Static analyzers are noisy” – Is it useful?

• “They only find trivial errors”

!23

Page 24: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

• Analysis dashboard

!24

Page 25: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

– Pyre is a fast, scalable type checker for large Python 3 codebases

– Open source • Python static analysis? • Demo?

pyre-check.org

• Have you heard about Pyre?

!25

Page 26: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

We are hiring <3

!26

Page 27: Move fast and secure things - OWASP · 4/4/2019  · – Continuous detection [+ prevention] • Limitations – False positives and negatives – Difficult to get right!10 • Whitehat

Questions?

!27