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.
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 keysSeverity: Critical - secrets are exposed in publicly accessible JavaScript files.
The original code used:
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.
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.
If developers cannot upgrade immediately:
process.env.X references to sensitive variablesAfter upgrading, if client-side code needs access to specific environment variables:
Option 1: Use the SHAKAPACKER_PUBLIC_ prefix (recommended)
# Variables with this prefix are automatically exposed
export...
9.5.0Exploitability
AV:NAC:LPR:NUI:NScope
S:UImpact
C:HI:NA:N7.5/CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N