158
@thomas_shone Image by Matt McGee released under CC BY-ND 2.0 Security Theatre

Security theatre (Scotland php)

  • Upload
    xsist10

  • View
    180

  • Download
    3

Embed Size (px)

Citation preview

Page 2: Security theatre (Scotland php)

Booking.com

Page 4: Security theatre (Scotland php)

Denial

Page 5: Security theatre (Scotland php)

Illusion

Page 6: Security theatre (Scotland php)

I know about OWASP!

Page 7: Security theatre (Scotland php)

If you are hacked via OWASP Top 10, you’re not allowed to call it “advanced” or “sophisticated”

@thegrugq

Reference: https://twitter.com/thegrugq/status/658991205816995840

Page 8: Security theatre (Scotland php)

But I use antivirus!

Page 9: Security theatre (Scotland php)

Crypting makes antivirus techniques useless

Reference: http://krebsonsecurity.com/2014/05/antivirus-is-dead-long-live-antivirus/

Page 10: Security theatre (Scotland php)
Page 11: Security theatre (Scotland php)

Unsecured node.js server

TrendMicro Antivirus on WindowsJan 2016

https://code.google.com/p/google-security-research/issues/detail?id=693

Page 12: Security theatre (Scotland php)

Remote code-executions via Buffer Overflow

Sophos AntivirusJune 2015

https://lock.cmpxchg8b.com/sophailv2.pdf

Page 13: Security theatre (Scotland php)

Double Agent Attack

Avast, AVG, Avira, Bitdefender, TrendMicro, Comodo, ESET, F-Secure, Kaspersky, Malwarebytes, McAfee, Panda, Quick Heal,

and Norton - March 2017https://www.wired.com/2017/03/clever-doubleagent-attack-turns-antivirus-malware/

Page 14: Security theatre (Scotland php)
Page 15: Security theatre (Scotland php)

Internet of Things

Page 16: Security theatre (Scotland php)
Page 17: Security theatre (Scotland php)
Page 18: Security theatre (Scotland php)

Reference: https://www.yahoo.com/tech/dutch-consumer-group-demands-samsung-151703102.html

Page 19: Security theatre (Scotland php)

We’re all bad at security

Page 20: Security theatre (Scotland php)

Users

Page 21: Security theatre (Scotland php)

Developers

Page 22: Security theatre (Scotland php)

Hackers

Page 23: Security theatre (Scotland php)

A study in scarlet

Page 24: Security theatre (Scotland php)

43 applications, libraries and frameworksover 4,800 versionsover 10 million files

Page 25: Security theatre (Scotland php)

255,000 scansAbout 6k/month from June 2012 - Nov 2015

Page 26: Security theatre (Scotland php)

ResultsJuly 2015

Page 27: Security theatre (Scotland php)

Most popular softwareIt’s not what you think

Page 28: Security theatre (Scotland php)
Page 29: Security theatre (Scotland php)
Page 30: Security theatre (Scotland php)
Page 31: Security theatre (Scotland php)

How bad is it?

Page 32: Security theatre (Scotland php)
Page 33: Security theatre (Scotland php)
Page 34: Security theatre (Scotland php)

Why is it so bad?

Page 35: Security theatre (Scotland php)
Page 36: Security theatre (Scotland php)
Page 37: Security theatre (Scotland php)
Page 38: Security theatre (Scotland php)
Page 39: Security theatre (Scotland php)

I have seen thingsPh'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

Page 40: Security theatre (Scotland php)
Page 41: Security theatre (Scotland php)

Versioning Hell1.3-final-beta6-pre-patch3

Page 42: Security theatre (Scotland php)

OpenXBackdoored for almost a year

Page 43: Security theatre (Scotland php)
Page 44: Security theatre (Scotland php)

Lessons Learnt

Page 45: Security theatre (Scotland php)

VersioningProjects with bad versioning also have some

of the worst security issues

Page 46: Security theatre (Scotland php)

Automatic PatchingIf your software comes with automatic

upgrading, people will use it

Page 47: Security theatre (Scotland php)

Plugins and TemplatesIf an update needs manual changes for

plugins or template, no one updates

Page 48: Security theatre (Scotland php)

Image by Aaaron Jacobs released under CC BY-SA 2.0

Patch Fatigue Exists

Page 49: Security theatre (Scotland php)

Image by Josh Janssen released under CC BY-ND 2.0

Anger

Page 50: Security theatre (Scotland php)

Why doesn’t someone do something about it?

Page 51: Security theatre (Scotland php)

Private industry keep threatening security researchers

List of well referenced situations of the above: http://attrition.org/errata/legal_threats/

Page 52: Security theatre (Scotland php)
Page 53: Security theatre (Scotland php)
Page 54: Security theatre (Scotland php)
Page 55: Security theatre (Scotland php)
Page 56: Security theatre (Scotland php)
Page 57: Security theatre (Scotland php)

"How many Fortune 500 companies are hacked right now?

Answer, 500."Mikko Hypponen, CRO of F-Secure

Reference: https://twitter.com/mikko/status/184329161257652227

Page 58: Security theatre (Scotland php)

Why don’t we have some form of standard?

Page 59: Security theatre (Scotland php)

We have ISO 27001/2, ISO 15408, RFC 2196, PCI DSS, NIST, …

Reference: https://en.wikipedia.org/wiki/Cyber_security_standards

Page 60: Security theatre (Scotland php)

Why doesn’t the government do something about it?

Page 61: Security theatre (Scotland php)

Don’t lump me in with

those idiots.

Page 62: Security theatre (Scotland php)

Reference: https://t.co/PA7cDQC9EIImage by Unknown released into the Public Domain

Page 63: Security theatre (Scotland php)

Fine… no backdoor in E2E encryption.

Julian King, Security Commissioner, EU

Reference: https://www.theregister.co.uk/2017/10/19/eu_crypto_cracking/

Page 64: Security theatre (Scotland php)

Fine… no backdoor in E2E encryption. But store everything

in plaintext.

Rod Rosenstein, Deputy Attorney General, USA

Reference: https://www.theregister.co.uk/2017/10/30/encryption_backdoors_plaintext_deputy_ag/

Page 65: Security theatre (Scotland php)

Image by Jeroen Moes released under CC BY-SA 2.0

Bargaining

Page 66: Security theatre (Scotland php)

But what if we installed advanced IDSs, WAFs and

specialised network hardware

Page 67: Security theatre (Scotland php)

We probably only knew about one of the two backdoors in our

system

Juniper NetworksDec 2015

http://www.wired.com/2015/12/juniper-networks-hidden-backdoors-show-the-risk-of-government-backdoors/

Page 68: Security theatre (Scotland php)

Depression

Page 69: Security theatre (Scotland php)

Ninety percent of everything is crap.

Sturgeon's law

Reference: https://en.wikipedia.org/wiki/Sturgeon%27s_law

Page 70: Security theatre (Scotland php)

Infosec - A profession that turns normal people into whiskey drinking,

swearing, paranoid, disheartened curmudgeons with no hope for the future of computers or humanity.

@mzbat

Reference: https://www.urbandictionary.com/define.php?term=Infosec

Page 71: Security theatre (Scotland php)

Image by Stephan Brunet released under CC BY-SA 3.0

Acceptance

Page 72: Security theatre (Scotland php)

Effective?

Page 73: Security theatre (Scotland php)

Most of our security practices are ineffective

Page 74: Security theatre (Scotland php)

We do security in isolation

Page 75: Security theatre (Scotland php)

Holistic

Page 76: Security theatre (Scotland php)

Hardware

Drivers

Services

Your Dependencies

Operating System

Your Software

Humans

Network / Internet

Area of Influence

Page 77: Security theatre (Scotland php)

Drivers

Services

Operating System203.5M LoC

Area of Influence

Hardware

Disclaimer: Numbers generated using cloc (Service LoC limited to latest releases of MySQL, Apache and PHP)

Page 78: Security theatre (Scotland php)

Operating SystemArea of Influence

Humans DNA7B LoC

Source: http://www.examiner.com/article/dna-the-ultimate-source-code

Page 79: Security theatre (Scotland php)

Hardware

Drivers

Services

Your Dependencies

Operating System

Your Software

Humans

Network / Internet

HR/Training/LART device

System Administrators

Downstream Providers

Page 81: Security theatre (Scotland php)

Surface Area

Image by Albert Bridge released under CC BY-SA 2.0

Page 83: Security theatre (Scotland php)

Image by Pivari.com released under CC BY-SA 3.0

Mitigation

Page 84: Security theatre (Scotland php)

Trust

Page 85: Security theatre (Scotland php)

Trust??????

Page 86: Security theatre (Scotland php)

Be aware of what you’re trusting

Page 87: Security theatre (Scotland php)

The hardest part of security is not writing

secure code

Page 88: Security theatre (Scotland php)

It’s understanding where you’re misplace

your trust

Page 89: Security theatre (Scotland php)

Trust is a chain

Page 90: Security theatre (Scotland php)

I trust my computer is not compromised

Up-to-date patches

TRUST

Page 91: Security theatre (Scotland php)

I trust that the software is without vulnerability

Vulnerability research and security updates

TRUST

Page 92: Security theatre (Scotland php)

I trust that the software is configured properly

Automated provisioning

TRUST

Page 93: Security theatre (Scotland php)

I trust that the network is configured properly and secure

Good system administrators

TRUST

Page 94: Security theatre (Scotland php)

I trust you are who you say you are

TLS Certificate Peer Verification or Authentication

TRUST

Page 95: Security theatre (Scotland php)

I trust you are allowed to talk to me about this topic

Authorization

TRUST

Page 96: Security theatre (Scotland php)

I trust that what you send me hasn’t been tampered with

Hashes, CRCs or signatures

TRUST

Page 97: Security theatre (Scotland php)

I trust that what we talk about is just between us

Public and private keys

TRUST

Page 98: Security theatre (Scotland php)

I trust your computer is not compromised

????

TRUST

Page 99: Security theatre (Scotland php)

I trust that what we talk about won’t be share with others

Contracts, Legalities, Terms of use, ????

TRUST

Page 100: Security theatre (Scotland php)

I trust that the user won’t be the weak link

Training and procedures

TRUST

Page 101: Security theatre (Scotland php)

Turn your chain into a mesh

Image by ineverfinishanyth released under CC BY-NC-SA 2.5

Page 102: Security theatre (Scotland php)

Common Mistakes

Page 103: Security theatre (Scotland php)

WeakeningCompromising encryption or hashing is

about reducing time to crack

Page 104: Security theatre (Scotland php)

ImplementationA bad implementation helps reduce the time

to crack

Page 105: Security theatre (Scotland php)

Authentication

Page 106: Security theatre (Scotland php)

2 Factor Authenticationcomposer require pragmarx/google2fa

Page 107: Security theatre (Scotland php)

OAuth2composer require league/oauth2-client

Page 108: Security theatre (Scotland php)

Sessions

Page 109: Security theatre (Scotland php)

Image by Wouter van Emmerik released under CC BY-SA 3.0

Never roll your own

Page 110: Security theatre (Scotland php)

if (strstr($_SERVER['QUERY_STRING'],'session_to_unset') != false){ parse_str($_SERVER['QUERY_STRING']); session_write_close(); session_id($session_to_unset); session_start(); $_SESSION = array(); session_write_close(); session_destroy(); exit;}

MistakesDeep understanding of the language

Reference: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2505

CODE SAMPLE

Page 111: Security theatre (Scotland php)

if (strstr($_SERVER['QUERY_STRING'],'session_to_unset') != false){ parse_str($_SERVER['QUERY_STRING']); session_write_close(); session_id($session_to_unset); session_start(); $_SESSION = array(); session_write_close(); session_destroy(); exit;}

MistakesDeep understanding of the language

Reference: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2505

Writes $_SESSION to disk

CODE SAMPLE

Page 112: Security theatre (Scotland php)

if (strstr($_SERVER['QUERY_STRING'],'session_to_unset') != false){ parse_str($_SERVER['QUERY_STRING']); session_write_close(); session_id($session_to_unset); session_start(); $_SESSION = array(); session_write_close(); session_destroy(); exit;}

MistakesDeep understanding of the language

CODE SAMPLE

Extracts URL parameters into the namespace.

session_to_unset=a becomes $session_to_unset = “a”;

Reference: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2505

Page 113: Security theatre (Scotland php)

Encryption

Page 114: Security theatre (Scotland php)

Image by Wouter van Emmerik released under CC BY-SA 3.0

Never roll your own

Page 115: Security theatre (Scotland php)
Page 116: Security theatre (Scotland php)

Avoid old tutorials on encryption

https://gist.github.com/paragonie-scott/e9319254c8ecbad4f227

Page 117: Security theatre (Scotland php)

Failed: Error Number: 60. Reason: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

// Many old tutorials and posts suggest disabling peer verificationscurl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// Thankfully PHP 5.6+ handles CA certificate location automatically// thanks to https://wiki.php.net/rfc/improved-tls-defaults and// Daniel Lowrey

Avoid advice like thisWeakening security for convenience

CODE SAMPLE

Page 118: Security theatre (Scotland php)

Hashing

Page 119: Security theatre (Scotland php)

Image by Wouter van Emmerik released under CC BY-SA 3.0

Never roll your own

Page 120: Security theatre (Scotland php)

One way encodingComparisons / Integrity Checks

Page 121: Security theatre (Scotland php)

Weak hash functions+/- 690GB rainbow tables

Reference: http://project-rainbowcrack.com/table.htm

Page 122: Security theatre (Scotland php)

4,797,089,933Number of accounts publicly leaked

Reference: https://haveibeenpwned.com/

Page 123: Security theatre (Scotland php)

$password = 'rasmuslerdorf';$hash = '$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a';

// Is this call safe?if (crypt($password, $hash) === $hash) { echo 'Password is correct';}// What about this one?if (password_verify($password, $hash)) { echo 'Password is correct';}

Bad implementationWhere is the weakness?

CODE SAMPLE

Page 124: Security theatre (Scotland php)

Timing AttacksBrute forcing cryptographic functions via

time taken to execute

Page 125: Security theatre (Scotland php)

$string1 = 'abcd';$string2 = 'abce';$string3 = 'acde';

for ($i=0; $i<10000; $i++) { ($string1 === $string2); }// Time taken: 0.008344

for ($i=0; $i<10000; $i++) { ($string1 === $string3); }// Time taken: 0.006923

Timing AttacksHow it works

CODE SAMPLE

Page 126: Security theatre (Scotland php)

Timing attacks can be used to work out if an account exists [...].

@troyhunt, haveibeenpwned.com

Reference: https://t.co/5WkQ48suj7

Page 127: Security theatre (Scotland php)

Well actuallyAmount of randomness matters

Reference: http://blog.ircmaxell.com/2012/12/seven-ways-to-screw-up-bcrypt.html

Page 128: Security theatre (Scotland php)

$password = 'rasmuslerdorf';$hash = '$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a';

// Check the passwordif (password_verify($password, $hash)) { echo 'Password is correct'; if (password_needs_rehash($hash, PASSWORD_DEFAULT)) { // Rehash and store in database $new_password = password_hash($password, PASSWORD_DEFAULT); }}

RehashBuild it into your flow

CODE SAMPLE

Page 129: Security theatre (Scotland php)

Randomness

Page 130: Security theatre (Scotland php)

Image by Wouter van Emmerik released under CC BY-SA 3.0

Never roll your own

Page 131: Security theatre (Scotland php)

Non-deterministic randomness is critical in encryption

Used for key generation and nonces

Page 132: Security theatre (Scotland php)

Non-deterministic randomness is hard

Dual_EC_DRBG was in use for 7 years

Page 133: Security theatre (Scotland php)

// NOT cryptographically securerand();

// Cryptographically secure (uses OS-specific source)random_int();

// Cryptographically secure (uses OS-specific source)random_bytes();

// Cryptographically secure (uses OpenSSL library)openssl_random_pseudo_bytes();

Random in codeKnow the source

CODE SAMPLE

Page 134: Security theatre (Scotland php)

Information Disclosure

Page 135: Security theatre (Scotland php)

HEAD http://example.com/index.php200 OKConnection: closeDate: Sat, 26 Dec 2015 13:52:01 GMTServer: ApacheContent-Type: text/html; charset=UTF-8Client-Date: Sat, 26 Dec 2015 13:52:01 GMTClient-Peer: 192.168.0.101:80Client-Response-Num: 1X-Powered-By: PHP/5.5.11

Information DisclosureEvery piece of information can be leveraged

LOG SAMPLE

Page 136: Security theatre (Scotland php)

HEAD http://example.com/index.php200 OKConnection: closeDate: Sat, 26 Dec 2015 13:52:01 GMTServer: ApacheContent-Type: text/html; charset=UTF-8Client-Date: Sat, 26 Dec 2015 13:52:01 GMTClient-Peer: 192.168.0.101:80Client-Response-Num: 1X-Powered-By: PHP/5.5.11

Information DisclosureEvery piece of information can be leveraged

LOG SAMPLE

Page 137: Security theatre (Scotland php)

Warning: require(assets/includes/footer.php) [function.require]: failed to open stream: No such file or directory in /home/user/path/to/assets/includes/operations.php on line 38

Fatal error: require() [function.require]: Failed opening required 'assets/includes/footer.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/path/to/assets/includes/operations.php on line 38

Information DisclosureEvery piece of information can be leveraged

LOG SAMPLE

Page 138: Security theatre (Scotland php)

Social Engineering

Page 139: Security theatre (Scotland php)

Weak password reset processes

Can you Google the answer?How do you handle customer support reset?

Page 140: Security theatre (Scotland php)

Customer support training

Convenience vs Security

Page 141: Security theatre (Scotland php)

@N’s (Naoki Hiroshima) Story

How do you mitigate against this?

Page 142: Security theatre (Scotland php)

Image by Jenny released under CC BY-NC-ND 2.0

Hope

Page 143: Security theatre (Scotland php)

Holistic

Page 144: Security theatre (Scotland php)

A.B.C.

Page 145: Security theatre (Scotland php)

Always Be C Patching

Page 146: Security theatre (Scotland php)

Patching StrategyIf a dependency prevents updating, resolve it

now

Page 147: Security theatre (Scotland php)

Version properlyMajor.Minor.Patch. How hard is that?

Page 148: Security theatre (Scotland php)

Don’t become comfortable

Comfort breeds contempt

Page 149: Security theatre (Scotland php)

ReadKnow about new threats and best practice

changes

Page 150: Security theatre (Scotland php)

Training StrategyHave a process for dealing with account

locks and resets

Page 151: Security theatre (Scotland php)

Compromise StrategyHave a plan before you need it

Page 152: Security theatre (Scotland php)

InformationOnly store what you really need

Page 153: Security theatre (Scotland php)

Mistakes will be madeLearn from them

Page 154: Security theatre (Scotland php)

Rate limitBuilt it now, or you’ll have to build it while an

incident is underway

Page 155: Security theatre (Scotland php)

Monitor everythingYou’re more likely to be alerted by a graph

spiking than your IDS

Page 156: Security theatre (Scotland php)

Decouple rolesDatabases, servers, domains, roles, ...

Page 158: Security theatre (Scotland php)

Thank youhttps://joind.in/talk/0a184

@thomas_shone