GHSA-J965-2QGJ-VJMQ

Region of Doom: Poisoning AWS SDK v2 Configuration

Amit Schendel
Amit Schendel
Senior Security Researcher

Jan 9, 2026·6 min read

Executive Summary (TL;DR)

The AWS SDK for Node.js v2 (now EOL) blindly trusts the 'region' parameter when constructing service URLs. By injecting special characters or domain names into this parameter via environment variables or compromised config, an attacker can manipulate the destination of API calls, potentially leaking credentials and payloads. v2 is not getting a patch; migration to v3 is mandatory.

A defense-in-depth bypass in the End-of-Life AWS SDK for JavaScript v2 allows attackers with control over environment configuration to inject malicious region strings, potentially routing AWS traffic to attacker-controlled endpoints.

The Hook: Trusting the Environment

We treat the AWS_REGION environment variable like a constant of the universe. It’s supposed to be us-east-1 or eu-west-1. It’s the boring setting in your .env file that you copy-paste and forget. But in the world of software security, "boring" is where the demons hide.

For years, the AWS SDK for JavaScript v2 (the one that powers half the legacy Node.js backends on the planet) has been taking this value and plugging it directly into URL constructors without a second thought. It assumes you, the developer, are a rational actor who wouldn't try to set the region to something psychotic.

But what if you aren't the one setting it? What if an attacker finds a way to inject environment variables (hello, container injection) or you have a multi-tenant app that lets users specify their "preferred region"? Suddenly, that boring configuration string becomes a redirection vector, turning your authenticated AWS API calls into a care package sent directly to an attacker's server.

The Flaw: String Concatenation is Not Engineering

At its core, this is a classic input validation failure, specifically a lack of RFC 1123 compliance checks. The SDK's logic for resolving service endpoints is effectively a glorified string concatenation game. It takes the service identifier (e.g., s3), the region (e.g., us-east-1), and the suffix (e.g., amazonaws.com) and smashes them together.

The logic roughly looks like this (simplified for dramatic effect):

const endpoint = `https://${service}.${region}.amazonaws.com`;

The vulnerability arises because the v2 SDK does not check if region contains valid DNS host characters (alphanumeric and hyphens). It accepts anything. Special characters, slashes, colons—it’s all fair game. If an attacker can inject a value that breaks the URL semantics, they can alter the request routing.

While AWS endpoints usually enforce a strict TLD structure, the lack of sanitization here means the SDK is abdicating its responsibility to ensure it is talking to a valid host. It is a "Defense in Depth" failure because it relies entirely on the environment being pristine.

The Code: Before and After (The Migration)

Since AWS SDK v2 is End-of-Support (EOS), there is no patch for aws-sdk. The vulnerable code remains in the wild forever. However, we can look at the fix implemented in the v3 ecosystem (@smithy/config-resolver) to understand what should have happened.

In the unpatched v2 logic, the region is consumed raw. In the patched v3 component (specifically @smithy/config-resolver version 4.4.0), a validation step was added.

The Vulnerable Logic (v2 Conceptual):

function resolveEndpoint(region) {
  // YOLO: No validation
  return `https://service.${region}.amazonaws.com`;
}

The Fixed Logic (v3 equivalent):

// From @smithy/config-resolver fix
const DNS_LABEL_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
 
if (!DNS_LABEL_PATTERN.test(region)) {
   throw new Error("Invalid region: " + region);
}

The fix is incredibly simple: ensure the region looks like a region. If it contains a slash, a colon, or a dot (where it shouldn't be), reject it. The fact that v2 lacks this check essentially means the SDK operates with "implicit trust" in the configuration layer.

The Exploit: Hijacking the Signal

How do we weaponize this? We need an entry point where we can control the region parameter. This often happens in two scenarios:

  1. Configuration Injection: An attacker exploits an unrelated vulnerability (like a prototype pollution or a compromised CI/CD variable) to set AWS_REGION.
  2. SaaS Logic: An application allows users to "Bring Your Own Bucket" and specifies the region for that bucket via an API parameter.

The Attack Chain:

Let's say the application uses the region to fetch a file from S3. The attacker supplies a malicious region string designed to alter the host resolution or port.

By manipulating the region, the attacker might not be able to completely strip the .amazonaws.com suffix (depending on the specific service client's logic), but they can often confuse the URL parser or internal routing logic. Even worse, if the SDK supports custom partition logic (e.g., for China or GovCloud), injecting a region that maps to a different partition configuration could route traffic to entirely different TLDs.

The Impact: Leaking the Keys to the Kingdom

Why is this scary? It's not just about Denial of Service (sending traffic into a black hole). It's about Information Disclosure.

When the SDK makes a request to https://s3.us-east-1.evil.com..., it doesn't just send a GET request. It signs that request. It attaches headers like:

  • Authorization: Contains the SigV4 signature.
  • X-Amz-Security-Token: The temporary session token (if using IAM Roles).
  • X-Amz-Date: The timestamp.

If an attacker can route this request to a server they control (even partially, or via a Man-in-the-Middle facilitated by the DNS confusion), they capture these headers. With the session token and the signature, they gain insight into the credentials being used. While they can't reverse the signature to get the Secret Key, they can replay the captured request or use the session token (if captured) to authenticate as that role until it expires.

This turns a simple "configuration error" into a potential credential exfiltration pipeline.

The Mitigation: Abandon Ship

This is the part where I usually tell you to update your package.json. Not today. AWS SDK v2 is dead. It reached End-of-Support in September 2025. There is no patch coming for this. If you are still using v2, you are driving a car with no brakes on a highway built in the 90s.

Strategy 1: Migration (The Only Real Fix)

You must migrate to AWS SDK for JavaScript v3. The v3 architecture is modular and, more importantly, actively maintained. The vulnerability was patched in v3 components (@smithy/config-resolver v4.4.0) in November 2025.

Strategy 2: The Band-Aid (If you enjoy living dangerously)

If you absolutely cannot migrate right now (we know, legacy codebases are sticky), you must implement your own validation wrapper before instantiating the SDK.

const AWS = require('aws-sdk');
const region = process.env.AWS_REGION;
 
// The "I don't want to get hacked" regex
const validRegionRegex = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
 
if (!region || !validRegionRegex.test(region)) {
    console.error("POTENTIAL EXPLOIT ATTEMPT: Invalid Region Detected");
    process.exit(1);
}
 
AWS.config.update({ region: region });

Treat the region variable like user input: guilty until proven innocent.

Technical Appendix

CVSS Score
3.7/ 10
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N
EPSS Probability
0.04%
Top 100% most exploited

Affected Systems

AWS SDK for JavaScript v2 (All Versions)Node.js applications using legacy AWS SDKServerless functions (Lambda) using default v2 SDK layers (if not updated)

Affected Versions Detail

Product
Affected Versions
Fixed Version
aws-sdk (v2)
AWS
All VersionsNone (EOL)
@smithy/config-resolver (v3)
AWS
< 4.4.04.4.0
AttributeDetail
Attack VectorLocal / Environment Configuration
CVSS3.7 (Low)
Affected ComponentEndpoint Resolver / URL Constructor
ImpactTraffic Redirection / Credential Leakage
StatusWill Not Fix (v2 is EOS)
Fix AvailableYes (Upgrade to SDK v3)
CWE-20
Improper Input Validation

The product constructs a URL or URI using input from an upstream component, but it does not validate that the input matches the expected format, allowing for the injection of malicious characters.

Vulnerability Timeline

AWS SDK v2 reaches End-of-Support
2025-09-08
Fix released for AWS SDK v3 (@smithy/config-resolver v4.4.0)
2025-11-15
GHSA-J965-2QGJ-VJMQ Published
2026-01-08

Subscribe to updates

Get the latest CVE analysis reports delivered to your inbox.