SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Tietoturva Web-kehityksessä
             &
    Zend Frameworkissä
    PHP User Group Finland
         24.11.2011
Kuka?
• Carl (Kalle) Vuorinen         • Matti Suominen
  –                      :ssa     –                   :ssa
      vuodesta 2005                   vuodesta 2007
       • PHP kehittäjä                 • Tietoturvahörhö
       • Tiiminvetäjä                  • Osakas
       • Osakas
Mitä?
• Tietoturva                                  • Zend Framework
     – OWASP Top Ten                            – MVC framework
     – 10 kriittisintä web                      – Komponentti kirjasto
       sovellusten
       tietoturvariskiä                        Extending the art & spirit of PHP, Zend
                                               Framework is based on simplicity,
     – Injektio, XSS, CSRF,                    object-oriented best practices,
       salasanojen suojaus                     corporate friendly licensing, and a
https://www.owasp.org/index.php/Top_10_2010    rigorously tested agile codebase.
                                               http://framework.zend.com/about/overview
Miksi?
Miksi?
Miksi?
Miksi?
Miksi?
Tietoturva Zend
Frameworkissä
SQL injektio
SQL injektio
• Erikoismerkkien muuntaminen
  – Escaping
• Syötteiden tarkistukset
  – Filtteröinti & validointi
• SQL lauseiden esikäsittely
  – Prepared statements
Prepared statements
• Zend_Db_Adapter & Zend_Db_Statement
  $sql = 'SELECT * FROM bugs WHERE bug_id = ?';

  $result = $db->fetchAll($sql, $bugId);


• Zend_Db_Select
  $select = $db->select()
               ->from('products',
                      array('product_id', 'product_name', 'price'))
               ->where('price > ?', $minimumPrice);


• Zend_Db_Table
  $table = new Bugs();

  $rows = $table->find($bugId);
XSS
XSS
• Tulosteiden siistiminen
  – Escape output
• Syötteiden tarkistukset
  – Filtteröinti & validointi
• PHP session konfigurointi
  – httpOnly cookie
Escape output
• Zend_View escape() metodi
  <?php foreach ($this->books as $key => $val): ?>
  <tr>
       <td><?php echo $this->escape($val['author']) ?></td>
       <td><?php echo $this->escape($val['title']) ?></td>
  </tr>
  <?php endforeach; ?>
Filtteröinti & validointi
• Zend_Form ja Zend_Filter &
  Zend_Validate
  $this->addElement(
      text', 'username', array(
          'required'   => true,
          'label'      => 'Username:',
          'filters'    => array('StringTrim', 'StringToLower'),
          'validators' => array(
              'Alnum',
              array('Regex',
                    false,
                    array('/^[a-z][a-z0-9]{2,}$/'))
          )
      ));


• Zend_Filter_Input
Filtteröinti & validointi - HTML
• HTMLPurifier
  – HTML Purifier defeats XSS with an audited
    whitelist
   http://htmlpurifier.org/



  – class My_Filter_HtmlPurifier
    implements Zend_Filter_Interface
CSRF
CSRF
• Piilotettu uniikki tunniste
  – Hidden unique token
Piilotettu uniikki tunniste
• Zend_Form_Hash
  $form->addElement('hash', 'no_csrf_foo', array('salt' => 'unique'));




• Automaattinen CSRF suojaus
  – Extend Zend_Form


• Linkkien suojaus
  – Javascript POST
Riittämätön salasanojen
suojaus
Riittämätön salasanojen
             suojaus
• Hashing
  – MD5 ei riitä
  – bcrypt
  – Hitaampi on parempi
Hashing
• PHPASS
 – Portable PHP password hashing framework
   http://www.openwall.com/phpass/



 – class My_Auth_Adapter_DbTableHash
   extends Zend_Auth_Adapter_DbTable
Kysymyksiä ?
Referenssit
•   http://framework.zend.com/
•   https://www.owasp.org/
•   http://static.zend.com/topics/Webinar-Zend-Secure-Application-Development-with-
    the-Zend-Framework.pdf
•   http://htmlpurifier.org/
•   http://blog.astrumfutura.com/2008/05/example-zend-framework-blog-application-
    tutorial-part-8-creating-and-editing-blog-entries-with-a-dash-of-htmlpurifier/
•   https://www.owasp.org/index.php/Cross-
    Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet
•   http://www.openwall.com/phpass/
•   http://www.openwall.com/articles/PHP-Users-Passwords
•   http://codahale.com/how-to-safely-store-a-password/

Más contenido relacionado

Destacado

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Destacado (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

3.w3 php user group 24112011 tietoturva web-kehityksessa-&-zend-frameworkissa carl vuorinen

  • 1. Tietoturva Web-kehityksessä & Zend Frameworkissä PHP User Group Finland 24.11.2011
  • 2. Kuka? • Carl (Kalle) Vuorinen • Matti Suominen – :ssa – :ssa vuodesta 2005 vuodesta 2007 • PHP kehittäjä • Tietoturvahörhö • Tiiminvetäjä • Osakas • Osakas
  • 3. Mitä? • Tietoturva • Zend Framework – OWASP Top Ten – MVC framework – 10 kriittisintä web – Komponentti kirjasto sovellusten tietoturvariskiä Extending the art & spirit of PHP, Zend Framework is based on simplicity, – Injektio, XSS, CSRF, object-oriented best practices, salasanojen suojaus corporate friendly licensing, and a https://www.owasp.org/index.php/Top_10_2010 rigorously tested agile codebase. http://framework.zend.com/about/overview
  • 11. SQL injektio • Erikoismerkkien muuntaminen – Escaping • Syötteiden tarkistukset – Filtteröinti & validointi • SQL lauseiden esikäsittely – Prepared statements
  • 12. Prepared statements • Zend_Db_Adapter & Zend_Db_Statement $sql = 'SELECT * FROM bugs WHERE bug_id = ?'; $result = $db->fetchAll($sql, $bugId); • Zend_Db_Select $select = $db->select() ->from('products', array('product_id', 'product_name', 'price')) ->where('price > ?', $minimumPrice); • Zend_Db_Table $table = new Bugs(); $rows = $table->find($bugId);
  • 13. XSS
  • 14. XSS • Tulosteiden siistiminen – Escape output • Syötteiden tarkistukset – Filtteröinti & validointi • PHP session konfigurointi – httpOnly cookie
  • 15. Escape output • Zend_View escape() metodi <?php foreach ($this->books as $key => $val): ?> <tr> <td><?php echo $this->escape($val['author']) ?></td> <td><?php echo $this->escape($val['title']) ?></td> </tr> <?php endforeach; ?>
  • 16. Filtteröinti & validointi • Zend_Form ja Zend_Filter & Zend_Validate $this->addElement( text', 'username', array( 'required' => true, 'label' => 'Username:', 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array( 'Alnum', array('Regex', false, array('/^[a-z][a-z0-9]{2,}$/')) ) )); • Zend_Filter_Input
  • 17. Filtteröinti & validointi - HTML • HTMLPurifier – HTML Purifier defeats XSS with an audited whitelist http://htmlpurifier.org/ – class My_Filter_HtmlPurifier implements Zend_Filter_Interface
  • 18. CSRF
  • 19. CSRF • Piilotettu uniikki tunniste – Hidden unique token
  • 20. Piilotettu uniikki tunniste • Zend_Form_Hash $form->addElement('hash', 'no_csrf_foo', array('salt' => 'unique')); • Automaattinen CSRF suojaus – Extend Zend_Form • Linkkien suojaus – Javascript POST
  • 22. Riittämätön salasanojen suojaus • Hashing – MD5 ei riitä – bcrypt – Hitaampi on parempi
  • 23. Hashing • PHPASS – Portable PHP password hashing framework http://www.openwall.com/phpass/ – class My_Auth_Adapter_DbTableHash extends Zend_Auth_Adapter_DbTable
  • 25. Referenssit • http://framework.zend.com/ • https://www.owasp.org/ • http://static.zend.com/topics/Webinar-Zend-Secure-Application-Development-with- the-Zend-Framework.pdf • http://htmlpurifier.org/ • http://blog.astrumfutura.com/2008/05/example-zend-framework-blog-application- tutorial-part-8-creating-and-editing-blog-entries-with-a-dash-of-htmlpurifier/ • https://www.owasp.org/index.php/Cross- Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet • http://www.openwall.com/phpass/ • http://www.openwall.com/articles/PHP-Users-Passwords • http://codahale.com/how-to-safely-store-a-password/