SlideShare une entreprise Scribd logo
1  sur  57
Crash Course in Brain Surgery*

                   A Primer for Developers


          * By “brain” I mean application and by “surgery” I mean security


Bruno Morisson <morisson@genhex.org>                                  Codebits 2009
About me
•  InfoSec Consultant & IT Security Operations
   Manager @ Commet (Oni Telecom)
•  ~10 years in InfoSec
•  CISSP/CISA/ISO27001 Lead Auditor
•  Background as a Linux/Unix sysadmin
•  Background as a C developer
•  Know enough Perl/Python for my needs
•  Not a developer!!!

                                                 2
Why ?
Buffer Overflows
         OS Command Injection
Null Pointer Deref.
     Business Logic
Format Strings
          User Authentication
XSS
                     Session Management
CSRF
                    Password Management
SQL Injection
           Encra^Hyption
RFI
                     Access Control
LDAP Injection
          …

                                                 3
Brain Surgery ?!?
•  You can’t expect to learn brain surgery in
   ~40 minutes

•  You shouldn’t expect to learn application
   security in ~40 minutes




                                                4
Status




Source: Cenzic
                            5
Status (II)




Source: Verizon Business
                                      6
OWASP Top Ten (2010 rc1)
•    Injection Flaws
•    Cross Site Scripting (XSS)
•    Broken Authentication and Session Management
•    Insecure Direct Object Reference
•    CSRF
•    Security Misconfiguration
•    Failure to Restrict URL Access
•    Invalidated Redirects and Forwards
•    Insecure Cryptographic Storage
•    Insufficient Transport Layer Protection

                                                     7
8
Objective
•  Raise awareness on application security
   (and security in general)

     • Think like an attacker

     • Understand to those who do



                                             9
Security Mindset
“Good engineering involves thinking about
 how things can be made to work; the
 security mindset involves thinking about
 how things can be made to fail.”
                             Bruce Schneier




                                          10
Security
•  Security is about Managing Risks



 Risk = P(Threat x Vulnerability x Impact)




                                          11
How secure are your apps ?
•  How do you measure your apps’
   security ?
    # of bugs ?
    # of bugs per line of code ??
    # of bugs per code ???
    …


•  More important, how do you avoid
   security bugs in your apps!!!
                                      12
“Security Is a Process not a Product”
                          Bruce Schneier




                                       13
14
So you think you’re secure?
•  Just because you develop in
   {C,Perl,Python,Ruby,PHP,Java,<insert favorite language here>} it doesn’t

   mean your app is secure!

•  Understand and know that you will fail

•  Assess risks, and define controls 


                                                                              15
User Input Validation
•  Buffer Overflows / XSS / SQLi /…

•  Applications don’t correctly validate what
   the user inputs

•  Trust but verify



                                                16
Cross Site Scripting
 ....is a type of computer security
vulnerability typically found in web
applications which enable malicious
attackers to inject client-side script into
web pages viewed by other users.




                             Source: Wikipedia
                                             17
Cross Site Scripting
•  Example app code (pseudo code):
  ...
  $search = $_GET[‘search’];
  $query = ‘SELECT * FROM DOCS where BODY
     LIKE “%$search%”;
  $result = sql_query($query);
  print “Here are the results to your query $search”;
  print_results($result);
  …

                                                         18
Cross Site Scripting
•  Application use:

    http://secureserver/?search=application+security




                                                        19
Cross Site Scripting
•  Application abuse:
  –  What if the user inputs some JavaScript ??


•  The attacker can potentially own the
   user’s browser… but how ?

•  Typically through social engineering or
   your own web app
                                                   20
Cross Site Scripting
•  Back in 2002... “Multiple XSS
   Vulnerabilities in PHPNuke 6.0”

•  In aprox. 1 hour “audit” 7 XSS
   vulnerabilities discovered (in 22 different
   input fields)

•  All allowed any user to hijack other users’
   sessions
                                                 21
Cross Site Scripting
•  In 2009… StrongWebMail Contest. US
   $10.000 Prize

•  Everyone had the login and password.

•  “Ultra” secure webmail system, confirmation
   of login using a cellphone.

•  Owned by XSS.

                                            22
Cross Site Scripting




Source: http://www.securescience.net/blog/
                                              23
Cross Site Scripting
•  What can you do ?
  –  Filter the input…
                     …and the output

•  Ask yourself:
  –  Do we really need to use HTML ? 
  –  What is the intended input ?
  –  Are we outputting what we expect ?

  Unfortunately developers tend to blacklist…
                                                 24
Cross Site Scripting
•  But blacklist what ?

     <IMG """><SCRIPT>alert("XSS")</SCRIPT>">

     <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>

     <IMG
       SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#
       97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>

     <IMG
       SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#000
       0114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000
       101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#00000
       83&#0000039&#0000041>
     …



                                                                         25
Cross Site Scripting
•  Use a positive security model

  –  If you expect a name, why accept numbers or
     punctuation ?
  –  If you expect a date, why accept “<“ or “>” ?
  –  If you do expect HTML, make sure it is well
     filtered (that’s the hard part…)



                                                  26
Injection
•  Not only SQL.
     •  Technique first mentioned in 1998 by rain forest
        puppy in Phrack 54


•  OS injection is possibly older.

•  LDAP is another target for injection.


                                                          27
Injection
...
$search = $_GET[‘search’];
$query = ‘SELECT * FROM DOCS where BODY
   LIKE “%$search%”’;
$result = sql_query($query);
print “Here are the results to your query
   $search”;
print_results($result);
…
                                        28
Injection
•  Impact ?

  –  Heartland Security Breach: 130 million credit
     and debit cards

  –  Cost of the breach: US$12.6 Million




                                                     29
Injection




Source: http://www.nosec.org
        30
Injection




Source: http://unu123456.baywords.com/
   31
Injection
•  How do we protect ?

  –  Not so different from XSS. Same principles:
  –  Filter user input
  –  Whitelist what you know it’s safe
  –  Use stored procedures and views
  –  More ideas in a couple of slides…


                                                    32
More Input Validation
•  Cookies
•  Headers (Referrer!)
•  Any variables!
  –  There’s no such thing as hidden fields!
  –  User IDs ?
  –  Application flow
  –  Etc..


                                               33
More Input Validation
•  Example:

  –  Application checks the “Referrer” to ensure
     the user comes from an allowed origin.

  –  Who sets the Referrer ? Oooops…




                                                   34
More Input Validation
•  Example:

  –  If you trust the “hidden” field UserID, and the
     user sends it as “admin”, shouldn’t you verify
     it ?
  –  Use HMACs.
  –  More on this in a few slides



                                                  35
Identification, Authentication and
          Authorization
•  Most people don’t know the difference!

•  Identification is easy!

•  The hard part is authenticating and
   authorizing…



                                             36
Passwords & Login
•  Lots of problems:

  –  Storage / Encryption ?

  –  Recovery ?

  –  Quality ?

  –  Bots / CAPTCHAs

•  Why not outsource it ?
                               37
Sessions
•  Lots of problems:

  –  Unique

  –  Unreplayable

  –  Unpredictable

  –  Logging user off

•  Use a proven framework
                                 38
Access Control
•  How many apps use more than one
   database user ?

•  If in certain parts of the app the user just
   needs to read (SELECT), why should it be
   able to write (INSERT/UPDATE) ?

•  Does every part of the app need to read
   every table in the database ?
                                                  39
Access Control
•  The same applies to any object (on a
   database or not)

•  If in certain parts of the app the user just
   needs to read information, why should it
   be able to write or change information?

•  Does every part of the app need to
   access every piece of information ?
                                                  40
Access Control
•  Security Models to the rescue!




                                     41
Access Control
•  Not those models…

  –  Biba (integrity)
  –  Bell-LaPadula (Confidentiality)
  –  Chinese-Wall (Brewer-Nash) (Conflicts of
     interest)


•  Don’t reinvent the wheel…

                                               42
Access Control
•  Define a security model for your app.
•  How many profiles should you need ?
•  Which are the access needs for each
   profile ?
•  Implement the model with the controls
   you have.
•  Implement controls you don’t have, but
   can.
                                            43
Access Control
•  Ensure each subject has access to and
   only to the objects it is allowed to
   access!!!




                                           44
Encraption
•  Encryption is hard

•  Don’t come up with new algorithms.
   They’ll suck.

•  Don’t come up with new implementations.
   See previous point.


                                         45
Encraption
•  Debian OpenSSL

•  Google KeyCzar

•  SSL/TLS Renegotiation bug




                                46
You’ve done all of the previous things, now
  you’re secure!




                                              47
48
Business Logic
•  If the logic is flawed, the app is flawed

•  Example:
  –  In a homebanking system, the user can
     transfer -€2000 to a different account.
  –  Oooops…




                                                49
Business Logic
•  More examples

  –  On a site that sells electronics, the user
     bought 10 TV sets for €1000 each, and
     bought -20 Stereos for €500 each.
  –  Oooops…




                                                  50
Business Logic
•  And more…
  –  On a site that sells movie tickets, the user can
     choose the sit, and it stays locked until the
     payment is done, for a max. of 10 minutes.
  –  The user automates this, for every sit in the
     room, every 10 minutes.
  –  Oooops…



                                                   51
Business Logic
•  Still more…
  –  A company made a promotion, where you
     had to play a game (flash), using a special ID
     from their soda bottles.
  –  The top user had about 10x more points than
     the 2nd place.
  –  Results from each game were submitted from
     the flash application…
  –  Oooops…

                                                 52
Business Logic
•  Ok, Last one:
  –  An E-Commerce site had special discount
     coupons they sent their customers.
  –  Someone discovered the coupons codes
     where predictable.
  –  Oooops…




                                               53
Wrap-Up
•  Always expect the worse
•  Start thinking about security ASAP in the SDL
•  Define a security model
•  Analyze data flows and entry points
•  Test the security of your app before the bad
   guys do
•  Rinse & Repeat



                                                    54
Community
•  InfoSec-Pros-PT – Mailing-List and
   LinkedIn Group (~377 members)
     •  http://groups.google.com/group/InfoSec-Pros-PT
     •  http://www.linkedin.com/groups?gid=112919


•  Confraria Security&IT (Networking)
     •  Monthly informal meetings & dinner
     •  Free
     •  http://www.linkedin.com/groups?gid=1859900



                                                          55
Thank You!"

                            Q&A?

Bruno Morisson
CISSP, CISA, ISO27001LA
morisson@genhex.org
http://genhex.org/~mori/
                                    56
References
•    http://www.owasp.org
•    http://www.webappsec.org
•    http://jeremiahgrossman.blogspot.com/
•    http://ha.ckers.org/blog/
•    http://www.cl.cam.ac.uk/~rja14/book.html
•    http://www.schneier.com/blog/
•    http://chargen.matasano.com/
•    http://www.cenzic.com/downloads/Cenzic_AppSecTrends_Q1-Q2-2009.pdf
•    http://www.verizonbusiness.com/resources/security/reports/
     2009_databreach_rp.pdf
•    http://sqlmap.sourceforge.net/
•    http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project
•    http://portswigger.net/proxy/
•    http://www.parosproxy.org/
•    http://livehttpheaders.mozdev.org/
•    https://addons.mozilla.org/en-US/firefox/addon/966 (tamper data)

                                                                           57

Contenu connexe

Tendances

David Thiel - Secure Development On iOS
David Thiel - Secure Development On iOSDavid Thiel - Secure Development On iOS
David Thiel - Secure Development On iOS
Source Conference
 
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best PracticesSecure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Websecurify
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...
Luis Grangeia
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and Future
Luis Grangeia
 

Tendances (18)

User Authentication: Passwords and Beyond
User Authentication: Passwords and BeyondUser Authentication: Passwords and Beyond
User Authentication: Passwords and Beyond
 
Comptia Security+ Exam Notes
Comptia Security+ Exam NotesComptia Security+ Exam Notes
Comptia Security+ Exam Notes
 
Do You Write Secure Code? by Erez Metula
Do You Write Secure Code? by Erez MetulaDo You Write Secure Code? by Erez Metula
Do You Write Secure Code? by Erez Metula
 
Certificates, PKI, and SSL/TLS for infrastructure builders and operators
Certificates, PKI, and SSL/TLS for infrastructure builders and operatorsCertificates, PKI, and SSL/TLS for infrastructure builders and operators
Certificates, PKI, and SSL/TLS for infrastructure builders and operators
 
Secure Coding for Java - An Introduction
Secure Coding for Java - An IntroductionSecure Coding for Java - An Introduction
Secure Coding for Java - An Introduction
 
Secure Coding principles by example: Build Security In from the start - Carlo...
Secure Coding principles by example: Build Security In from the start - Carlo...Secure Coding principles by example: Build Security In from the start - Carlo...
Secure Coding principles by example: Build Security In from the start - Carlo...
 
David Thiel - Secure Development On iOS
David Thiel - Secure Development On iOSDavid Thiel - Secure Development On iOS
David Thiel - Secure Development On iOS
 
Web security and OWASP
Web security and OWASPWeb security and OWASP
Web security and OWASP
 
LASCON 2014: Multi-Factor Authentication -- Weeding out the Snake Oil
LASCON 2014: Multi-Factor Authentication -- Weeding out the Snake OilLASCON 2014: Multi-Factor Authentication -- Weeding out the Snake Oil
LASCON 2014: Multi-Factor Authentication -- Weeding out the Snake Oil
 
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best PracticesSecure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best Practices
 
AppSecCali - How Credential Stuffing is Evolving
AppSecCali - How Credential Stuffing is EvolvingAppSecCali - How Credential Stuffing is Evolving
AppSecCali - How Credential Stuffing is Evolving
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
How Credential Stuffing is Evolving - PasswordsCon 2019
How Credential Stuffing is Evolving - PasswordsCon 2019How Credential Stuffing is Evolving - PasswordsCon 2019
How Credential Stuffing is Evolving - PasswordsCon 2019
 
The State of Credential Stuffing and the Future of Account Takeovers.
The State of Credential Stuffing and the Future of Account Takeovers.The State of Credential Stuffing and the Future of Account Takeovers.
The State of Credential Stuffing and the Future of Account Takeovers.
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and Future
 
Owasp Top 10 - A1 Injection
Owasp Top 10 - A1 InjectionOwasp Top 10 - A1 Injection
Owasp Top 10 - A1 Injection
 
AppSec EU 2015 - E-banking transaction authorization - possible vulnerabiliti...
AppSec EU 2015 - E-banking transaction authorization - possible vulnerabiliti...AppSec EU 2015 - E-banking transaction authorization - possible vulnerabiliti...
AppSec EU 2015 - E-banking transaction authorization - possible vulnerabiliti...
 

En vedette

Awake craniotomy
Awake craniotomyAwake craniotomy
Awake craniotomy
vickyyad
 
Extended and expanded role of nurse
Extended and expanded role of nurseExtended and expanded role of nurse
Extended and expanded role of nurse
ramanlal patidar
 

En vedette (10)

Voyage au centre de la Tête
Voyage au centre de la Tête Voyage au centre de la Tête
Voyage au centre de la Tête
 
Psychiatry and skin disease
Psychiatry and skin diseasePsychiatry and skin disease
Psychiatry and skin disease
 
Principles of angioplasty -Endovascular Management of Peripheral Vascular Dis...
Principles of angioplasty -Endovascular Management of Peripheral Vascular Dis...Principles of angioplasty -Endovascular Management of Peripheral Vascular Dis...
Principles of angioplasty -Endovascular Management of Peripheral Vascular Dis...
 
Organophosphorus poisoning
Organophosphorus poisoningOrganophosphorus poisoning
Organophosphorus poisoning
 
Awake craniotomy
Awake craniotomyAwake craniotomy
Awake craniotomy
 
Lead poisoning
Lead poisoningLead poisoning
Lead poisoning
 
Extended and expanded role of nurse
Extended and expanded role of nurseExtended and expanded role of nurse
Extended and expanded role of nurse
 
ORGANOPHOSPHATE POISONING AND MANAGEMENT
ORGANOPHOSPHATE POISONING AND MANAGEMENTORGANOPHOSPHATE POISONING AND MANAGEMENT
ORGANOPHOSPHATE POISONING AND MANAGEMENT
 
Antidote
AntidoteAntidote
Antidote
 
The Top Skills That Can Get You Hired in 2017
The Top Skills That Can Get You Hired in 2017The Top Skills That Can Get You Hired in 2017
The Top Skills That Can Get You Hired in 2017
 

Similaire à Crash Course In Brain Surgery

Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja WarriorsRyan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins
 
Andrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.pptAndrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.ppt
SilverGold16
 
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADFOWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
Brian Huff
 

Similaire à Crash Course In Brain Surgery (20)

Started In Security Now I'm Here
Started In Security Now I'm HereStarted In Security Now I'm Here
Started In Security Now I'm Here
 
Xss talk, attack and defense
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defense
 
Luis Grangeia IBWAS
Luis Grangeia IBWASLuis Grangeia IBWAS
Luis Grangeia IBWAS
 
IBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointIBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's Standpoint
 
Zen and the art of Security Testing
Zen and the art of Security TestingZen and the art of Security Testing
Zen and the art of Security Testing
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a Database
 
For Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSecFor Business's Sake, Let's focus on AppSec
For Business's Sake, Let's focus on AppSec
 
The hardcore stuff i hack, experiences from past VAPT assignments
The hardcore stuff i hack, experiences from past VAPT assignmentsThe hardcore stuff i hack, experiences from past VAPT assignments
The hardcore stuff i hack, experiences from past VAPT assignments
 
Fun with Application Security
Fun with Application SecurityFun with Application Security
Fun with Application Security
 
How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
 
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja WarriorsRyan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
 
Andrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.pptAndrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.ppt
 
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADFOWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
 
Solvay secure application layer v2015 seba
Solvay secure application layer v2015   sebaSolvay secure application layer v2015   seba
Solvay secure application layer v2015 seba
 
The Thing That Should Not Be
The Thing That Should Not BeThe Thing That Should Not Be
The Thing That Should Not Be
 
How an Attacker "Audits" Your Software Systems
How an Attacker "Audits" Your Software SystemsHow an Attacker "Audits" Your Software Systems
How an Attacker "Audits" Your Software Systems
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
Java application security the hard way - a workshop for the serious developer
Java application security the hard way - a workshop for the serious developerJava application security the hard way - a workshop for the serious developer
Java application security the hard way - a workshop for the serious developer
 
Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?
 
Indianapolis Splunk User Group Dec 22
Indianapolis Splunk User Group Dec 22Indianapolis Splunk User Group Dec 22
Indianapolis Splunk User Group Dec 22
 

Plus de morisson (6)

Security asap
Security asapSecurity asap
Security asap
 
(Mis)trusting and (ab)using ssh
(Mis)trusting and (ab)using ssh(Mis)trusting and (ab)using ssh
(Mis)trusting and (ab)using ssh
 
Mobile Securty - An Oxymoron?
Mobile Securty - An Oxymoron?Mobile Securty - An Oxymoron?
Mobile Securty - An Oxymoron?
 
APT
APTAPT
APT
 
Honeypot Farms using Ethernet Bridging over a TCP Connection
Honeypot Farms using Ethernet Bridging over a TCP Connection Honeypot Farms using Ethernet Bridging over a TCP Connection
Honeypot Farms using Ethernet Bridging over a TCP Connection
 
Virtualization & Security
Virtualization & SecurityVirtualization & Security
Virtualization & Security
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Crash Course In Brain Surgery

  • 1. Crash Course in Brain Surgery* A Primer for Developers * By “brain” I mean application and by “surgery” I mean security Bruno Morisson <morisson@genhex.org> Codebits 2009
  • 2. About me •  InfoSec Consultant & IT Security Operations Manager @ Commet (Oni Telecom) •  ~10 years in InfoSec •  CISSP/CISA/ISO27001 Lead Auditor •  Background as a Linux/Unix sysadmin •  Background as a C developer •  Know enough Perl/Python for my needs •  Not a developer!!! 2
  • 3. Why ? Buffer Overflows OS Command Injection Null Pointer Deref. Business Logic Format Strings User Authentication XSS Session Management CSRF Password Management SQL Injection Encra^Hyption RFI Access Control LDAP Injection … 3
  • 4. Brain Surgery ?!? •  You can’t expect to learn brain surgery in ~40 minutes •  You shouldn’t expect to learn application security in ~40 minutes 4
  • 7. OWASP Top Ten (2010 rc1) •  Injection Flaws •  Cross Site Scripting (XSS) •  Broken Authentication and Session Management •  Insecure Direct Object Reference •  CSRF •  Security Misconfiguration •  Failure to Restrict URL Access •  Invalidated Redirects and Forwards •  Insecure Cryptographic Storage •  Insufficient Transport Layer Protection 7
  • 8. 8
  • 9. Objective •  Raise awareness on application security (and security in general) • Think like an attacker • Understand to those who do 9
  • 10. Security Mindset “Good engineering involves thinking about how things can be made to work; the security mindset involves thinking about how things can be made to fail.” Bruce Schneier 10
  • 11. Security •  Security is about Managing Risks Risk = P(Threat x Vulnerability x Impact) 11
  • 12. How secure are your apps ? •  How do you measure your apps’ security ? # of bugs ? # of bugs per line of code ?? # of bugs per code ??? … •  More important, how do you avoid security bugs in your apps!!! 12
  • 13. “Security Is a Process not a Product” Bruce Schneier 13
  • 14. 14
  • 15. So you think you’re secure? •  Just because you develop in {C,Perl,Python,Ruby,PHP,Java,<insert favorite language here>} it doesn’t mean your app is secure! •  Understand and know that you will fail •  Assess risks, and define controls 15
  • 16. User Input Validation •  Buffer Overflows / XSS / SQLi /… •  Applications don’t correctly validate what the user inputs •  Trust but verify 16
  • 17. Cross Site Scripting ....is a type of computer security vulnerability typically found in web applications which enable malicious attackers to inject client-side script into web pages viewed by other users. Source: Wikipedia 17
  • 18. Cross Site Scripting •  Example app code (pseudo code): ... $search = $_GET[‘search’]; $query = ‘SELECT * FROM DOCS where BODY LIKE “%$search%”; $result = sql_query($query); print “Here are the results to your query $search”; print_results($result); … 18
  • 19. Cross Site Scripting •  Application use: http://secureserver/?search=application+security 19
  • 20. Cross Site Scripting •  Application abuse: –  What if the user inputs some JavaScript ?? •  The attacker can potentially own the user’s browser… but how ? •  Typically through social engineering or your own web app 20
  • 21. Cross Site Scripting •  Back in 2002... “Multiple XSS Vulnerabilities in PHPNuke 6.0” •  In aprox. 1 hour “audit” 7 XSS vulnerabilities discovered (in 22 different input fields) •  All allowed any user to hijack other users’ sessions 21
  • 22. Cross Site Scripting •  In 2009… StrongWebMail Contest. US $10.000 Prize •  Everyone had the login and password. •  “Ultra” secure webmail system, confirmation of login using a cellphone. •  Owned by XSS. 22
  • 23. Cross Site Scripting Source: http://www.securescience.net/blog/ 23
  • 24. Cross Site Scripting •  What can you do ? –  Filter the input… …and the output •  Ask yourself: –  Do we really need to use HTML ? –  What is the intended input ? –  Are we outputting what we expect ? Unfortunately developers tend to blacklist… 24
  • 25. Cross Site Scripting •  But blacklist what ? <IMG """><SCRIPT>alert("XSS")</SCRIPT>"> <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))> <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&# 97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;> <IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#000 0114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000 101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#00000 83&#0000039&#0000041> … 25
  • 26. Cross Site Scripting •  Use a positive security model –  If you expect a name, why accept numbers or punctuation ? –  If you expect a date, why accept “<“ or “>” ? –  If you do expect HTML, make sure it is well filtered (that’s the hard part…) 26
  • 27. Injection •  Not only SQL. •  Technique first mentioned in 1998 by rain forest puppy in Phrack 54 •  OS injection is possibly older. •  LDAP is another target for injection. 27
  • 28. Injection ... $search = $_GET[‘search’]; $query = ‘SELECT * FROM DOCS where BODY LIKE “%$search%”’; $result = sql_query($query); print “Here are the results to your query $search”; print_results($result); … 28
  • 29. Injection •  Impact ? –  Heartland Security Breach: 130 million credit and debit cards –  Cost of the breach: US$12.6 Million 29
  • 32. Injection •  How do we protect ? –  Not so different from XSS. Same principles: –  Filter user input –  Whitelist what you know it’s safe –  Use stored procedures and views –  More ideas in a couple of slides… 32
  • 33. More Input Validation •  Cookies •  Headers (Referrer!) •  Any variables! –  There’s no such thing as hidden fields! –  User IDs ? –  Application flow –  Etc.. 33
  • 34. More Input Validation •  Example: –  Application checks the “Referrer” to ensure the user comes from an allowed origin. –  Who sets the Referrer ? Oooops… 34
  • 35. More Input Validation •  Example: –  If you trust the “hidden” field UserID, and the user sends it as “admin”, shouldn’t you verify it ? –  Use HMACs. –  More on this in a few slides 35
  • 36. Identification, Authentication and Authorization •  Most people don’t know the difference! •  Identification is easy! •  The hard part is authenticating and authorizing… 36
  • 37. Passwords & Login •  Lots of problems: –  Storage / Encryption ? –  Recovery ? –  Quality ? –  Bots / CAPTCHAs •  Why not outsource it ? 37
  • 38. Sessions •  Lots of problems: –  Unique –  Unreplayable –  Unpredictable –  Logging user off •  Use a proven framework 38
  • 39. Access Control •  How many apps use more than one database user ? •  If in certain parts of the app the user just needs to read (SELECT), why should it be able to write (INSERT/UPDATE) ? •  Does every part of the app need to read every table in the database ? 39
  • 40. Access Control •  The same applies to any object (on a database or not) •  If in certain parts of the app the user just needs to read information, why should it be able to write or change information? •  Does every part of the app need to access every piece of information ? 40
  • 41. Access Control •  Security Models to the rescue! 41
  • 42. Access Control •  Not those models… –  Biba (integrity) –  Bell-LaPadula (Confidentiality) –  Chinese-Wall (Brewer-Nash) (Conflicts of interest) •  Don’t reinvent the wheel… 42
  • 43. Access Control •  Define a security model for your app. •  How many profiles should you need ? •  Which are the access needs for each profile ? •  Implement the model with the controls you have. •  Implement controls you don’t have, but can. 43
  • 44. Access Control •  Ensure each subject has access to and only to the objects it is allowed to access!!! 44
  • 45. Encraption •  Encryption is hard •  Don’t come up with new algorithms. They’ll suck. •  Don’t come up with new implementations. See previous point. 45
  • 46. Encraption •  Debian OpenSSL •  Google KeyCzar •  SSL/TLS Renegotiation bug 46
  • 47. You’ve done all of the previous things, now you’re secure! 47
  • 48. 48
  • 49. Business Logic •  If the logic is flawed, the app is flawed •  Example: –  In a homebanking system, the user can transfer -€2000 to a different account. –  Oooops… 49
  • 50. Business Logic •  More examples –  On a site that sells electronics, the user bought 10 TV sets for €1000 each, and bought -20 Stereos for €500 each. –  Oooops… 50
  • 51. Business Logic •  And more… –  On a site that sells movie tickets, the user can choose the sit, and it stays locked until the payment is done, for a max. of 10 minutes. –  The user automates this, for every sit in the room, every 10 minutes. –  Oooops… 51
  • 52. Business Logic •  Still more… –  A company made a promotion, where you had to play a game (flash), using a special ID from their soda bottles. –  The top user had about 10x more points than the 2nd place. –  Results from each game were submitted from the flash application… –  Oooops… 52
  • 53. Business Logic •  Ok, Last one: –  An E-Commerce site had special discount coupons they sent their customers. –  Someone discovered the coupons codes where predictable. –  Oooops… 53
  • 54. Wrap-Up •  Always expect the worse •  Start thinking about security ASAP in the SDL •  Define a security model •  Analyze data flows and entry points •  Test the security of your app before the bad guys do •  Rinse & Repeat 54
  • 55. Community •  InfoSec-Pros-PT – Mailing-List and LinkedIn Group (~377 members) •  http://groups.google.com/group/InfoSec-Pros-PT •  http://www.linkedin.com/groups?gid=112919 •  Confraria Security&IT (Networking) •  Monthly informal meetings & dinner •  Free •  http://www.linkedin.com/groups?gid=1859900 55
  • 56. Thank You!" Q&A? Bruno Morisson CISSP, CISA, ISO27001LA morisson@genhex.org http://genhex.org/~mori/ 56
  • 57. References •  http://www.owasp.org •  http://www.webappsec.org •  http://jeremiahgrossman.blogspot.com/ •  http://ha.ckers.org/blog/ •  http://www.cl.cam.ac.uk/~rja14/book.html •  http://www.schneier.com/blog/ •  http://chargen.matasano.com/ •  http://www.cenzic.com/downloads/Cenzic_AppSecTrends_Q1-Q2-2009.pdf •  http://www.verizonbusiness.com/resources/security/reports/ 2009_databreach_rp.pdf •  http://sqlmap.sourceforge.net/ •  http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project •  http://portswigger.net/proxy/ •  http://www.parosproxy.org/ •  http://livehttpheaders.mozdev.org/ •  https://addons.mozilla.org/en-US/firefox/addon/966 (tamper data) 57