{"id":21374,"date":"2023-01-18T19:18:43","date_gmt":"2023-01-18T13:48:43","guid":{"rendered":"https:\/\/valeurbit.com\/blog\/?p=21374"},"modified":"2023-01-18T19:18:44","modified_gmt":"2023-01-18T13:48:44","slug":"what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible","status":"publish","type":"post","link":"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/","title":{"rendered":"What is a CSRF attack: how it works and how to mitigate it as much as possible"},"content":{"rendered":"\n<p>A cross-site request attack is a type of obfuscated proxy cyberattack that causes a user to inadvertently use their credentials to trigger state-changing actions such as transferring funds from their account, changing their email address and password, or some other unwanted action.<\/p>\n\n\n\n<p>An obfuscated deputy is a computer program that uses its authority by trickery.&nbsp;This risk associated with this kind of vulnerability is why capability-based security helps mitigate the risks associated with misuse.&nbsp;For example, when installing software, most computers today require the user to log in.&nbsp;This helps prevent unintentional code execution when a user accidentally uses their authorization credentials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to prevent cross-site scripting<\/h2>\n\n\n\n<p>There is no single cross-site scripting mitigation strategy, and different types of web applications require different levels of protection.&nbsp;A number of protective measures can be taken:<\/p>\n\n\n\n<ul>\n<li>If possible, avoid HTML in the input.&nbsp;One very effective way to avoid constant cross-site scripting attacks is to prevent users from posting HTML in form inputs.&nbsp;There are other options that allow users to create rich content without using HTML, such as markdown and WYSIWYG editors.<\/li>\n\n\n\n<li>Input validation.&nbsp;Validation means implementing rules that prevent the user from submitting data to a form that does not meet certain criteria.&nbsp;For example, inputs that ask for the user&#8217;s &#8220;last name&#8221; should have validation rules that allow the user to submit data that consists of only alphanumeric characters.&nbsp;Validation rules can also be configured to reject any tags or characters commonly used in cross site scripting, such as &#8220;&lt;script&gt;&#8221; tags.<\/li>\n\n\n\n<li>Data cleaning.&nbsp;Data cleaning is similar to validation, but occurs after the data has already been sent to the web server, but before it is displayed to another user.&nbsp;There are several online tools that can scrape HTML and filter out any malicious code injections.<\/li>\n\n\n\n<li>Taking Security Measures for Cookies.&nbsp;Web applications can also set specific rules for handling cookies that can mitigate file theft through cross-site scripting.&nbsp;Cookies can be tied to specific IP addresses to prevent attackers using cross-site scripting from gaining access to them.&nbsp;You can also create rules to block JavaScript access to cookies.<\/li>\n<\/ul>\n\n\n\n<p>Configuring WAF Rules-WAF can also be configured to enforce rules that prevent cross-site scripting from being reflected.&nbsp;These WAF rules use strategies that block strange requests to the server, including cross-site scripting attacks.&nbsp;Cloudflare WAF offers a &#8220;rental&#8221; installation and protects web applications from cross-site scripting, DDoS attacks, SQL injection, and other common threats.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cross-site request forgery<\/h2>\n\n\n\n<p>While the potential impact on the average user is significant, a successful CSRF attack on an administrative account can compromise the entire server, potentially leading to the complete takeover of a web application, API, or other service.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How cross-site request forgery works<\/h2>\n\n\n\n<p>This attack targets state-changing requests, which are the type of request that changes data from one value to another.&nbsp;For example, a target request might make a purchase or change a value in an account.&nbsp;Interestingly, this is a &#8220;blind attack&#8221; and does not return any data to the attacker, making it a poor choice for stealing data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Here is an example of the 4th step in a cross-site request forgery attack:<\/h3>\n\n\n\n<ol start=\"1\">\n<li>The attacker creates a fake request that, when triggered, transfers $10,000 from a specific bank to his account.<\/li>\n\n\n\n<li>The attacker inserts a fake request into a hyperlink and sends it in bulk emails and also embeds it in websites.<\/li>\n\n\n\n<li>The victim clicks on an email or website link posted by the attacker, which results in the victim contacting the bank to transfer $10,000.<\/li>\n\n\n\n<li>The banking server receives the request, and since the victim is properly authorized, it treats the request as legitimate and transfers the funds.<\/li>\n<\/ol>\n\n\n\n<p>CSRF attacks vary in methodology, but typically have the following characteristics:<\/p>\n\n\n\n<ul>\n<li>They use websites that rely on the user&#8217;s identity;<\/li>\n\n\n\n<li>They trick the user&#8217;s browser into sending HTTP requests to the target site;<\/li>\n\n\n\n<li>These include the use of HTTP requests, which have side effects and do not have proper CSRF protection on the site.<\/li>\n<\/ul>\n\n\n\n<p>Different HTTP commands have different vulnerabilities to CSRF attacks, resulting in different security strategies.&nbsp;It has to do with how web browsers process requests.<\/p>\n\n\n\n<p>HTTP GET requests have built-in options such as internal image tags that can be manipulated and used.&nbsp;Generally, GET requests do not change state, making them ineffective as CSRF targets for a properly implemented web application or other resource.<\/p>\n\n\n\n<p>HTTP POST is used to change state, which increases the need for security.&nbsp;To this end, web browsers implement security measures called same-origin policy (SOP) and resource sharing (CORS), which contains the cross-origin security policy.&nbsp;SOP only allows requests from the same origin and CORS only allows certain types of requests to come from a different origin.&nbsp;The combination of these implementations helps prevent CSRF attacks (among others) by limiting the ability of a request or web page to interact with another origin.<\/p>\n\n\n\n<p>Other HTTP commands such as PUT and DELETE can only be fired with SOP and CORS, which reduces cross-site attacks.&nbsp;Although rare, some websites will explicitly disable these security measures, and they can also be disabled from inside the web browser.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A cross-site request attack is a type of obfuscated proxy cyberattack that causes a user to inadvertently use their credentials to trigger state-changing actions such as transferring funds from their account, changing their email address and password, or some other unwanted action. An obfuscated deputy is a computer program that uses its authority by trickery.&nbsp;This&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[36],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is a CSRF attack: how it works and how to mitigate it as much as possible | ValeurBit Infosec<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is a CSRF attack: how it works and how to mitigate it as much as possible | ValeurBit Infosec\" \/>\n<meta property=\"og:description\" content=\"A cross-site request attack is a type of obfuscated proxy cyberattack that causes a user to inadvertently use their credentials to trigger state-changing actions such as transferring funds from their account, changing their email address and password, or some other unwanted action. An obfuscated deputy is a computer program that uses its authority by trickery.&nbsp;This...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/\" \/>\n<meta property=\"og:site_name\" content=\"ValeurBit Infosec\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/valeurbitinfo\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-18T13:48:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-18T13:48:44+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@valeurbit\" \/>\n<meta name=\"twitter:site\" content=\"@valeurbit\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\",\"name\":\"Valeurbit Infosec\",\"url\":\"https:\/\/valeurbit.com\/blog\/\",\"sameAs\":[\"https:\/\/www.facebook.com\/valeurbitinfo\/\",\"https:\/\/www.instagram.com\/valeurbit\",\"https:\/\/www.linkedin.com\/company\/valeurbit-infosec\/\",\"https:\/\/twitter.com\/valeurbit\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/valeurbit.com\/blog\/wp-content\/uploads\/2021\/02\/Valeurbit-new-logo-center.png\",\"contentUrl\":\"https:\/\/valeurbit.com\/blog\/wp-content\/uploads\/2021\/02\/Valeurbit-new-logo-center.png\",\"width\":1080,\"height\":512,\"caption\":\"Valeurbit Infosec\"},\"image\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#website\",\"url\":\"https:\/\/valeurbit.com\/blog\/\",\"name\":\"ValeurBit Infosec\",\"description\":\"Cyber Security Company\",\"publisher\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/valeurbit.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#webpage\",\"url\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/\",\"name\":\"What is a CSRF attack: how it works and how to mitigate it as much as possible | ValeurBit Infosec\",\"isPartOf\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#website\"},\"datePublished\":\"2023-01-18T13:48:43+00:00\",\"dateModified\":\"2023-01-18T13:48:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/valeurbit.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is a CSRF attack: how it works and how to mitigate it as much as possible\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#webpage\"},\"author\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#\/schema\/person\/df20c1cd317765fa8677a3056caeccfa\"},\"headline\":\"What is a CSRF attack: how it works and how to mitigate it as much as possible\",\"datePublished\":\"2023-01-18T13:48:43+00:00\",\"dateModified\":\"2023-01-18T13:48:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/what-is-a-csrf-attack-how-it-works-and-how-to-mitigate-it-as-much-as-possible\/#webpage\"},\"wordCount\":889,\"publisher\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\"},\"keywords\":[\"csrf\"],\"articleSection\":[\"Valeurbit\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#\/schema\/person\/df20c1cd317765fa8677a3056caeccfa\",\"name\":\"ValeurBit\",\"sameAs\":[\"https:\/\/valeurbit.com\/blog\"],\"url\":\"https:\/\/valeurbit.com\/blog\/author\/valeurbit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts\/21374"}],"collection":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/comments?post=21374"}],"version-history":[{"count":1,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts\/21374\/revisions"}],"predecessor-version":[{"id":21375,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts\/21374\/revisions\/21375"}],"wp:attachment":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/media?parent=21374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/categories?post=21374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/tags?post=21374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}