<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rouwel Ngacha</title>
    <description>The latest articles on DEV Community by Rouwel Ngacha (@rrouwelng).</description>
    <link>https://dev.to/rrouwelng</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3924978%2F2d5c38e4-653e-4d1b-8628-91c93c7fd86c.png</url>
      <title>DEV Community: Rouwel Ngacha</title>
      <link>https://dev.to/rrouwelng</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rrouwelng"/>
    <language>en</language>
    <item>
      <title>the CSRF token</title>
      <dc:creator>Rouwel Ngacha</dc:creator>
      <pubDate>Mon, 11 May 2026 18:39:13 +0000</pubDate>
      <link>https://dev.to/rrouwelng/the-csrf-token-593p</link>
      <guid>https://dev.to/rrouwelng/the-csrf-token-593p</guid>
      <description>&lt;p&gt;Hello world, my name is rrouwelng and I am here to talk about the CSRF token. &lt;/p&gt;

&lt;p&gt;So, what is a CSRF token? A Cross-Site Request Forgery token is a unique and unpredictable value generated by server-side application. This was developed as a countermeasure to the &lt;strong&gt;Cross-Site Request Forgery attack&lt;/strong&gt; that was first documented in the early 2000's. &lt;/p&gt;

&lt;p&gt;What is a &lt;strong&gt;Cross-Site Request Forgery attack&lt;/strong&gt; ? Allow me to give an example.&lt;/p&gt;

&lt;p&gt;This is Bob,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1lrnh879rc547u6jqnf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1lrnh879rc547u6jqnf.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bob, logs into his bank at &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fulq6a5yw4jutlzwlf5ks.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fulq6a5yw4jutlzwlf5ks.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bob then decided to go read an article at a certain website at &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vpnks4och1uvcb198l4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vpnks4och1uvcb198l4.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that Bob hasn't logged out of his bank account.&lt;/p&gt;

&lt;p&gt;The site 'welikekittens.com' is set up by a malicious actor(call him swipper). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6h6xeko47lri6sotot3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6h6xeko47lri6sotot3.png" alt=" " width="478" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The website(welikekittens.com) is set up to send a form that is basically just a  POST request to Bob's bank website that basically tells it to credit a certain amount of money to the account of the attackers choosing.&lt;/p&gt;

&lt;p&gt;Because of how browsers work, every request(GET, POST or otherwise ) sent from bob's browser to the bank's server has the authentication cookies that Bob was given when he logged into the bank. This includes requests that weren't sent by Bob himself and are being sent by the malicious site.&lt;/p&gt;

&lt;p&gt;To counteract this, Bob's bank decides to use a CSRF-Token. When Bob interacts with the Bank interface, he receives a CSRF token that is embedded on the page. So now, if welikekittens.com tries to send a request from bob's browser, the bank's server checks the form to see if the CSRF token is included in the form. &lt;/p&gt;

&lt;p&gt;Since  it is not included the request is automatically denied because the request doesn't include the CSRF token.  As a bonus because of the Same-Origin Policy(basically means that one website cannot read the contents of another website unless they are from the same host. Feel free to look it up) welikekittens.com is unable to see the token and bob's bank account is safe for now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xb9al3tj93v7o2mr1u1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xb9al3tj93v7o2mr1u1.png" alt=" " width="444" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is CSRF tokens in a nutshell, feel free add or discredit what I have written (with proof of course :) ).&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cybersecurity</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
