{"id":8162,"date":"2021-07-23T19:24:44","date_gmt":"2021-07-24T00:24:44","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=8162"},"modified":"2021-08-19T10:27:12","modified_gmt":"2021-08-19T15:27:12","slug":"fortify-on-demand-remediation-header-injection-cookies","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=8162","title":{"rendered":"Fortify on Demand Remediation &#8211; Header Injection: Cookies"},"content":{"rendered":"<p>Cookie injection vulnerabilities occur when user input is stored into a cookie. It&#8217;s possible for malicious input to include newline characters that would be parsed out as new elements in the cookie. As an example, if I send my user ID as &#8220;lisa\\r\\nadmin: true&#8221; &#8230; I&#8217;ve got a cookie that says the userID is lisa and admin is true.<\/p>\n<p>With Fortify on Demand, you cannot just filter out \\r and \\n characters \u2013 Fortify still says the code is vulnerable. You can, however, filter out anything apart from alpha-numeric characters (and, I assume, any oddball character that has a legit reason to be included in the user input):<\/p>\n<p>$strLogonUserID = filter_var(preg_replace(&#8216;\/[^a-z\\d_]\/iu&#8217;, &#8221;, $_POST[&#8216;strUID&#8217;]), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cookie injection vulnerabilities occur when user input is stored into a cookie. It&#8217;s possible for malicious input to include newline characters that would be parsed out as new elements in the cookie. As an example, if I send my user ID as &#8220;lisa\\r\\nadmin: true&#8221; &#8230; I&#8217;ve got a cookie that says the userID is lisa &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[45,1437,35,69,1329],"class_list":["post-8162","post","type-post","status-publish","format-standard","hentry","category-coding","tag-coding","tag-fortify-on-demand","tag-php","tag-security","tag-web-coding"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8162"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8162\/revisions"}],"predecessor-version":[{"id":8163,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8162\/revisions\/8163"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}