SlideShare uma empresa Scribd logo
1 de 63
Baixar para ler offline
HOW NOT TO
SUCK AT CYBER
SECURITY
Chris Watts - Feb 2016
DON’T BE
EBAY
In 2015 there were
+38%more cyber security incidents than in 2014
Global State of Information Security® Survey 2016
Proportion of companies reporting a security incident
Global State of Information Security® Survey 2016
CUSTOMER RECORDS
Global State of Information Security® Survey 2016
38.27% of compromised assets
EMPLOYEE RECORDS
33.25% of compromised assets
While there is no guarantee against
being breached, organizations can
greatly manage their risk by becoming
more vigilant in covering their bases.
- Mike Denning, Vice President for Global Security, Verizon
According to the Pareto Principle
80%of the effects are from
20%of the causes
Software bugs are not exempt from this rule
BACK TO THE
RECENT EBAY
HACK
JS NIGHTMARES
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+
[] + [] === ''
[] + {} === [object Object]
{} + [] === 0
{} + {} === NaN
QUIRKY!
https://www.destroyallsoftware.com/talks/wat
HOW TO MAKE
A LANGUAGE
NAND or NOR gates will let you build anything!
With an array of NAND or NOR gates, you can build any
other logic gate. Hence FPGAs!
In software, if you have a NOT expression and an OR expression, you
can emulate any other logic circuit!
If you can emulate logic circuits, you can emulate a Turing machine.
Pretty much every language already has this requirement [!+]
TURING TARPITS
Some people just want to watch the world burn
This is an example of Hello World in Brainfuck
++++++++[>++++
[>++>+++>+++>+<<<<-]
>+>+>->>+[<]<-]
>>.>---.+++++++..+++.>>.
<-.<.+++.------.--------.>>+.>++.
To be Turing-complete, an
imperative language must:
1. Allow conditional branching
2. Allow read/write access to random
memory
To be Turing-complete, a
functional language must:
1. Allow abstraction of functions over
arguments
2. Allow application of functions to
arguments
ENTER JSFUCK
A Turing-complete sub-language of JavaScript that runs in the same
environment as real JavaScript. And yes, it’s Turing-complete.
false => ![]
true => !![]
undefined => [][[]]
NaN => +[![]]
0 => +[]
1 => +!+[]
2 => !+[]+!+[]
Problem: Lots of people want cat pictures
and illegible formatting in their listings
Solution: Let them insert HTML!
Normally, one filters out everything that
has the potential to do bad with
user-submitted HTML
USER INPUT IS A
DANGEROUS THING
In fact, the best idea is to just avoid it and
say no, but customers will be customers.
LET’S LEAVE IN
<SCRIPT> TAGS!
Now we can offer more
features like advertising!
And lawsuit-worthy user tracking!
Hey let’s just check for alphanumerics! It’s a super easy regex.
/<script>w+</script>//ig
ALL WE NEED TO DO IS DISALLOW ALL
STRINGS WITHIN <SCRIPT> TAGS
SUBMITTED BY USERS
It will be fine, nobody is ever going to
be able to execute JavaScript without
alphanumerics despite JS being even
sketchier than C++[1]
- some dev at eBay
NAILED ITNAILED IT
Two researchers by the names of Charlie
Miller and Chris Valasek were able to
connect to GM’s OnStar entertainment
system from 2012 to 2015.
Turns out the entertainment system is
connected to the ECU, braking, tire
pressure monitoring and steering systems.
OF COURSE, IT’S NOT JUST
EBAY
From 10 miles away, they were able to
turn up the car stereo, switch on the
wipers, and crash the car flat-out into a
ditch.
It will be fine, nobody is ever going to
control the car through the
entertainment system
- some dev at GM
LET’S NOT FOLLOW SUIT
DESIGN AS
THE
ANTI-USER
SQL INJECTION
https://xkcd.com/327/
A SIMPLE ATTACK
<?php
$page = $_GET[‘page’];
$query = “SELECT * FROM transactions LIMIT $page * 20, 20”;
...
?>
https://www.securebank.com/transactions/view/3/
https://www.securebank.com/transactions/view/3;DROP USER admin;--/
SOLUTION
NEVER trust user-supplied information. Hidden form fields and cookies are also not safe.
VALIDATE your inputs. Expecting a number? Assert that!
ALWAYS use prepared statements - don’t insert directly into SQL statements
$statement = $db->prepare(“SELECT * FROM transactions LIMIT :page, 20”);
$statement->bindParam(‘page’, $page * 20);
You would think there’s no harm in leaving the version numbers of
your Wordpress installation in the headers or footers of your web
page.
Some version information also appears in HTTP headers, for
example: ‘X-Powered-By: My Cool CMS v3.3.6’
INFORMATION LEAKAGE
EXPLOIT-DB
REMOVE all version identifiers from everything your server sends
CHECK what happens on a server error. Does the 500 page show
anything useful to a hacker?
REMOVE all debugging information, or have it sent to log files
SOLUTION
INFORMATION EXPOSURE
Sometimes your text editors are the enemy...
Of course, Database.php~ is no longer a .php file, so will not get executed when you
navigate to it.
Instead, it will just download the file to the user, containing the actual PHP code and
passwords!
SOLUTION
WHITELIST rather than blacklist files that are allowed to be displayed to the user (e.g. in
.htaccess)
DELETE all temporary files on the production server, edit files on a development server
before pushing.
MOVE all non-static (e.g. html, jpg, css) files out of the document root. Especially
configuration files.
USER UPLOADS
By performing the previous steps, you can also protect yourself from malicious uploads
being executed.
This does not replace the need to check file contents though as if the file exists on the
server, it’s more than likely the attacker will find a way to execute it.
Remember the Heartbleed bug of 2014?
In 2015 there were still swaths of unprotected servers due to
negligence and unwillingness to update.
OUTDATED SOFTWARE
sudo apt-get update
sudo apt-get upgrade
Update any frameworks or libraries you use in your projects too to
make sure you don’t appear on the Exploit DB.
SOLUTION
Just because the attacker can’t see your source code doesn’t mean
they can’t brute force or guess their way in!
SECURITY THROUGH OBSCURITY
Assume they can see your source code.
SOLUTION
AUTHORIZATION BYPASS
Locking the front door is useless if you left the window open.
Some companies forget to secure all of their admin pages. Sure, the
admin home page is protected by a password, but what about the
page where you can modify user permissions?
Storing valuable information in HTML <hidden> fields?
Users can modify and do whatever they like to those.
HIDDEN FIELDS ARE NOT HIDDEN
SOLUTION
CHECK every page, REST service, action and form to make sure only
those authorized can perform actions
NEVER store internal logic in content the user sends back. This
includes cookies! (Although storing this information in sessions with a
session token is OK provided you’re using sessions properly)
So you’ve fixed authorization bypass and an admin is logged in.
The admin checks the forums and sees this post:
CSRF CROSS-SITE REQUEST FORGERY
Hi, I’m getting harassed by the user Trump4President. I recorded a chat log here to prove that
he’s being derogatory and spiteful to every user in...
Little did the admin know, the link actually goes here:
https://www.clubpenguin.com/admin/users/Trump4President/perms?admin=true
There are actually two things wrong with this example.
1. A modification action was accessible with a GET request rather
than POST.
2. Because the admin was logged in, clicking this link performed
the action under the admin’s account.
WHAT WENT WRONG
USE POST, PUT, PATCH, DELETE etc. for any mutable actions. Use
GET only if data will not be modified by the request.
TOKENIZE all forms and actions with a random string generated as
the page loads. Store this token in your database to
cross-reference when the form is submitted. This token may be
stored in a hidden field or cookie.
SOLUTION
REDIRECT HIJACKING
Sometimes you need to show a page, such as a login page, before
redirecting the user to where they wanted to go.
If the redirect URL is not sanitized, an attacker might try to use it to
direct you to another site. Imagine if a user is presented with a
phishing email to change their bank password and they’re
presented with a legitimate link to their bank:
https://www.securebank.com/account/changepassword?redir=http://evil.com/phish
REDIRECT HIJACKING
This attack goes hand-in-hand with CSRF. If the user can be
redirected before they realize their session has been hijacked by an
evil button, the incident may go completely undetected.
REDIRECT HIJACKING
It’s not just limited to redirecting a user either. If your script accesses
the server’s filesystem, don’t let this happen:
https://www.mycoolforum.com/forum/page=../../../etc/passwd
SOLUTION
USE a URL parser on any URL arguments to make sure they’re
relative to the document root.
DENY use of patterns like ‘../’, ‘~/’ or ‘PROGRA~1/’
Some content is written by the user. This could be something like
eBay’s item descriptions, or even a user’s username displayed at the
top of the page.
If the user can enter HTML tags that they shouldn’t, we already know
what can go wrong.
XSS CROSS-SITE SCRIPTING
There are two ways XSS can be a problem.
1. Displaying unsanitized information that the user has directly
given (such as in a comment post or account bio)
2. Displaying unsanitized information that the user has weaseled
into the system (for example, with a database compromise)
FIRST AND SECOND ORDER
ESCAPE or encode all characters that should be illegal when
displayed on a page. For HTML body, this is <anyelement>, for HTML
attributes this is any single or double quote. There are pre-made
sanitizers for this job.
Perform this when the data is displayed rather than when it is stored.
Otherwise you can end up with multiple escaped strings and still be
vulnerable to second-order XSS!
SOLUTION
How it should be done (escaping with &lt; and &gt;)
How it shouldn’t be done
HUMANS
THE WEAKEST LINK OF A
SECURITY SYSTEM
Of the compromised respondents in the GSISS
34%said current employees were the most likely cause
Global State of Information Security® Survey 2016
29%linked attacks to former employees
Global State of Information Security® Survey 2016
PRIVILEGE MISUSE
is #3 of the 9 biggest causes
Verizon Data Breach Investigations Report 2015
Still a common cause of security violations. With a convincing email,
an employee can violate the security plan your business so dearly
values in a matter of seconds.
Hot for 2016 - SMiShing (via SMS)
PHISHING
Yes.
23% of phishing emails are opened and 11% of attachments are
downloaded according to the 2015 Verizon Data Breach
Investigations Report.
PEOPLE STILL FALL FOR
THAT?
Companies that have an overall security strategy
58%
Global State of Information Security® Survey 2016
Companies that have an employee training program
53%
With a suit, tie and clipboard, you can go pretty much anywhere you
want.
With a tray of coffees, you can go through pretty much any door.
It’s this inherent kindness that shows that as security systems go, we
are pretty poor.
SOCIAL ENGINEERING
In 2007, a mystery man walked into a Belgian bank and stole over
€21 million in diamonds from high-security safety deposit boxes using
only his charming personality.
He gained trust with the personnel by being a nice guy and bringing
chocolates. He was able to make copies of the keys and gain
information to the diamonds whereabouts.
CONFIDENCE
Hence,
TO MAKE A SECURE SYSTEM,
FIRST REMOVE HUMANS
THANKS!
I’ll be glad to take your criticisms
Chris Watts - cwatts1@us.ibm.com

Mais conteúdo relacionado

Mais procurados

Owasp top 10 web application security hazards part 2
Owasp top 10 web application security hazards part 2Owasp top 10 web application security hazards part 2
Owasp top 10 web application security hazards part 2Abhinav Sejpal
 
Owasp top 10 web application security hazards - Part 1
Owasp top 10 web application security hazards - Part 1Owasp top 10 web application security hazards - Part 1
Owasp top 10 web application security hazards - Part 1Abhinav Sejpal
 
Prevent browser hijack infection
Prevent browser hijack infectionPrevent browser hijack infection
Prevent browser hijack infectionscottgelbard123
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threatAvădănei Andrei
 
Staying Safe on the Computer and Online
Staying Safe on the Computer and OnlineStaying Safe on the Computer and Online
Staying Safe on the Computer and Onlinecat509
 
Defcon9 Presentation2001
Defcon9 Presentation2001Defcon9 Presentation2001
Defcon9 Presentation2001Miguel Ibarra
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Netalsmola
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...CODE BLUE
 
Securing Word Press Blog
Securing Word Press BlogSecuring Word Press Blog
Securing Word Press BlogChetan Gole
 
How to remove search.olivernetko.com manually
How to remove search.olivernetko.com manuallyHow to remove search.olivernetko.com manually
How to remove search.olivernetko.com manuallyjesicasruma
 
Web security presentation
Web security presentationWeb security presentation
Web security presentationJohn Staveley
 
Presentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web ApplicationPresentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web ApplicationMd Mahfuzur Rahman
 
How to remove isearch.omiga-plus.com?
How to remove isearch.omiga-plus.com?How to remove isearch.omiga-plus.com?
How to remove isearch.omiga-plus.com?paula_bolivar
 
Hacking with experts 3 (facebook hacking) by anurag dwivedi.
Hacking with experts 3 (facebook hacking) by anurag dwivedi.Hacking with experts 3 (facebook hacking) by anurag dwivedi.
Hacking with experts 3 (facebook hacking) by anurag dwivedi.Esteban Bedoya
 
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Developmentmrdon
 
Things that go bump on the web - Web Application Security
Things that go bump on the web - Web Application SecurityThings that go bump on the web - Web Application Security
Things that go bump on the web - Web Application SecurityChristian Heilmann
 
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacksRoberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacksPietro Polsinelli
 

Mais procurados (20)

Owasp top 10 web application security hazards part 2
Owasp top 10 web application security hazards part 2Owasp top 10 web application security hazards part 2
Owasp top 10 web application security hazards part 2
 
Owasp top 10 web application security hazards - Part 1
Owasp top 10 web application security hazards - Part 1Owasp top 10 web application security hazards - Part 1
Owasp top 10 web application security hazards - Part 1
 
Riding Rails 4
Riding Rails 4Riding Rails 4
Riding Rails 4
 
Prevent browser hijack infection
Prevent browser hijack infectionPrevent browser hijack infection
Prevent browser hijack infection
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Jetpack All The Things
Jetpack All The ThingsJetpack All The Things
Jetpack All The Things
 
Staying Safe on the Computer and Online
Staying Safe on the Computer and OnlineStaying Safe on the Computer and Online
Staying Safe on the Computer and Online
 
Defcon9 Presentation2001
Defcon9 Presentation2001Defcon9 Presentation2001
Defcon9 Presentation2001
 
Web Security 101
Web Security 101Web Security 101
Web Security 101
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Net
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
 
Securing Word Press Blog
Securing Word Press BlogSecuring Word Press Blog
Securing Word Press Blog
 
How to remove search.olivernetko.com manually
How to remove search.olivernetko.com manuallyHow to remove search.olivernetko.com manually
How to remove search.olivernetko.com manually
 
Web security presentation
Web security presentationWeb security presentation
Web security presentation
 
Presentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web ApplicationPresentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web Application
 
How to remove isearch.omiga-plus.com?
How to remove isearch.omiga-plus.com?How to remove isearch.omiga-plus.com?
How to remove isearch.omiga-plus.com?
 
Hacking with experts 3 (facebook hacking) by anurag dwivedi.
Hacking with experts 3 (facebook hacking) by anurag dwivedi.Hacking with experts 3 (facebook hacking) by anurag dwivedi.
Hacking with experts 3 (facebook hacking) by anurag dwivedi.
 
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
 
Things that go bump on the web - Web Application Security
Things that go bump on the web - Web Application SecurityThings that go bump on the web - Web Application Security
Things that go bump on the web - Web Application Security
 
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacksRoberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
 

Destaque

Design din egen bortedrakt
Design din egen bortedraktDesign din egen bortedrakt
Design din egen bortedraktSimon Bognø
 
Sosiale medier-strategi for intro
Sosiale medier-strategi for introSosiale medier-strategi for intro
Sosiale medier-strategi for introSimon Bognø
 
Tcm step 3 venture assessment
Tcm step 3 venture assessmentTcm step 3 venture assessment
Tcm step 3 venture assessmentStephen Ong
 
go[ing] mad Reifegrad Digitalisierung 2018
go[ing] mad Reifegrad Digitalisierung 2018go[ing] mad Reifegrad Digitalisierung 2018
go[ing] mad Reifegrad Digitalisierung 2018addWings Services
 
Additional HTML
Additional HTML Additional HTML
Additional HTML Doeun KOCH
 
Unterschiedliche Technologien für digitales Publishing
Unterschiedliche Technologien für digitales PublishingUnterschiedliche Technologien für digitales Publishing
Unterschiedliche Technologien für digitales PublishingWeLoveYou
 
Effeithiau Digwyddiadau (Glastonbury)
Effeithiau Digwyddiadau (Glastonbury)Effeithiau Digwyddiadau (Glastonbury)
Effeithiau Digwyddiadau (Glastonbury)Mrs Serena Davies
 
Ortografia y redaccion
Ortografia y redaccionOrtografia y redaccion
Ortografia y redaccionkbjarrin
 
TSEM Fall 2016 McArthur Class 1
TSEM Fall 2016 McArthur Class 1TSEM Fall 2016 McArthur Class 1
TSEM Fall 2016 McArthur Class 1Laksamee Putnam
 
Arquitectura románica II. Europa.
Arquitectura románica II. Europa.Arquitectura románica II. Europa.
Arquitectura románica II. Europa.Alfredo García
 
Capilla Scrovegni 4. Juicio Final
Capilla Scrovegni 4. Juicio FinalCapilla Scrovegni 4. Juicio Final
Capilla Scrovegni 4. Juicio FinalAlfredo García
 
Al Andalus III. Del siglo XI al siglo XV.
Al Andalus III. Del siglo XI al siglo XV.Al Andalus III. Del siglo XI al siglo XV.
Al Andalus III. Del siglo XI al siglo XV.Alfredo García
 

Destaque (20)

Good Title
Good TitleGood Title
Good Title
 
Mensagens de ifá
Mensagens de ifáMensagens de ifá
Mensagens de ifá
 
Design din egen bortedrakt
Design din egen bortedraktDesign din egen bortedrakt
Design din egen bortedrakt
 
Sosiale medier-strategi for intro
Sosiale medier-strategi for introSosiale medier-strategi for intro
Sosiale medier-strategi for intro
 
Tcm step 3 venture assessment
Tcm step 3 venture assessmentTcm step 3 venture assessment
Tcm step 3 venture assessment
 
go[ing] mad Reifegrad Digitalisierung 2018
go[ing] mad Reifegrad Digitalisierung 2018go[ing] mad Reifegrad Digitalisierung 2018
go[ing] mad Reifegrad Digitalisierung 2018
 
Additional HTML
Additional HTML Additional HTML
Additional HTML
 
Unterschiedliche Technologien für digitales Publishing
Unterschiedliche Technologien für digitales PublishingUnterschiedliche Technologien für digitales Publishing
Unterschiedliche Technologien für digitales Publishing
 
ภูมิใจ
ภูมิใจภูมิใจ
ภูมิใจ
 
Showcase 6 styles
Showcase 6 stylesShowcase 6 styles
Showcase 6 styles
 
Effeithiau Digwyddiadau (Glastonbury)
Effeithiau Digwyddiadau (Glastonbury)Effeithiau Digwyddiadau (Glastonbury)
Effeithiau Digwyddiadau (Glastonbury)
 
Ori
OriOri
Ori
 
Ortografia y redaccion
Ortografia y redaccionOrtografia y redaccion
Ortografia y redaccion
 
TSEM Fall 2016 McArthur Class 1
TSEM Fall 2016 McArthur Class 1TSEM Fall 2016 McArthur Class 1
TSEM Fall 2016 McArthur Class 1
 
Vanda azevedo
Vanda azevedoVanda azevedo
Vanda azevedo
 
Diccionario Lucumi
Diccionario LucumiDiccionario Lucumi
Diccionario Lucumi
 
Eshu-eleggua
Eshu-elegguaEshu-eleggua
Eshu-eleggua
 
Arquitectura románica II. Europa.
Arquitectura románica II. Europa.Arquitectura románica II. Europa.
Arquitectura románica II. Europa.
 
Capilla Scrovegni 4. Juicio Final
Capilla Scrovegni 4. Juicio FinalCapilla Scrovegni 4. Juicio Final
Capilla Scrovegni 4. Juicio Final
 
Al Andalus III. Del siglo XI al siglo XV.
Al Andalus III. Del siglo XI al siglo XV.Al Andalus III. Del siglo XI al siglo XV.
Al Andalus III. Del siglo XI al siglo XV.
 

Semelhante a How not to suck at cyber security: A concise guide to common threats/TITLE

Practical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonPractical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonStefan Streichsbier
 
Website Security
Website SecurityWebsite Security
Website SecurityCarlos Z
 
Application Security
Application SecurityApplication Security
Application Securitynirola
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Bastian Grimm
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggetsguestbd1cdca
 
Conquering Code with hjc
Conquering Code with hjcConquering Code with hjc
Conquering Code with hjchjc
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan GandhiReliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan Gandhibhumika2108
 
How to code securely: a crash course for non-coders
How to code securely: a crash course for non-codersHow to code securely: a crash course for non-coders
How to code securely: a crash course for non-codersJaap Karan Singh
 
Developing Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksDeveloping Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksPayPalX Developer Network
 
Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Moataz Kamel
 
Best And Worst Practices Building Ria with Adobe and Microsoft
Best And Worst Practices Building Ria with Adobe and MicrosoftBest And Worst Practices Building Ria with Adobe and Microsoft
Best And Worst Practices Building Ria with Adobe and MicrosoftJosh Holmes
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxChapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxilhamilyas5
 
Bug Bounty #Defconlucknow2016
Bug Bounty #Defconlucknow2016Bug Bounty #Defconlucknow2016
Bug Bounty #Defconlucknow2016Shubham Gupta
 
A security note for web developers
A security note for web developersA security note for web developers
A security note for web developersJohn Ombagi
 
Security Best Practices for Bot Builders
Security Best Practices for Bot BuildersSecurity Best Practices for Bot Builders
Security Best Practices for Bot BuildersMax Feldman
 

Semelhante a How not to suck at cyber security: A concise guide to common threats/TITLE (20)

Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
Practical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonPractical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} Hackathon
 
Website Security
Website SecurityWebsite Security
Website Security
 
Web Security
Web SecurityWeb Security
Web Security
 
Application Security
Application SecurityApplication Security
Application Security
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
 
Conquering Code with hjc
Conquering Code with hjcConquering Code with hjc
Conquering Code with hjc
 
Security Awareness
Security AwarenessSecurity Awareness
Security Awareness
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan GandhiReliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
 
How to code securely: a crash course for non-coders
How to code securely: a crash course for non-codersHow to code securely: a crash course for non-coders
How to code securely: a crash course for non-coders
 
Developing Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksDeveloping Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common Attacks
 
Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Securing Applications
Securing ApplicationsSecuring Applications
Securing Applications
 
Best And Worst Practices Building Ria with Adobe and Microsoft
Best And Worst Practices Building Ria with Adobe and MicrosoftBest And Worst Practices Building Ria with Adobe and Microsoft
Best And Worst Practices Building Ria with Adobe and Microsoft
 
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptxChapter5-Bypass-ClientSide-Control-Presentation.pptx
Chapter5-Bypass-ClientSide-Control-Presentation.pptx
 
Bug Bounty #Defconlucknow2016
Bug Bounty #Defconlucknow2016Bug Bounty #Defconlucknow2016
Bug Bounty #Defconlucknow2016
 
A security note for web developers
A security note for web developersA security note for web developers
A security note for web developers
 
Security Best Practices for Bot Builders
Security Best Practices for Bot BuildersSecurity Best Practices for Bot Builders
Security Best Practices for Bot Builders
 

How not to suck at cyber security: A concise guide to common threats/TITLE

  • 1. HOW NOT TO SUCK AT CYBER SECURITY Chris Watts - Feb 2016
  • 3. In 2015 there were +38%more cyber security incidents than in 2014 Global State of Information Security® Survey 2016
  • 4. Proportion of companies reporting a security incident Global State of Information Security® Survey 2016
  • 5. CUSTOMER RECORDS Global State of Information Security® Survey 2016 38.27% of compromised assets EMPLOYEE RECORDS 33.25% of compromised assets
  • 6. While there is no guarantee against being breached, organizations can greatly manage their risk by becoming more vigilant in covering their bases. - Mike Denning, Vice President for Global Security, Verizon
  • 7. According to the Pareto Principle 80%of the effects are from 20%of the causes Software bugs are not exempt from this rule
  • 8. BACK TO THE RECENT EBAY HACK
  • 10. [] + [] === '' [] + {} === [object Object] {} + [] === 0 {} + {} === NaN QUIRKY! https://www.destroyallsoftware.com/talks/wat
  • 11. HOW TO MAKE A LANGUAGE NAND or NOR gates will let you build anything!
  • 12. With an array of NAND or NOR gates, you can build any other logic gate. Hence FPGAs! In software, if you have a NOT expression and an OR expression, you can emulate any other logic circuit! If you can emulate logic circuits, you can emulate a Turing machine. Pretty much every language already has this requirement [!+]
  • 13. TURING TARPITS Some people just want to watch the world burn This is an example of Hello World in Brainfuck ++++++++[>++++ [>++>+++>+++>+<<<<-] >+>+>->>+[<]<-] >>.>---.+++++++..+++.>>. <-.<.+++.------.--------.>>+.>++.
  • 14. To be Turing-complete, an imperative language must: 1. Allow conditional branching 2. Allow read/write access to random memory
  • 15. To be Turing-complete, a functional language must: 1. Allow abstraction of functions over arguments 2. Allow application of functions to arguments
  • 16. ENTER JSFUCK A Turing-complete sub-language of JavaScript that runs in the same environment as real JavaScript. And yes, it’s Turing-complete. false => ![] true => !![] undefined => [][[]] NaN => +[![]] 0 => +[] 1 => +!+[] 2 => !+[]+!+[]
  • 17. Problem: Lots of people want cat pictures and illegible formatting in their listings Solution: Let them insert HTML! Normally, one filters out everything that has the potential to do bad with user-submitted HTML USER INPUT IS A DANGEROUS THING In fact, the best idea is to just avoid it and say no, but customers will be customers.
  • 18. LET’S LEAVE IN <SCRIPT> TAGS! Now we can offer more features like advertising! And lawsuit-worthy user tracking!
  • 19. Hey let’s just check for alphanumerics! It’s a super easy regex. /<script>w+</script>//ig ALL WE NEED TO DO IS DISALLOW ALL STRINGS WITHIN <SCRIPT> TAGS SUBMITTED BY USERS
  • 20. It will be fine, nobody is ever going to be able to execute JavaScript without alphanumerics despite JS being even sketchier than C++[1] - some dev at eBay
  • 22.
  • 23. Two researchers by the names of Charlie Miller and Chris Valasek were able to connect to GM’s OnStar entertainment system from 2012 to 2015. Turns out the entertainment system is connected to the ECU, braking, tire pressure monitoring and steering systems. OF COURSE, IT’S NOT JUST EBAY From 10 miles away, they were able to turn up the car stereo, switch on the wipers, and crash the car flat-out into a ditch.
  • 24. It will be fine, nobody is ever going to control the car through the entertainment system - some dev at GM
  • 25. LET’S NOT FOLLOW SUIT DESIGN AS THE ANTI-USER
  • 27. A SIMPLE ATTACK <?php $page = $_GET[‘page’]; $query = “SELECT * FROM transactions LIMIT $page * 20, 20”; ... ?> https://www.securebank.com/transactions/view/3/ https://www.securebank.com/transactions/view/3;DROP USER admin;--/
  • 28. SOLUTION NEVER trust user-supplied information. Hidden form fields and cookies are also not safe. VALIDATE your inputs. Expecting a number? Assert that! ALWAYS use prepared statements - don’t insert directly into SQL statements $statement = $db->prepare(“SELECT * FROM transactions LIMIT :page, 20”); $statement->bindParam(‘page’, $page * 20);
  • 29. You would think there’s no harm in leaving the version numbers of your Wordpress installation in the headers or footers of your web page. Some version information also appears in HTTP headers, for example: ‘X-Powered-By: My Cool CMS v3.3.6’ INFORMATION LEAKAGE
  • 31. REMOVE all version identifiers from everything your server sends CHECK what happens on a server error. Does the 500 page show anything useful to a hacker? REMOVE all debugging information, or have it sent to log files SOLUTION
  • 32. INFORMATION EXPOSURE Sometimes your text editors are the enemy... Of course, Database.php~ is no longer a .php file, so will not get executed when you navigate to it. Instead, it will just download the file to the user, containing the actual PHP code and passwords!
  • 33. SOLUTION WHITELIST rather than blacklist files that are allowed to be displayed to the user (e.g. in .htaccess) DELETE all temporary files on the production server, edit files on a development server before pushing. MOVE all non-static (e.g. html, jpg, css) files out of the document root. Especially configuration files.
  • 34. USER UPLOADS By performing the previous steps, you can also protect yourself from malicious uploads being executed. This does not replace the need to check file contents though as if the file exists on the server, it’s more than likely the attacker will find a way to execute it.
  • 35. Remember the Heartbleed bug of 2014? In 2015 there were still swaths of unprotected servers due to negligence and unwillingness to update. OUTDATED SOFTWARE
  • 36. sudo apt-get update sudo apt-get upgrade Update any frameworks or libraries you use in your projects too to make sure you don’t appear on the Exploit DB. SOLUTION
  • 37. Just because the attacker can’t see your source code doesn’t mean they can’t brute force or guess their way in! SECURITY THROUGH OBSCURITY
  • 38. Assume they can see your source code. SOLUTION
  • 39. AUTHORIZATION BYPASS Locking the front door is useless if you left the window open. Some companies forget to secure all of their admin pages. Sure, the admin home page is protected by a password, but what about the page where you can modify user permissions?
  • 40. Storing valuable information in HTML <hidden> fields? Users can modify and do whatever they like to those. HIDDEN FIELDS ARE NOT HIDDEN
  • 41. SOLUTION CHECK every page, REST service, action and form to make sure only those authorized can perform actions NEVER store internal logic in content the user sends back. This includes cookies! (Although storing this information in sessions with a session token is OK provided you’re using sessions properly)
  • 42. So you’ve fixed authorization bypass and an admin is logged in. The admin checks the forums and sees this post: CSRF CROSS-SITE REQUEST FORGERY Hi, I’m getting harassed by the user Trump4President. I recorded a chat log here to prove that he’s being derogatory and spiteful to every user in... Little did the admin know, the link actually goes here: https://www.clubpenguin.com/admin/users/Trump4President/perms?admin=true
  • 43. There are actually two things wrong with this example. 1. A modification action was accessible with a GET request rather than POST. 2. Because the admin was logged in, clicking this link performed the action under the admin’s account. WHAT WENT WRONG
  • 44. USE POST, PUT, PATCH, DELETE etc. for any mutable actions. Use GET only if data will not be modified by the request. TOKENIZE all forms and actions with a random string generated as the page loads. Store this token in your database to cross-reference when the form is submitted. This token may be stored in a hidden field or cookie. SOLUTION
  • 45. REDIRECT HIJACKING Sometimes you need to show a page, such as a login page, before redirecting the user to where they wanted to go. If the redirect URL is not sanitized, an attacker might try to use it to direct you to another site. Imagine if a user is presented with a phishing email to change their bank password and they’re presented with a legitimate link to their bank: https://www.securebank.com/account/changepassword?redir=http://evil.com/phish
  • 46. REDIRECT HIJACKING This attack goes hand-in-hand with CSRF. If the user can be redirected before they realize their session has been hijacked by an evil button, the incident may go completely undetected.
  • 47. REDIRECT HIJACKING It’s not just limited to redirecting a user either. If your script accesses the server’s filesystem, don’t let this happen: https://www.mycoolforum.com/forum/page=../../../etc/passwd
  • 48. SOLUTION USE a URL parser on any URL arguments to make sure they’re relative to the document root. DENY use of patterns like ‘../’, ‘~/’ or ‘PROGRA~1/’
  • 49. Some content is written by the user. This could be something like eBay’s item descriptions, or even a user’s username displayed at the top of the page. If the user can enter HTML tags that they shouldn’t, we already know what can go wrong. XSS CROSS-SITE SCRIPTING
  • 50. There are two ways XSS can be a problem. 1. Displaying unsanitized information that the user has directly given (such as in a comment post or account bio) 2. Displaying unsanitized information that the user has weaseled into the system (for example, with a database compromise) FIRST AND SECOND ORDER
  • 51. ESCAPE or encode all characters that should be illegal when displayed on a page. For HTML body, this is <anyelement>, for HTML attributes this is any single or double quote. There are pre-made sanitizers for this job. Perform this when the data is displayed rather than when it is stored. Otherwise you can end up with multiple escaped strings and still be vulnerable to second-order XSS! SOLUTION
  • 52. How it should be done (escaping with &lt; and &gt;) How it shouldn’t be done
  • 53. HUMANS THE WEAKEST LINK OF A SECURITY SYSTEM
  • 54. Of the compromised respondents in the GSISS 34%said current employees were the most likely cause Global State of Information Security® Survey 2016
  • 55. 29%linked attacks to former employees Global State of Information Security® Survey 2016
  • 56. PRIVILEGE MISUSE is #3 of the 9 biggest causes Verizon Data Breach Investigations Report 2015
  • 57. Still a common cause of security violations. With a convincing email, an employee can violate the security plan your business so dearly values in a matter of seconds. Hot for 2016 - SMiShing (via SMS) PHISHING
  • 58. Yes. 23% of phishing emails are opened and 11% of attachments are downloaded according to the 2015 Verizon Data Breach Investigations Report. PEOPLE STILL FALL FOR THAT?
  • 59. Companies that have an overall security strategy 58% Global State of Information Security® Survey 2016 Companies that have an employee training program 53%
  • 60. With a suit, tie and clipboard, you can go pretty much anywhere you want. With a tray of coffees, you can go through pretty much any door. It’s this inherent kindness that shows that as security systems go, we are pretty poor. SOCIAL ENGINEERING
  • 61. In 2007, a mystery man walked into a Belgian bank and stole over €21 million in diamonds from high-security safety deposit boxes using only his charming personality. He gained trust with the personnel by being a nice guy and bringing chocolates. He was able to make copies of the keys and gain information to the diamonds whereabouts. CONFIDENCE
  • 62. Hence, TO MAKE A SECURE SYSTEM, FIRST REMOVE HUMANS
  • 63. THANKS! I’ll be glad to take your criticisms Chris Watts - cwatts1@us.ibm.com