1 / 31

Auditing PHP applications

Auditing PHP applications. Auditer les applications en PHP. Agenda Ordre du jour. Workshop presentation Black box audit Source code audit Présentation de l’atelier Audit boîte noire Audit à code ouvert. Who speak? Qui parle?. Philippe Gamache

ayanna
Download Presentation

Auditing PHP applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Auditing PHP applications • Auditer les applications en PHP

  2. Agenda Ordre du jour • Workshop presentation • Black box audit • Source code audit • Présentation de l’atelier • Audit boîte noire • Audit à code ouvert

  3. Who speak? Qui parle? • Philippe Gamache • Parler Haut, Interagir Librement : Web development, security audit, training • info@ph-il.ca • @SecureSymfony • Philippe Gamache • Parler haut, interagir librement : Développement Web, audit de sécurité, formations • Caviste de cidres de glace • info@ph-il.ca • @SecureSymfony

  4. Security bookLivre de sécurité • New 2009 edition • Comprehensive review of security system for MySQL, PHP, etc. • Published in French • Planning translation • Nouvelle édition 2009 • Bilan complet de la sécurité : système, MySQL, PHP, etc • Edité chez Eyrolles • Dédicaces sur demande

  5. Yes, I take questionJe répond aux questions

  6. Why? Pourquoi? • Confidence does not exclude control™ • To validate external work • To validate internal work • Round-up • For an external perspective • As often as possible • La confiance n'exclut pas le contrôle™ • Pour valider un travail externe • Pour valider un travail interne • Pour faire le point • Pour avoir un regard externe • Aussi souvent que possible

  7. Full audit synopsis Synopsis d’un audit • Identification of the audit goals • Interview with the development teams • Black box testing • Open Code audit • Report • Identification des objectifs d'audit • Entretien avec les équipes de développement • Test boîte noir • Audit de code • Rapport

  8. Identification of the audit goals Identification des objectifs d’audit • Audit scope • Security • Performance • Étendue de l'audit • Sécurité • Performance

  9. Interview with the development teamsEntretien avec les équipes de développement • Check if development teams knows what to secure • Have the design explained first • Have them explains their approach • Check what they say • Check what they don’t say • Vérifiez si l’équipe de développement sait ce qu’il faut sécurisé • Demandez d’expliqué la conception • Demandez-leur d’explique leur approche • Vérifiez ce qu'ils disent • Vérifiez ce qu'ils ne disent pas

  10. The shy versionLa version timide • We know there are security problems • but we have no time to secure them • this app has been written years ago • we can’t keep up with the threats • Nous savons qu’il y a des problèmes de sécurité • mais nous n'avons pas le temps de les sécuriser • ce soft a été écrit il y a quelques années • nous ne pouvons pas suivre les menaces

  11. The strong versionLa version forte • We have secured the application • We use SSL and crypto • All content is validated and filtered • We don’t do any dynamical include • Our frameworks doesn’t allow this • Nous avons sécurisé l'application • Nous utilisons le protocole SSL et la cryptographie • Tout le contenu est validé et filtrée • Nous ne faisons aucune inclusion dynamique • Nos cadres d’applications sont secures

  12. Black box testingTest boîte noir • Easy to set up • Take into account the context of the application • Often spectacular • Generally shallow • Facile de mise en place • Prendre en compte le contexte de la demande • Souvent spectaculaires • Généralement peu profondes

  13. Black box testingTest boîte noir • Finding informations • Look for vulnerabilities • Automatic scanners • By hand • Fuzzing • Scenarios • Strikes • Recherche d’informations • Rechercher les vulnérabilités • Scanneurs automatiques • A la main • Fuzzing • Scénarios • Attaquer

  14. Black box testingTest boîte noir • Usual directories • includes, include, inc, com, classes, lib, library • admin, adm, administrator • tmp, TMP, ext, var • data, db, conf, config • uploads, install • Répertoires habituels • includes, include, inc, com, classes, lib, library • admin, adm, administrateur • tmp, TMP, ext, var • data, db, conf, config, configuration • uploads, install

  15. Black box testingTest boîte noir • Typical files • .phps, .inc, .class • xml, ini, yaml, cfg • .tar, .gz, .zip, .rar, .bz2 • Apache Alias : /icons/ • robots.txt • Fichiers typiques • .phps, .inc, .class • xml, ini, yaml, cfg • .tar, .gz, .zip, .rar, .bz2 • Apache Alias : /icons/ • robots.txt

  16. Open Code auditAudit de code • Look into the PHP code • Search for hidden problems • Usually less spectacular than black box • Easy to loose focus • Tempting to audit everything • Rechercher dans le code PHP • Rechercher les problèmes cachés • Habituellement, moins spectaculaire que les tests boîte noire • Facile de perdre sa concentration • Tentant de tout vérifier

  17. Approch Approche • What to search for? • What are the entry points? • What are the exit points? • Open-mindedness and discovery • How can they be exploited • Or protected ? • Que rechercher? • Quels sont les points d'entrée? • Quels sont les points de sortie? • Ouverture d’esprit et découverte • Comment peuvent-ils être exploités • Ou protégés?

  18. Assessing the codeÉvaluer le code • One liners • One line of code is sufficiently to be bad • Even though • you must follow the code • forward (for input) • in reverse (for output) • En une ligne • Une ligne de code est suffisamment pour être mauvais • Malgré tous • vous devez suivre le code • vers l’avant (entrées) • sens inverse (sorties) <?php $action = $_POST['action']; $query_string ="action=$action"; $link ="index.php?$query_string"; ?> <a href="<?php echo $link; ?>"> Click Here </a>

  19. What to search for?Que rechercher? • Injections • PHP • SQL • HTML • system • Injections • PHP • SQL • HTML • système

  20. Tools Outils • Your eyes • Text editors • grep • Fast, available, convenient • Tokenizer • Semantic, accurate • Vos yeux • Éditeurs de texte • grep • Rapide, disponible, pratique • Tokenizer • Sémantique, précis

  21. Tokenizer <?php print ("hello $world!"); ?> [1] => Array ( [0] => 266 [1] => print [2] => 1 ) [2] => Array ( [0] => 370 [1] => [2] => 1 ) [3] => ( [4] => " [5] => Array ( [0] => 314 [1] => hello [2] => 1 ) [6] => Array ( [0] => 309 [1] => $world [2] => 1 ) [7] => Array ( [0] => 314 [1] => ! [2] => 1 ) [8] => " [9] => ) [10] => ; [1] => Array ( [0] => PHP token [1] => PHP code [2] => Script line ) [2] => "

  22. PHP injectionsInjections PHP • dynamical inclusion • include, require and *_once • back ticks (`) • eval • Inclusions dynamiques d'inclusion • include, require and *_once • ` • eval

  23. Input Entrées • HTML Forms: • form • input • $_GET • $_POST • $_REQUEST • Formulaire HTML: • form • input • $_GET • $_POST • $_REQUEST

  24. Input Entrées • Databases: • mysql_query() • SELECT • HTTP Headers: • $_COOKIE • $_SERVER • Bases de données: • mysql_query() • SELECT • Entête HTTP: • $_COOKIE • $_SERVER

  25. Input Entrées • register_globals strikes back • Foreach and $$ • extract • import_request_var • $GLOBALS • parse_str • (ini_get(‘register_globals’)) • register_globals contre-attaque • Foreach and $$ • extract • import_request_var • $GLOBALS • parse_str • (ini_get(‘register_globals’))

  26. Output Sorties • Client: • echo • print • <?= • die • print_r • var_dump • Client: • echo • print • <?= • die • print_r • var_dump

  27. Output Sorties • Databases: • mysql_query() • mysqli_multi_query • update, delete, insert • Headers • header() • Bases de données: • mysql_query() • mysqli_multi_query • update, delete, insert • En-têtes • header()

  28. Output Sorties • System: • exec() • passthru() • system() • Système: • exec() • passthru() • system()

  29. Gotchas Pièges • Trust of HTTP Headers: • Referer • Trust of $_SERVER: • $_SERVER['PHP_SELF'] • Trust of Client-Side Restrictions: • maxlength • Confiance des en-têtes HTTP : • Referer • Confiance de $_SERVER : • $_SERVER['PHP_SELF'] • Confiance des restrictions clients: • maxlength

  30. Report Rapport

  31. Questions? • info@ph-il.ca • http://www.ph-il.ca • http://www.ph-il.ca/en/conferences • http://www.ph-il.ca/fr/conferences

More Related