<?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: Artem Lupyr</title>
    <description>The latest articles on DEV Community by Artem Lupyr (@arty_arty).</description>
    <link>https://dev.to/arty_arty</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4281166%2Fcd79621d-c82c-42f4-861a-c2a67fd5def8.png</url>
      <title>DEV Community: Artem Lupyr</title>
      <link>https://dev.to/arty_arty</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arty_arty"/>
    <language>en</language>
    <item>
      <title>Post-Quantum JWTs in .NET 10: What Breaks When You Switch to ML-DSA</title>
      <dc:creator>Artem Lupyr</dc:creator>
      <pubDate>Thu, 03 Dec 2026 17:55:03 +0000</pubDate>
      <link>https://dev.to/arty_arty/post-quantum-jwts-in-net-10-what-breaks-when-you-switch-to-ml-dsa-484b</link>
      <guid>https://dev.to/arty_arty/post-quantum-jwts-in-net-10-what-breaks-when-you-switch-to-ml-dsa-484b</guid>
      <description>&lt;p&gt;I swapped RS256 for post-quantum ML-DSA in a real JWT flow on .NET 10. Signing and verification speed barely changed. Token size grew up to 10x, and the browser silently dropped my auth cookie.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother now
&lt;/h2&gt;

&lt;p&gt;Short-lived JWTs are not the most urgent quantum target. "Harvest now, decrypt later" is a threat to encrypted traffic. A signature only matters while it is being verified, so a 15-minute token cannot be forged after the fact.&lt;/p&gt;

&lt;p&gt;The pressure comes from deadlines. NIST published the final IR 8547 on October 27, 2026. It deprecates RSA, ECDSA and EdDSA after 2030 at every key size, RSA-3072 and P-256 included, and disallows them after 2035. US federal high-value systems must move to post-quantum signatures by December 31, 2031 (&lt;a href="https://labs.cloudsecurityalliance.org/research/csa-research-note-nist-ir8547-pqc-transition-20261030-csa-st/" rel="noopener noreferrer"&gt;CSA summary&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;An auth stack spans identity providers, gateways, SDKs and every API that validates tokens. That is years of work, so 2031 is close. I wanted to know what actually breaks before planning it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The experiment
&lt;/h2&gt;

&lt;p&gt;A minimal ASP.NET Core app issues and validates JWTs signed with five algorithms. RS256 (RSA-2048) and ES256 (ECDSA P-256) are the classic baseline. ML-DSA-44, -65 and -87 come from the new &lt;code&gt;System.Security.Cryptography.MLDsa&lt;/code&gt; class in .NET 10.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Payload:&lt;/strong&gt; a realistic access token with &lt;code&gt;iss&lt;/code&gt;, &lt;code&gt;aud&lt;/code&gt;, &lt;code&gt;sub&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;roles&lt;/code&gt;, &lt;code&gt;iat&lt;/code&gt; and &lt;code&gt;exp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JWT:&lt;/strong&gt; built by hand in about 60 lines, &lt;code&gt;base64url(header).base64url(payload).base64url(signature)&lt;/code&gt;. This keeps the experiment dependency-free and easy to inspect. Microsoft.IdentityModel has since gained ML-DSA support (&lt;a href="https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/pull/3479" rel="noopener noreferrer"&gt;PR #3479&lt;/a&gt;, merged May 2026), so check your version before rolling your own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;alg&lt;/code&gt; values:&lt;/strong&gt; &lt;code&gt;ML-DSA-44&lt;/code&gt;, &lt;code&gt;ML-DSA-65&lt;/code&gt;, &lt;code&gt;ML-DSA-87&lt;/code&gt;, the JOSE names.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timings:&lt;/strong&gt; 20 warm-up calls, then the average of 200. Good for orders of magnitude, not for a benchmark paper.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine:&lt;/strong&gt; Windows (NT 10.0.26300), 16 cores, .NET 10.0.10. ML-DSA needs Windows 11 / Server 2025 with the PQC updates, or Linux with OpenSSL 3.5+.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;ML-DSA tokens are 5.7–10.4× larger than RS256, while signing and verification stay well under 1.5 ms.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;Public key, bytes&lt;/th&gt;
&lt;th&gt;Signature, bytes&lt;/th&gt;
&lt;th&gt;Token, chars&lt;/th&gt;
&lt;th&gt;Fits a 4 KB cookie&lt;/th&gt;
&lt;th&gt;Sign, µs&lt;/th&gt;
&lt;th&gt;Verify, µs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RS256&lt;/td&gt;
&lt;td&gt;294&lt;/td&gt;
&lt;td&gt;256&lt;/td&gt;
&lt;td&gt;619&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;667&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ES256&lt;/td&gt;
&lt;td&gt;91&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;363&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;191&lt;/td&gt;
&lt;td&gt;174&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ML-DSA-44&lt;/td&gt;
&lt;td&gt;1,312&lt;/td&gt;
&lt;td&gt;2,420&lt;/td&gt;
&lt;td&gt;3,510&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;542&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ML-DSA-65&lt;/td&gt;
&lt;td&gt;1,952&lt;/td&gt;
&lt;td&gt;3,309&lt;/td&gt;
&lt;td&gt;4,695&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;899&lt;/td&gt;
&lt;td&gt;137&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ML-DSA-87&lt;/td&gt;
&lt;td&gt;2,592&lt;/td&gt;
&lt;td&gt;4,627&lt;/td&gt;
&lt;td&gt;6,453&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1,183&lt;/td&gt;
&lt;td&gt;212&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All five tokens still fit in an 8 KB header line, the nginx default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 1: size is the real cost
&lt;/h2&gt;

&lt;p&gt;An ML-DSA-65 token is 7.6× the size of an RS256 token and 13× the size of ES256. The signature alone is 3,309 bytes, which base64url turns into 4,412 characters.&lt;/p&gt;

&lt;p&gt;That size lands everywhere the token travels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cookies.&lt;/strong&gt; Browsers cap a single cookie at about 4,096 bytes. ML-DSA-65 and ML-DSA-87 do not fit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Headers.&lt;/strong&gt; nginx allows 8 KB per header line by default, and Kestrel 32 KB for all headers combined. ML-DSA-87 fits both, but load balancers, API gateways and WAFs have their own limits, and the token shares them with every other header.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every request.&lt;/strong&gt; A 4.7 KB bearer token on every API call adds real bandwidth, especially on mobile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JWKS.&lt;/strong&gt; Public keys grow from 91–294 bytes to 1.3–2.6 KB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Finding 2: speed is a non-issue
&lt;/h2&gt;

&lt;p&gt;Signing with ML-DSA-65 took 0.9 ms against 0.67 ms for RS256, and ML-DSA-44 was faster than RS256. Tokens are signed once per login or refresh, so this barely matters.&lt;/p&gt;

&lt;p&gt;Verification is what an API does on every request. ML-DSA took 80–212 µs against 16 µs for RSA, which is cheap to verify because its public exponent is small. Yet ML-DSA-44 and -65 verified faster than ES256 (174 µs), which many teams already run in production. A tenth of a millisecond per request is noise next to a database call.&lt;/p&gt;

&lt;p&gt;One caveat on baselines: an earlier console test showed ML-DSA-65 signing about 3× faster than RSA. That was RSA-3072, which is much slower than the RSA-2048 most JWTs use. Compare against what you actually run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 3: the silent cookie failure
&lt;/h2&gt;

&lt;p&gt;The most dangerous result produced no error at all. Here is what happened in a real browser:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign in with RS256. The token goes into an HttpOnly cookie, and &lt;code&gt;/whoami&lt;/code&gt; says authenticated.&lt;/li&gt;
&lt;li&gt;Switch the issuer to ML-DSA-65. The server sends a 4.7 KB &lt;code&gt;Set-Cookie&lt;/code&gt;, and the browser silently drops it.&lt;/li&gt;
&lt;li&gt;The browser keeps sending the &lt;strong&gt;old&lt;/strong&gt; RS256 cookie.&lt;/li&gt;
&lt;li&gt;In my run that old cookie was signed with a key from a previous app start, so validation failed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"authenticated"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cookie"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"alg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"RS256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Invalid signature."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"note"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"You requested a ML-DSA-65 cookie, but the browser sent an older RS256 one: the new cookie was rejected and the old one kept."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing points at the real cause. The server logs show an invalid RS256 token, not an oversized ML-DSA cookie. In a production rollout this looks like random logouts right after the algorithm switch. The &lt;code&gt;note&lt;/code&gt; exists only because the demo sets a second, tiny cookie recording which &lt;code&gt;alg&lt;/code&gt; it tried to store.&lt;/p&gt;

&lt;p&gt;Test this in a real browser: curl does not enforce cookie size limits, so the bug never shows up there.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do about it
&lt;/h2&gt;

&lt;p&gt;There is no single fix. Pick by where your tokens live and which rules you answer to.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;How it works&lt;/th&gt;
&lt;th&gt;Trade-off&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Use ML-DSA-44&lt;/td&gt;
&lt;td&gt;3,510-char token fits a 4 KB cookie&lt;/td&gt;
&lt;td&gt;NIST category 2; a few extra claims overflow it; CNSA 2.0 systems must use ML-DSA-87&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep tokens off the browser (BFF)&lt;/td&gt;
&lt;td&gt;The cookie holds a session ID; tokens stay server-side&lt;/td&gt;
&lt;td&gt;Needs a session store; the cleanest fix for web apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Split the cookie&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ChunkingCookieManager&lt;/code&gt; stores the value as numbered chunks&lt;/td&gt;
&lt;td&gt;Every request still carries 4.7 KB+; per-domain cookie limits still apply&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reference tokens&lt;/td&gt;
&lt;td&gt;Opaque handle plus introspection at the auth server&lt;/td&gt;
&lt;td&gt;Tiny tokens, but an extra call per validation (cacheable)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;ASP.NET Core already ships the chunking option: cookie authentication uses it by default for large auth tickets. You can also use it directly for your own cookies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nc"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AspNetCore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Authentication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Cookies&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cookies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ChunkingCookieManager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ChunkSize = 4050 by default&lt;/span&gt;

&lt;span class="c1"&gt;// Write: a 4.7 KB token becomes access_token=chunks-2, access_tokenC1, access_tokenC2&lt;/span&gt;
&lt;span class="n"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AppendResponseCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"access_token"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Read: the chunks are reassembled transparently&lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetRequestCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"access_token"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I checked this with a 4,700-character value: it was split into two chunks and read back intact.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Measure size, not speed.&lt;/strong&gt; CPU cost barely moves; bytes grow 5–10×.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Map where tokens live:&lt;/strong&gt; cookies, headers, query strings, logs, database columns, gateway limits. Each one is a place an ML-DSA token can silently stop fitting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test the failure path in a real browser.&lt;/strong&gt; The worst bug here produced no error on either side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan the rollover.&lt;/strong&gt; During migration, validators must accept old and new algorithms at once. Pin the expected &lt;code&gt;alg&lt;/code&gt; per key (&lt;code&gt;kid&lt;/code&gt;) instead of trusting the token header.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Source code: &lt;a href="https://github.com/kapitaneo/PqcJwt" rel="noopener noreferrer"&gt;github.com/kapitaneo/PqcJwt&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://labs.cloudsecurityalliance.org/research/csa-research-note-nist-ir8547-pqc-transition-20261030-csa-st/" rel="noopener noreferrer"&gt;CSA research note: NIST IR 8547 final&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/dotnet/core/whats-new/dotnet-10/libraries" rel="noopener noreferrer"&gt;What's new in .NET 10 libraries: post-quantum cryptography&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/pull/3479" rel="noopener noreferrer"&gt;Microsoft.IdentityModel PR #3479: ML-DSA support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>security</category>
      <category>cryptography</category>
    </item>
  </channel>
</rss>
