SECURITYCRITICALCVE-2026-18248

CVE-2026-18248: Fastify AWS Lambda Auth Bypass Allows Privilege Escalation

A critical vulnerability in @fastify/aws-lambda 6.4.0 allows attackers to spoof AWS API Gateway authorizer claims by sending crafted HTTP headers,...

Dylan H.

Security Team

August 4, 2026
5 min read
CVE-2026-18248: Fastify AWS Lambda Auth Bypass Allows Privilege Escalation

Critical severity

Rated critical. Prioritise patching — see the remediation guidance below.

Affected Products

  • @fastify/aws-lambda 6.4.0

Executive Summary

A critical authentication bypass vulnerability (CVE-2026-18248, CVSS 9.1) has been disclosed in @fastify/aws-lambda version 6.4.0 — the official adapter for running Fastify web applications on AWS Lambda. The vulnerability allows remote attackers to spoof AWS API Gateway authorizer claims, bypassing authorization decisions in any Fastify application that relies on request.awsLambda.event for access control.

Any serverless application on AWS Lambda using this adapter for authorization decisions is potentially vulnerable to unauthenticated access and privilege escalation.


Vulnerability Overview

AttributeValue
CVE IDCVE-2026-18248
CVSS Score9.1 (Critical)
TypeAuthentication Bypass / Authorization Spoofing
Attack VectorNetwork (no prior authentication required)
Privileges RequiredNone
User InteractionNone
Affected Package@fastify/aws-lambda 6.4.0

Affected Versions

PackageAffected VersionFixed Version
@fastify/aws-lambda6.4.0Check upstream for patch

Technical Analysis

@fastify/aws-lambda decorates each incoming Fastify request with two objects:

  • request.awsLambda.event — the raw API Gateway event object
  • request.awsLambda.context — the Lambda execution context

The official documentation encourages developers to use request.awsLambda.event for authorization decisions — particularly for reading API Gateway authorizer claims (e.g., claims set by a Lambda Authorizer or Cognito JWT).

In version 6.4.0, the getter that populates these values can be overridden or spoofed via crafted HTTP headers. In the default configuration, an attacker can send a specially crafted request that makes the application's authorization logic read attacker-controlled values as if they were legitimate API Gateway authorizer claims.

Vulnerable Authorization Pattern (commonly documented):
const claims = request.awsLambda.event.requestContext.authorizer.claims;
if (claims.role === 'admin') {
  // Allow access to admin resource
}
 
Attack:
1. Attacker crafts HTTP request with headers that override event properties
2. Application reads crafted headers as trusted authorizer claims
3. Authorization check passes with attacker-supplied role/group values
4. Attacker gains unauthorized access to protected resources

Impact Assessment

ImpactDescription
Authentication BypassBypass Lambda Authorizer and Cognito checks
Privilege EscalationClaim admin or elevated roles without valid credentials
Data ExfiltrationAccess protected API resources and underlying data
Account TakeoverImpersonate any user by spoofing identity claims
Compliance ViolationUnauthorized access to regulated data (PII, PHI, PCI)

Affected Patterns

Applications are vulnerable if they:

  1. Use @fastify/aws-lambda 6.4.0 as their Lambda adapter
  2. Read authorization data from request.awsLambda.event (e.g., requestContext.authorizer.claims)
  3. Make access control decisions based on these values
// VULNERABLE: Reading claims from event without validation
app.get('/admin', async (req, reply) => {
  const claims = req.awsLambda.event.requestContext.authorizer.claims;
  if (!claims || claims['cognito:groups'] !== 'Admins') {
    return reply.status(403).send({ error: 'Forbidden' });
  }
  // ... admin logic
});

Remediation

Step 1: Update @fastify/aws-lambda

# Check current version
npm list @fastify/aws-lambda
 
# Update to patched version (check npm for latest)
npm update @fastify/aws-lambda
 
# Or install specific patched version
npm install @fastify/aws-lambda@latest

Step 2: Verify Your Authorization Logic

Audit all Fastify routes that read from request.awsLambda.event for authorization:

# Find vulnerable patterns in your codebase
grep -r "awsLambda.event" src/ --include="*.ts" --include="*.js"
grep -r "requestContext.authorizer" src/ --include="*.ts" --include="*.js"

Step 3: Implement Defense-in-Depth Authorization

Until patched, add explicit header validation or use Cognito JWT verification directly:

import { createVerifier } from 'fast-jwt';
 
// Verify the JWT token directly instead of trusting event claims
app.addHook('preHandler', async (request, reply) => {
  const token = request.headers.authorization?.replace('Bearer ', '');
  if (!token) {
    return reply.status(401).send({ error: 'Unauthorized' });
  }
  try {
    const verify = createVerifier({ key: process.env.JWT_PUBLIC_KEY });
    request.user = await verify(token);
  } catch {
    return reply.status(401).send({ error: 'Invalid token' });
  }
});

Step 4: Review API Gateway Configuration

Ensure your API Gateway configuration enforces authentication at the gateway level and does not allow requests to bypass authorizers:

  1. In API Gateway, verify Lambda Authorizer or Cognito Authorizer is applied to all routes
  2. Set Authorization to deny by default
  3. Enable API Gateway access logging to detect anomalous requests

Detection Indicators

IndicatorDescription
Requests with unusual requestContext headersPotential spoofing attempts
Access to admin/privileged endpoints without valid JWTsAuthorization bypass exploitation
CloudWatch Lambda logs showing unexpected claim valuesAnomalous event context data
API Gateway access logs with 200 responses to unauthorized pathsSuccessful exploitation

AWS-Specific Mitigations

// API Gateway Resource Policy — restrict to known sources
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Principal": "*",
      "Action": "execute-api:Invoke",
      "Resource": "arn:aws:execute-api:*:*:*",
      "Condition": {
        "NotIpAddress": {
          "aws:SourceIp": ["10.0.0.0/8"]
        }
      }
    }
  ]
}

Enable AWS WAF on your API Gateway to detect and block exploitation attempts while patches are applied.


References