GHSA-96QW-H329-V5RG

Vulnerability from github – Published: 2026-01-08 21:13 – Updated: 2026-01-08 21:13
VLAI?
Summary
Shakapacker has environment variable leak via EnvironmentPlugin that exposes secrets to client-side bundles
Details

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 credentials
  • AWS_SECRET_ACCESS_KEY - AWS credentials
  • RAILS_MASTER_KEY - Rails encrypted credentials key
  • STRIPE_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:

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: 1. Audit client-side code and dependencies for any process.env.X references to sensitive variables 2. Remove sensitive variables from the build environment 3. 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)

# Variables with this prefix are automatically exposed
export SHAKAPACKER_PUBLIC_API_URL="https://api.example.com"

Option 2: Use SHAKAPACKER_ENV_VARS

SHAKAPACKER_ENV_VARS=API_URL,FEATURE_FLAG bundle exec rails assets:precompile

Action Required

After upgrading, rotate any secrets that may have been exposed in previously compiled JavaScript bundles.

Resources

  • Fix PR: https://github.com/shakacode/shakapacker/pull/857
Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "shakapacker"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "9.5.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "RubyGems",
        "name": "shakapacker"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "9.5.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-200"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-01-08T21:13:37Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "### Summary\n\nSince 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`.\n\nThis is not a regression - the vulnerable code has existed since the original Webpacker implementation. No recent code change in Shakapacker triggered this issue.\n\n### Impact\n\nAny 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:\n\n- `DATABASE_URL` - Database credentials\n- `AWS_SECRET_ACCESS_KEY` - AWS credentials  \n- `RAILS_MASTER_KEY` - Rails encrypted credentials key\n- `STRIPE_SECRET_KEY`, `TWILIO_AUTH_TOKEN` - Third-party API keys\n- Any other secrets present in the build environment\n\n**Severity**: Critical - secrets are exposed in publicly accessible JavaScript files.\n\n### Root Cause\n\nThe original code used:\n```javascript\nnew webpack.EnvironmentPlugin(process.env)\n```\n\nThis makes every environment variable available for substitution. If any code references `process.env.SECRET_KEY`, that value is embedded in the bundle.\n\n### Patches\n\nUpgrade to version 9.5.0 or later, which uses an allowlist approach that only exposes `NODE_ENV`, `RAILS_ENV`, and `WEBPACK_SERVE` by default.\n\n### Workarounds\n\nIf developers cannot upgrade immediately:\n1. Audit client-side code and dependencies for any `process.env.X` references to sensitive variables\n2. Remove sensitive variables from the build environment\n3. Override the default plugins with a custom webpack/rspack config using an explicit allowlist\n\n### Migration\n\nAfter upgrading, if client-side code needs access to specific environment variables:\n\n**Option 1: Use the `SHAKAPACKER_PUBLIC_` prefix (recommended)**\n```bash\n# Variables with this prefix are automatically exposed\nexport SHAKAPACKER_PUBLIC_API_URL=\"https://api.example.com\"\n```\n\n**Option 2: Use `SHAKAPACKER_ENV_VARS`**\n```bash\nSHAKAPACKER_ENV_VARS=API_URL,FEATURE_FLAG bundle exec rails assets:precompile\n```\n\n### Action Required\n\nAfter upgrading, **rotate any secrets** that may have been exposed in previously compiled JavaScript bundles.\n\n### Resources\n\n- Fix PR: https://github.com/shakacode/shakapacker/pull/857",
  "id": "GHSA-96qw-h329-v5rg",
  "modified": "2026-01-08T21:13:37Z",
  "published": "2026-01-08T21:13:37Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/shakacode/shakapacker/security/advisories/GHSA-96qw-h329-v5rg"
    },
    {
      "type": "WEB",
      "url": "https://github.com/shakacode/shakapacker/pull/857"
    },
    {
      "type": "WEB",
      "url": "https://github.com/shakacode/shakapacker/commit/3e06781b18383c5c2857ed3a722f7b91bdc1bc0e"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/shakacode/shakapacker"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Shakapacker has environment variable leak via EnvironmentPlugin that exposes secrets to client-side bundles"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…