<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tools on Ankit Maurya</title>
    <link>https://ankitmaurya.pages.dev/tags/tools/</link>
    <description>Recent content in Tools on Ankit Maurya</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 05 Mar 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://ankitmaurya.pages.dev/tags/tools/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>JWT Security Analysis</title>
      <link>https://ankitmaurya.pages.dev/projects/jwt-analysis/</link>
      <pubDate>Tue, 05 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://ankitmaurya.pages.dev/projects/jwt-analysis/</guid>
      <description>&lt;p&gt;Tools and techniques for analyzing JWT tokens for authentication vulnerabilities.&lt;/p&gt;&#xA;&lt;h2 id=&#34;jwt-overview&#34;&gt;JWT Overview&lt;/h2&gt;&#xA;&lt;p&gt;JSON Web Tokens (JWT) are commonly used for authentication but can introduce security issues if not implemented correctly.&lt;/p&gt;&#xA;&lt;h2 id=&#34;common-vulnerabilities&#34;&gt;Common Vulnerabilities&lt;/h2&gt;&#xA;&lt;h3 id=&#34;algorithm-confusion-alg-none&#34;&gt;Algorithm Confusion (alg: none)&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Exploit: Change alg to &amp;#34;none&amp;#34; and remove signature&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;header&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;alg&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;none&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;typ&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;JWT&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;payload&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;sub&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;1234567890&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;role&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;admin&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;key-confusion-rs256-to-hs256&#34;&gt;Key Confusion (RS256 to HS256)&lt;/h3&gt;&#xA;&lt;p&gt;If the server uses RS256 but the library accepts HS256 with the public key as the secret.&lt;/p&gt;&#xA;&lt;h2 id=&#34;analysis-tools&#34;&gt;Analysis Tools&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;JWT.io for manual inspection&lt;/li&gt;&#xA;&lt;li&gt;Custom Python scripts for batch analysis&lt;/li&gt;&#xA;&lt;li&gt;Burp Suite extension for runtime inspection&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;validation-checklist&#34;&gt;Validation Checklist&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Verify signature with correct algorithm&lt;/li&gt;&#xA;&lt;li&gt;Check token expiration (exp claim)&lt;/li&gt;&#xA;&lt;li&gt;Validate audience (aud claim)&lt;/li&gt;&#xA;&lt;li&gt;Ensure proper key management&lt;/li&gt;&#xA;&lt;li&gt;Use strong secret keys (256-bit minimum)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;best-practices&#34;&gt;Best Practices&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Always validate algorithm expected by your application&lt;/li&gt;&#xA;&lt;li&gt;Use asymmetric algorithms (RS256) when possible&lt;/li&gt;&#xA;&lt;li&gt;Implement token rotation&lt;/li&gt;&#xA;&lt;li&gt;Set appropriate expiration times&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
  </channel>
</rss>
