get-jwks, Cache Poisoning, CVE-2024-43605 (Critical)

Listen to this Post

The vulnerability in get-jwks stems from an insecure cache key generation algorithm. The library constructs a cache key by concatenating the JWT’s algorithm (alg), key ID (kid), and issuer (iss) domain with a colon (:) as a delimiter. An attacker can craft malicious `kid` and `iss` values that contain colons, causing a delimiter collision. By sending a first JWT from a malicious issuer with a carefully crafted `kid` (e.g., testkid:http://attacker.com/?`) and `iss` (e.g.,https://example.com`), the attacker forces the library to fetch and cache their public key under a specific key. A second JWT, with a valid issuer but a manipulated `kid` (e.g., testkid) and `iss` (e.g., http://attacker.com/?`), generates an identical cache key. This causes the victim application to retrieve the attacker's public key from the cache for validation of a token purportedly from a trusted issuer, effectively bypassing issuer validation because the check happens after the key is fetched.
Platform: Node.js
Version: get-jwks <9.0.4
Vulnerability: Cache Poisoning
Severity: Critical
<h2 style="color: blue;">date: 2024-08-21</h2>
<h2 style="color: blue;">Prediction: Patch expected 2024-08-23</h2>
<h2 style="color: blue;">What Undercode Say:</h2>

npm audit
git clone https://github.com/nearform/get-jwks
cd get-jwks
grep -n "cacheKey" src/get-jwks.js
// Vulnerable cache key generation (pre-fix)
const cacheKey =</code>${alg}:${kid}:${domain}<code>;
// Example of malicious input creating collision
const alg = 'RS256';
const kid = 'testkid:http://attacker.com/?';
const domain = 'https://example.com';
const maliciousKey =</code>${alg}:${kid}:${domain}<code>; // RS256:testkid:http://attacker.com/?:https://example.com
const kid2 = 'testkid';
const domain2 = 'http://attacker.com/?';
const validKey =</code>${alg}:${kid2}:${domain2}`; // RS256:testkid:http://attacker.com/?:https://example.com
// maliciousKey === validKey -> true

How Exploit:

1. Attacker sets up a malicious JWKS server.

  1. Attacker crafts JWT-1 with poisoned `kid` and `iss` to cache their public key.
  2. Attacker crafts JWT-2 with valid `iss` but manipulated `kid` to trigger cache hit.
  3. Victim server validates JWT-2 using the attacker's cached key, bypassing `iss` check.

Protection from this CVE

Upgrade get-jwks to version 9.0.4 or later. The patch properly escapes delimiters in cache key components.

Impact:

Authentication Bypass, Identity Spoofing, Full system compromise by impersonating any user.

🎯Let’s Practice Exploiting & Learn Patching For Free:

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top