{"id":911,"date":"2016-10-22T10:00:10","date_gmt":"2016-10-22T14:00:10","guid":{"rendered":"http:\/\/sethalling.com\/?p=911"},"modified":"2016-10-22T09:12:59","modified_gmt":"2016-10-22T13:12:59","slug":"security-vulnerability","status":"publish","type":"post","link":"https:\/\/sethalling.com\/security-vulnerability\/","title":{"rendered":"I Had a Security Vulnerability"},"content":{"rendered":"

A little less than a month ago I took a trip up to Pictured Rocks National Lakeshore with my family. While up there, I received a disconcerting email informing me that No Page Comment<\/a>, a plugin I’ve written that’s on the WordPress plugin repository, had a security vulnerability.<\/p>\n

“I am an IT security professional and I have found few problems in your WordPress plugin.”<\/p>\n

That’s how the email started. If you ever receive an email that begins with that, then it should make you a bit skeptic, and I was.<\/p>\n

Fortunately, I did not immediately delete the email. I read the whole thing and it was a very good idea.<\/p>\n

The sender listed two issues with the plugin: There was a cross-site scripting (XSS) security vulnerability and a Cross-Site Request Forgery (CSRF) security vulnerability.<\/p>\n

What is a cross-site scripting (XSS) security vulnerability?<\/h2>\n

In layman’s terms, it means someone can inject and run arbitrary JavaScript on the page. This means that your cookies can be accessed, as well as potential active sessions. If someone had access to that, then they could potentially gain access to the site you are on. This allows them to change your password and possibly lock you out of your site.<\/p>\n

Fortunately, on No Page Comment, that vulnerability was only found on the settings page in the admin section. It happened because I failed to sanitize a single URL on the page. By sanitizing the request URL from the server, I was able to patch this issue.<\/p>\n

What is a Cross-Site Request Forgery (CSRF) security vulnerability?<\/h2>\n

A CSRF is where someone can create a form on another URL, and submit it to your site. Basically, if someone can submit something to the wrong form, then the results can really hurt you.<\/p>\n

On No Page Comment, this security vulnerability affected the settings page in the admin section as well. Fortunately, it wasn’t anything major, but it could have been. If someone created an external form, and then linked to the admin page, they would be able to change the settings of no page comment. Those settings were only the comment and trackback defaults for the various post types, but it still was worrisome that someone could do that.<\/p>\n

My solution was to add a nonce to check and make sure the form was being submitted from the admin area of the site.<\/p>\n

How can developers prevent security vulnerabilities?<\/h2>\n

First, sanitize everything. If you don’t know what that means, take the time to learn about it<\/a>. Never code anything where someone can input something. Do what you can to prevent any possible leak. If you are in doubt of whether it needs to be sanitized, then just do it.<\/p>\n

Second, use your nonces<\/a>. Nonce means “number used once”. Think of it like an always changing access token. By setting a form or action in wordpress to use a nonce, you are verifying that the user or script has access to perform that task.<\/p>\n

How can WordPress users prevent security vulnerabilities?<\/h2>\n

Update everything!<\/strong><\/p>\n

I’m serious! Always make sure core WordPress is updated. Also, make sure your themes and plugins are up-to-date. Hopefully, if a developer learns they have a security vulnerability, they will patch it before it’s made public. As soon as that patch is released though, the vulnerability is made public. Always make sure your site is updated.<\/p>\n

I’m lucky because the person who revealed the issues to me said that they weren’t going to release their findings yet. They wanted to make sure I had time to fix them, which was nice, considering I was on a family trip to the UP (that’s the Upper Peninsula for all of you non-Michiganders).<\/p>\n

With that said, if you are a user of No Page Comment, please update now. While the issues aren’t anything major, it’s always best to close as many holes as possible.<\/p>\n","protected":false},"excerpt":{"rendered":"

A little less than a month ago I took a trip up to Pictured Rocks National Lakeshore with my family. While up there, I received a disconcerting email informing me that No Page Comment, a plugin I’ve written that’s on the WordPress plugin repository, had a security vulnerability. “I am an IT security professional and […]<\/p>\n","protected":false},"author":1,"featured_media":915,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[6],"tags":[15,45,5],"acf":[],"yoast_head":"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling<\/title>\n<meta name=\"description\" content=\"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sethalling.com\/security-vulnerability\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling\" \/>\n<meta property=\"og:description\" content=\"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sethalling.com\/security-vulnerability\/\" \/>\n<meta property=\"og:site_name\" content=\"Seth Alling\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-22T14:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-22T13:12:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"700\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Seth Alling\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seth Alling\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/\",\"url\":\"https:\/\/sethalling.com\/security-vulnerability\/\",\"name\":\"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling\",\"isPartOf\":{\"@id\":\"https:\/\/sethalling.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg\",\"datePublished\":\"2016-10-22T14:00:10+00:00\",\"dateModified\":\"2016-10-22T13:12:59+00:00\",\"author\":{\"@id\":\"https:\/\/sethalling.com\/#\/schema\/person\/31e4e1211a7d7d70251b7db49db74e37\"},\"description\":\"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?\",\"breadcrumb\":{\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/sethalling.com\/security-vulnerability\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage\",\"url\":\"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg\",\"contentUrl\":\"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg\",\"width\":1000,\"height\":700},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/sethalling.com\/security-vulnerability\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/sethalling.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"I Had a Security Vulnerability\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/sethalling.com\/#website\",\"url\":\"https:\/\/sethalling.com\/\",\"name\":\"Seth Alling\",\"description\":\"Detroit WordPress Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/sethalling.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/sethalling.com\/#\/schema\/person\/31e4e1211a7d7d70251b7db49db74e37\",\"name\":\"Seth Alling\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/sethalling.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4ad3f61b13af506ff4fd890f1fe4cd64?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4ad3f61b13af506ff4fd890f1fe4cd64?s=96&d=mm&r=g\",\"caption\":\"Seth Alling\"},\"description\":\"Detroit Web Developer & Graphic Designer Follow me: Twitter | WordPress | GitHub\",\"url\":\"https:\/\/sethalling.com\/author\/sethalling\/\"}]}<\/script>","yoast_head_json":{"title":"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling","description":"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sethalling.com\/security-vulnerability\/","og_locale":"en_US","og_type":"article","og_title":"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling","og_description":"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?","og_url":"https:\/\/sethalling.com\/security-vulnerability\/","og_site_name":"Seth Alling","article_published_time":"2016-10-22T14:00:10+00:00","article_modified_time":"2016-10-22T13:12:59+00:00","og_image":[{"width":1000,"height":700,"url":"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg","type":"image\/jpeg"}],"author":"Seth Alling","twitter_misc":{"Written by":"Seth Alling","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sethalling.com\/security-vulnerability\/","url":"https:\/\/sethalling.com\/security-vulnerability\/","name":"I Had a Security Vulnerability: Fixing No Page Comment by Seth Alling","isPartOf":{"@id":"https:\/\/sethalling.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage"},"image":{"@id":"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage"},"thumbnailUrl":"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg","datePublished":"2016-10-22T14:00:10+00:00","dateModified":"2016-10-22T13:12:59+00:00","author":{"@id":"https:\/\/sethalling.com\/#\/schema\/person\/31e4e1211a7d7d70251b7db49db74e37"},"description":"While on a family trip, I received an email informing me that No Page Comment had a security vulnerability or two. How do you fix XSS and CSRF issues?","breadcrumb":{"@id":"https:\/\/sethalling.com\/security-vulnerability\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sethalling.com\/security-vulnerability\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sethalling.com\/security-vulnerability\/#primaryimage","url":"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg","contentUrl":"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability.jpg","width":1000,"height":700},{"@type":"BreadcrumbList","@id":"https:\/\/sethalling.com\/security-vulnerability\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sethalling.com\/"},{"@type":"ListItem","position":2,"name":"I Had a Security Vulnerability"}]},{"@type":"WebSite","@id":"https:\/\/sethalling.com\/#website","url":"https:\/\/sethalling.com\/","name":"Seth Alling","description":"Detroit WordPress Developer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sethalling.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sethalling.com\/#\/schema\/person\/31e4e1211a7d7d70251b7db49db74e37","name":"Seth Alling","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sethalling.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4ad3f61b13af506ff4fd890f1fe4cd64?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ad3f61b13af506ff4fd890f1fe4cd64?s=96&d=mm&r=g","caption":"Seth Alling"},"description":"Detroit Web Developer & Graphic Designer Follow me: Twitter | WordPress | GitHub","url":"https:\/\/sethalling.com\/author\/sethalling\/"}]}},"mv":{"thumbnail_id":915,"thumbnail_uri":"https:\/\/sethalling.com\/content\/uploads\/2016\/10\/security-vulnerability-300x210.jpg"},"_links":{"self":[{"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/posts\/911"}],"collection":[{"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/comments?post=911"}],"version-history":[{"count":0,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/posts\/911\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/media\/915"}],"wp:attachment":[{"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/media?parent=911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/categories?post=911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sethalling.com\/wp-json\/wp\/v2\/tags?post=911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}