CVE-2026-27212: Verified Repro With Script Download
CVE-2026-27212: Swiper Prototype Pollution
CVE-2026-27212 is verified against swiper · npm. Affected versions: >= 6.5.1, < 12.1.2. Fixed in 12.1.2. Vulnerability class: Prototype Pollution. This high reproduction includes runnable sandbox proof, artifacts, and a plain-text agent view under REPRO-2026-00107.
What Is CVE-2026-27212?
CVE-2026-27212 is a critical prototype pollution vulnerability (CWE-1321) in the Swiper npm package that lets an attacker pollute Object.prototype despite a previous mitigation attempt. Pruva reproduced it (reproduction REPRO-2026-00107).
CVE-2026-27212 Severity & CVSS Score
CVE-2026-27212 is rated high severity, with a CVSS base score of 7.8 out of 10.
High — serious impact or readily exploitable. Prioritize remediation.
Affected swiper Versions
swiper · npm versions >= 6.5.1, < 12.1.2 are affected.
How to Reproduce CVE-2026-27212
pruva-verify REPRO-2026-00107 curl -O https://pruva.dev/api/v1/reproductions/REPRO-2026-00107/artifacts/reproduction_steps.sh && chmod +x reproduction_steps.sh && ./reproduction_steps.sh Proof of Reproduction for CVE-2026-27212
Reproduced by Pruva's autonomous agents — 87 tool calls over 10 min. Full root-cause analysis and the complete transcript are below.
How the agent worked
Root Cause and Exploit Chain for CVE-2026-27212
Summary
A prototype pollution vulnerability exists in the swiper npm package (versions >=6.5.1, < 12.1.2) that can be bypassed by modifying Array.prototype.indexOf. The vulnerability resides in shared/utils.mjs at line 94 where indexOf() is used to check whether user-provided input contains forbidden strings like __proto__. An attacker can override Array.prototype.indexOf to always return -1, causing the filter to incorrectly allow __proto__ keys through, resulting in successful prototype pollution of Object.prototype.
Impact
- Package: swiper (npm package)
- Affected Versions: >=6.5.1, < 12.1.2
- Fixed In: 12.1.2
- Severity: CRITICAL
Risk and Consequences
This is a prototype pollution vulnerability which can have severe security implications:
- Authentication Bypass - Polluted prototypes can modify authentication logic
- Denial of Service - Modified prototypes can cause application crashes or unexpected behavior
- Property Injection - Arbitrary properties can be injected into all objects
- Logic Manipulation - Application business logic can be altered through prototype manipulation
Any application that processes attacker-controlled input using this package may be affected, particularly when using extendDefaults() or similar methods that merge user input with internal configuration objects.
Root Cause
Technical Explanation
The vulnerability exists in the swiper package's utility functions, specifically in shared/utils.mjs around line 94. The code attempts to prevent prototype pollution by checking if input keys contain forbidden strings:
// Vulnerable pattern (conceptual)
if (forbiddenKeys.indexOf(key) !== -1) {
// Block the key
}
The problem is that indexOf() is a method called on the forbiddenKeys array. Since indexOf is defined on Array.prototype, it can be globally overridden:
Array.prototype.indexOf = () => -1;
When this override is in place:
forbiddenKeys.indexOf('__proto__')returns-1(instead of the actual index)- The check
indexOf(...) !== -1evaluates tofalse - The
__proto__key is allowed through the filter Object.prototypegets polluted with attacker-controlled properties
Bypass Mechanism
The exploit chain works as follows:
- Override Phase:
Array.prototype.indexOf = () => -1; - Input Phase: Attacker provides
{"__proto__":{"polluted":"yes"}} - Filter Bypass: The
indexOfcheck returns-1, so__proto__passes validation - Merge Phase: The library merges the malicious payload into the target object
- Pollution:
Object.prototype.pollutedis set to"yes" - Impact: All objects now have the
pollutedproperty
Fix Information
The issue was fixed in version 12.1.2. The fix likely replaces the indexOf()-based check with a more robust approach that doesn't rely on prototype methods that can be overridden, such as:
- Using
Object.prototype.hasOwnProperty.call()checks - Using a
Setwithhas()method - Using
includes()from a frozen array - Implementing a custom comparison function that doesn't rely on prototype methods
Reproduction Steps
Script Reference
The reproduction script is located at: repro/reproduction_steps.sh
What the Script Does
- Creates a temporary directory and initializes npm
- Installs the vulnerable version of swiper (12.1.1)
- Creates a test script that:
- Imports the swiper package
- Overrides
Array.prototype.indexOfto always return-1 - Checks
{}.pollutedbefore exploitation (should beundefined) - Calls
swiper.default.extendDefaults()with a malicious payload containing{"__proto__":{"polluted":"yes"}} - Checks
{}.pollutedafter exploitation - Restores the original
Array.prototype.indexOf
- Runs the test and reports results
- Cleans up temporary files
Expected Evidence of Reproduction
When the vulnerability is present, the script outputs:
Before exploit: {}.polluted = undefined
After exploit: {}.polluted = yes
[VULNERABILITY CONFIRMED] Prototype pollution successful!
Object.prototype was polluted with 'polluted' property.
The key indicator is that {}.polluted changes from undefined to "yes", proving that Object.prototype was successfully polluted.
Evidence
Log Files
- Installation log:
logs/npm_install.log - Test output:
logs/test_output.log
Key Excerpts
From logs/test_output.log:
Testing prototype pollution in swiper...
Before exploit: {}.polluted = undefined
After exploit: {}.polluted = yes
[VULNERABILITY CONFIRMED] Prototype pollution successful!
Object.prototype was polluted with 'polluted' property.
Environment Details
- Node.js Version: v22.22.0
- npm Version: 10.9.4
- Tested Package: swiper@12.1.1
- Operating System: Linux (containerized environment)
Recommendations / Next Steps
Suggested Fix Approach
Replace indexOf()-based checks with alternatives that cannot be easily bypassed:
// Instead of: if (forbiddenKeys.indexOf(key) !== -1) // Use: const forbiddenSet = new Set(['__proto__', 'constructor', 'prototype']); if (forbiddenSet.has(key))Use Object.freeze() on critical arrays to prevent prototype manipulation
Validate keys explicitly without relying on prototype methods:
if (key === '__proto__' || key === 'constructor' || key === 'prototype')Use Object.prototype.hasOwnProperty.call() for property checks
Upgrade Guidance
Immediate Action Required: Upgrade to swiper version 12.1.2 or later.
npm install swiper@latest
Testing Recommendations
- Add regression tests that specifically test prototype pollution scenarios
- Test with various prototype overrides (Array.prototype.indexOf, Array.prototype.includes, etc.)
- Implement input validation tests for all user-controlled data entry points
- Consider using libraries like
safe-object-assignorsafe-extendfor object merging operations
Additional Security Measures
- Implement Content Security Policy (CSP) headers where applicable
- Use input sanitization libraries
- Regularly audit dependencies for prototype pollution vulnerabilities
- Consider using Object.create(null) for objects that shouldn't inherit from Object.prototype
Additional Notes
Idempotency Confirmation
The reproduction script has been tested twice consecutively and produces consistent results:
- First run: Exit code 0, vulnerability confirmed
- Second run: Exit code 0, vulnerability confirmed
The script is fully idempotent - it creates a fresh temporary directory for each run, installs dependencies cleanly, runs the test, and removes all temporary files.
Edge Cases and Limitations
Runtime Dependency: The exploit requires JavaScript runtime access to modify
Array.prototype. This is typically only possible in server-side JavaScript (Node.js, Bun) or if an attacker can execute arbitrary code in a browser context.Method Scope: The vulnerability specifically affects code paths that use
indexOf()for forbidden key validation. Other protection mechanisms may still block some attack vectors.Cleanup Requirement: The exploit modifies global prototypes. Proper cleanup (restoring original methods) is essential to prevent side effects in the same execution context.
Bun Runtime: According to the advisory, this exploit also works on Bun runtime. The same fix should be applicable.
Previous Fix Bypass: This vulnerability is a bypass of a previous fix. Future fixes should consider all possible prototype pollution vectors, not just the specific one addressed previously.
CVE-2026-27212 Reproduction Transcript
The agent's step-by-step process — every tool call, every handoff, the moment the exploit fired.
Full session Replay every step — scrub the timeline or play it back.
#!/bin/bash
set -euo pipefail
# Portable root detection - works anywhere
ROOT="${PRUVA_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
LOGS="$ROOT/logs"
mkdir -p "$LOGS"
cd "$ROOT"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "========================================"
echo "GHSA-hmx5-qpq5-p643: Prototype pollution in swiper"
echo "========================================"
chmod +x repro/reproduction_steps.sh && ./repro/reproduction_steps.sh======================================== GHSA-hmx5-qpq5-p643: Prototype pollution in swiper ======================================== [1;33mInstalling vulnerable version of swiper (12.1.1)...[0m
Artifacts and Evidence for CVE-2026-27212
Scripts, logs, diffs, and output captured during the reproduction.
No artifacts available
How to Fix CVE-2026-27212
Upgrade swiper · npm to 12.1.2 or later.
FAQ: CVE-2026-27212
How does the CVE-2026-27212 prototype pollution bypass work?
Array.prototype.indexOf (e.g. to always return -1), which causes Swiper's forbidden-key filter to incorrectly conclude that __proto__ is not present in the input, letting a crafted payload using Array.prototype pass through and pollute Object.prototype. The exploit works across Windows and Linux, on both Node and Bun runtimes.Which Swiper versions are affected by CVE-2026-27212, and where is it fixed?
How severe is CVE-2026-27212?
How can I reproduce CVE-2026-27212?
References for CVE-2026-27212
Authoritative sources for CVE-2026-27212 — official vulnerability databases and the upstream advisory. Pruva's reproduction verifies the issue firsthand; these are the primary records to corroborate it.