Top Banner
© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES 1 PENTESTER
47

Beating the Pentester

Jan 24, 2018

Download

Technology

Boy Baukema
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: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES1

PENTESTER

Page 2: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES2 © 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES.

Boy BaukemaSenior Application Security Consultant

Page 3: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES3 © 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES.

Adrian H.Pentester

Page 4: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES4 © 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES.

Adrian H.Enemy nr. 1

Page 5: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES5

Agenda

• Introduction

• Bare fists

• Baseball bats (Lucille)

• Assorted items

• Conclusions

Page 6: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES6

Page 7: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES7

Known

Vulnerabilities

Page 8: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES8

Page 9: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES9

Page 10: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES10

Page 11: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES11

Page 12: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES12

Attack: Known Vulnerabilities

Your application Other applications

Framework (Composer) Libraries

PHP Interpreter

Webserver (Apache, Nginx) Other services

Operating System

Page 13: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES13

https://snyk.io/blog/owasp-top-10-breaches/

Top of the charts

Page 14: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES14

Defense: Monitoring & patching

• Monitor security patches for third party software

• Be prepared to fix rapidly (DevOps)

Page 15: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES15

Docker effect

Your application

Your Framework Your (Composer) Libraries

Your PHP Interpreter

Your Webserver (Apache,

Nginx)

Your other services

Operating System

Page 16: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES16

Injection

Page 17: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES17

I blame Doug Mclroy, and so should you

Write programs to handle text streams, because that is a universal interface.

Page 18: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES18

Angular templates

Content

CSS

CSV

HTTP Header

HTML

JavaScript / JSON

URL

XML

CSV

Database (ORM)

File paths

HTTP

LDAP

Logs (syslog)

Memcached

Shell

Solr

Eval

Math

Sprintf

Regexp

APPLICATION

Page 19: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES19

Little bit of template code, many contexts

Page 20: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES20

PHP HTML JS URL

Page 21: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES21

Attack: Breaking out into the URL

Page 22: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES22

Attack: Breaking out into JavaScript

Page 23: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES23

Attack: Breaking out into HTML

Page 24: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES24

Defense: Separation of Concerns &Contextual encoding ALAP

Page 25: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES25

Defense: Validate ASAP

• Does it have a datatype?

• Can it be of infinite length?

– Does your storage impose size limits?

• Can it be any arbitrary byte?

– Should it conform to a pattern?

– Should it match a known value in the data storage?

– Should it be UTF-8? Printable?

http://phpsecurity.readthedocs.io/en/latest/Input-Validation.html

Page 26: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES26

Validate HTML Script content

Page 27: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES27

Defense: Immutable Value Object

Page 28: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES28

So much more…

Page 29: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES29

• OWASP Top 10

• OWASP Application Security Verification Standard (ASVS)

• OWASP Testing Guide

• MITRE Common Weakness Enumeration

• github.com/PaulSec/awesome-sec-talks

• https://h1.sintheticlabs.com/bounties.html

Page 30: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES30

Training

• Basics:

– Zend Certification

• Advanced:

– OWASP

– Security Vendor

Page 31: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES31

• NULL byte attacks

• JSON </script> injection

• XML External Entities

• Preg_match /e

• Remote File Inclusion

• HTTP Header injection

Deprecated attacks

Page 32: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES32

Improved features

• random_bytes

• password_hash

• htmlentities defaults

• Blade / Twig

• PSR-7 (vs $_ globals)

• PDO Prepared Statements

Page 33: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES33 © 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES

If you know the pentesterbut not yourself, for every validation added you will also suffer a security bug.

― Sun Tzu

Page 34: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES34

• Accessibility

• Availability

• Backup

• Compliance

• Documentation

• Fun

• Maintainability

Non-functional requirements

• Performance

• Platform compatibility

• Reporting

• Scalability

• Security

• Usability

wikipedia.org/wiki/Non-functional_requirement

Page 35: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES35

Security Requirements

Page 36: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES36

Security Grooming

• Security Champion

Page 37: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES37

Quick and dirty threat modelling

1. What are you building?

2. What can go wrong?

3. What should you do about that?

4. Did you analyse that correctly?

Page 38: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES38

As a user I would like to reset my password if I have forgotten it.

What are we building?

Page 39: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES39

• Spoofing

• Tampering

• Repudiation

• Information leakage

• Denial of Service

• Elevation of Privilege

What can go wrong?

Page 40: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES40

What should we do?

• … and did we analyse correctly?

Page 41: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES41

Доверяй, но проверяй

• Embedding security:

– Code Review

– Functional Testing

– Unit testing

– Security Testing (OWASP ASVS)

• Security tooling:

– Static Application Security Testing (SAST)

– Dynamic Application Security Testing (DAST)

– Fuzzing

– Manual Penetration Testing

Page 42: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES42

Page 43: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES43

Operations

• Password hygiene:

– Password Manager

– 2 Factor Authentication

– Have I Been Pwned?

• PhishMe

• Encrypted storage

• Testing system recoveries

• Firewall

Page 44: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES44

PENTESTER

Page 45: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES45

PENTESTER

Page 46: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES46 © 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES.

Thank Youjoind.in/talk/f8142

veracode.com/demo

Page 47: Beating the Pentester

© 2017 VERACODE INC. ACQUIRED BY CA TECHNOLOGIES47

Images

• Brain by Nicholas Herdemanhttps://www.flickr.com/photos/95943853@N00/17584291945/

• CCTV by Peter Hellberghttps://www.flickr.com/photos/peterhellberg/5119089864

• Doug McIlroy by Faces of Open Source http://facesofopensource.com/doug-mcilroy/

• 125/365 Dolls in the Rain by Joe Lodge https://www.flickr.com/photos/joe57spike/5690570945