{"id":106,"date":"2008-09-24T17:34:58","date_gmt":"2008-09-24T22:34:58","guid":{"rendered":"http:\/\/www.webadminblog.com\/?p=106"},"modified":"2008-09-24T17:34:58","modified_gmt":"2008-09-24T22:34:58","slug":"coding-secure-with-php-owasp-appsec-nyc-2008","status":"publish","type":"post","link":"https:\/\/www.webadminblog.com\/index.php\/2008\/09\/24\/coding-secure-with-php-owasp-appsec-nyc-2008\/","title":{"rendered":"Coding Secure with PHP &#8211; OWASP AppSec NYC 2008"},"content":{"rendered":"<p>This presentation was by Hans Zaunere, Managing Member, and it is entitled &#8220;PHundamental Security &#8211; Ecosystem Review, Coding Secure with PHP, and Best Practices&#8221;.\u00a0 Take a look at http:\/\/www.nyphp.org\/phundamentals\/ for the ongoing guide and best practices.\u00a0 Guru Stefan Esser recently presented an excellent talk at Zendcon.<\/p>\n<p>Security fundamentals are common across the board.\u00a0 Different environments have different requirements (desktop apps different from web\/internet apps).\u00a0 Web\/internet have a huge number of touch points.\u00a0 PHP isn&#8217;t responsible for all of them, but the developer is.\u00a0 Different languages handle in different ways.\u00a0 PHP is no different except &#8220;More internet applications speak PHP than any other&#8221;.\u00a0 PHP gets a bad rap.\u00a0 Low point of entry and great flexibility.\u00a0 There&#8217;s been some mistakes like weak default configuration, too forgiving for amateurs, the infamous magic_* of PHP, PHP Group argues what&#8217;s a security flaw.<\/p>\n<blockquote><p>It&#8217;s easy to shoot yourself in the foot with C.\u00a0 In C++ it&#8217;s harder to shoot yourself in the foot, but when you do, you blow off your whole leg. &#8211; Bjarne Stroustrup, Inventor of C++<\/p><\/blockquote>\n<p>Three zones of responsibility.\u00a0 PHP is effectively a wrapper around libraries and data sources.\u00a0 Many external dependencies and touch points.<\/p>\n<ol>\n<li>Poorly written code by amateur developers with no programming background.\u00a0 Primary cause for the security ecosystem around PHP.\u00a0 Laziness &#8211; letting PHP do it&#8217;s magic_*.\u00a0 &#8220;Program smart&#8221;<\/li>\n<li>Extensions and external libraries.\u00a0 PHP&#8217;s greatest asset.\u00a0 Sometimes library binding is faulty.\u00a0 Sometimes the external library has faults, or behaves in an unforeseen way when in a web environment &#8211; possible in any environment.\u00a0 Know what extensions you&#8217;re using, use the minimal number of extensions, and be aware of the environment they were originally designed for.\u00a0 &#8220;Know thy extensions&#8221;<\/li>\n<li>PHP Core &#8211; &#8220;PHP&#8221;.\u00a0 Secunia says 19 advisories for PHP between 2003-2008.\u00a0 Java had 38+ and Ruby 11+.\u00a0 &#8220;The list goes on &#8211; PHP is not alone&#8221;.\u00a0 One advisory in 2008.\u00a0 &#8220;More internet applications speak PHP than any other&#8221;<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\"><strong>Best Practices<\/strong><\/span><\/p>\n<ul>\n<li>Best practices are common to any well run enterprise environment.\u00a0 PHP is growing into this environment very quickly.<\/li>\n<li>Web security is largely about your data and less about exploits in the underlying platform.\u00a0 Buffer overflows aren&#8217;t so much the hot-topic.<\/li>\n<li>Installation &#8211; Avoid prepackaged installs, including RPMs, .deb, etc.\u00a0 If you use them, review their default deployment.\u00a0 Installation touch points also typically include MySQL\/Apache.<\/li>\n<li>Configuration &#8211; Use php.ini-recommended.\u00a0 Better yet, take the time to know what you&#8217;re doing and tune configuration files yourself.<\/li>\n<li>Don&#8217;t make PHP guess what you mean.\u00a0 Be explicit with variables and types.\u00a0 Don&#8217;t abuse scope &#8211; know where your variables come from.\u00a0 Avoid magic_* and implicitness &#8211; BE EXPLICIT.<\/li>\n<li>Keep code small, organized, and maintainable.\u00a0 Use OOP techniques to enforce code execution paths.\u00a0 Use includes to keep things organized.<\/li>\n<li>Don&#8217;t use super-globals directly &#8211; wrap for protection.<\/li>\n<\/ul>\n<blockquote><p>Be aggressive &#8211; B.E. aggressive<\/p><\/blockquote>\n<ul>\n<li>It&#8217;s always about data<\/li>\n<li>One of PHP&#8217;s greatest strengths &#8211; loosely typed.\u00a0 Also it&#8217;s biggest weakness.\u00a0 Don&#8217;t make PHP guess what you mean.<\/li>\n<li>Cast variables, know their type and the data you expect.\u00a0 Let PHP do it&#8217;s magic only when you want it to &#8211; not by chance.<\/li>\n<li>Keep tabs on your data&#8217;s path, lifecycle and type.\u00a0 Know where it&#8217;s come from, what it&#8217;s doing, and where it&#8217;s going.\u00a0 Filter\/escape\/cast and throw exceptions every step of the way.<\/li>\n<li>Input validation, output validation, CASTING.<\/li>\n<li>Don&#8217;t be lazy, be explicit, use OOP.<\/li>\n<\/ul>\n<blockquote><p>Casting isn&#8217;t just for movie producers<\/p><\/blockquote>\n<ul>\n<li>No system has a single security pressure point<\/li>\n<li>Don&#8217;t take the easy way out just because you can<\/li>\n<li>Put PHP in the same well managed enterprise environment as other technologies<\/li>\n<li>PHP\/AMP respond very well to TLC<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\"><strong>Conclusions<\/strong><\/span><\/p>\n<p>PHP is just part of the ecosystem and there is awareness and experience on the PHP side.\u00a0 The ying\/yang of PHP&#8217;s history overshadows reality.\u00a0 Stand by PHP and it&#8217;ll stand by you.\u00a0 Web\/internet applications are deep and complex.\u00a0 Users, interoperability, data, architecture, support, compliance.\u00a0 Phishing, hijacking, spam, sopcial engineering &#8211; BROWSERS!<\/p>\n<blockquote><p>PHP is the least of your worries<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This presentation was by Hans Zaunere, Managing Member, and it is entitled &#8220;PHundamental Security &#8211; Ecosystem Review, Coding Secure with PHP, and Best Practices&#8221;.\u00a0 Take a look at http:\/\/www.nyphp.org\/phundamentals\/ for the ongoing guide and best practices.\u00a0 Guru Stefan Esser recently presented an excellent talk at Zendcon. Security fundamentals are common across the board.\u00a0 Different environments [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[127,4],"tags":[76,128,91,154,12,161,90,622],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-owasp-appsec-nyc-2008","category-web-app-sec","tag-application","tag-appsec","tag-code","tag-coding","tag-owasp","tag-php","tag-secure","tag-security"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pfI0c-1I","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":1,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions\/107"}],"wp:attachment":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}