PT-2026-3410 · Rubygems · Shakapacker
Published
2026-01-08
·
Updated
2026-01-08
CVSS v3.1
7.5
High
| Vector | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
Summary
Since 2017, the default webpack plugins have passed the entire
process.env to EnvironmentPlugin. This pattern exposed ALL build environment variables to client-side JavaScript bundles whenever application code (or any dependency) referenced process.env.VARIABLE NAME.This is not a regression - the vulnerable code has existed since the original Webpacker implementation. No recent code change in Shakapacker triggered this issue.
Impact
Any environment variable in the build environment that is referenced in client-side code (including third-party dependencies) is embedded directly into the JavaScript bundle. This includes:
DATABASE URL- Database credentialsAWS SECRET ACCESS KEY- AWS credentialsRAILS MASTER KEY- Rails encrypted credentials keySTRIPE SECRET KEY,TWILIO AUTH TOKEN- Third-party API keys- Any other secrets present in the build environment
Severity: Critical - secrets are exposed in publicly accessible JavaScript files.
Root Cause
The original code used:
javascript
new webpack.EnvironmentPlugin(process.env)This makes every environment variable available for substitution. If any code references
process.env.SECRET KEY, that value is embedded in the bundle.Patches
Upgrade to version 9.5.0 or later, which uses an allowlist approach that only exposes
NODE ENV, RAILS ENV, and WEBPACK SERVE by default.Workarounds
If developers cannot upgrade immediately:
- Audit client-side code and dependencies for any
process.env.Xreferences to sensitive variables - Remove sensitive variables from the build environment
- Override the default plugins with a custom webpack/rspack config using an explicit allowlist
Migration
After upgrading, if client-side code needs access to specific environment variables:
Option 1: Use the
SHAKAPACKER PUBLIC prefix (recommended)bash
# Variables with this prefix are automatically exposed
export SHAKAPACKER PUBLIC API URL="https://api.example.com"Option 2: Use
SHAKAPACKER ENV VARSbash
SHAKAPACKER ENV VARS=API URL,FEATURE FLAG bundle exec rails assets:precompileAction Required
After upgrading, rotate any secrets that may have been exposed in previously compiled JavaScript bundles.
Resources
Fix
Information Disclosure
Found an issue in the description? Have something to add? Feel free to write us 👾
Weakness Enumeration
Related Identifiers
Affected Products
Shakapacker