Storybook manager bundle may expose environment variables during build
storybookjs storybook
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| storybook npm |
|
|
storybookjs storybook
| Product | Affected | Fixed in |
|---|---|---|
| storybook npm |
|
|
Storybook is a frontend workshop for building user interface components and pages in isolation. A vulnerability present starting in versions 7.0.0 and prior to versions 7.6.21, 8.6.15, 9.1.17, and 10.1.10 relates to Storybook’s handling of environment variables defined in a `.env` file, which could, in specific circumstances, lead to those variables being unexpectedly bundled into the artifacts created by the `storybook build` command. When a built Storybook is published to the web, the bundle’s source is viewable, thus potentially exposing those variables to anyone with access. For a project to potentially be vulnerable to this issue, it must build the Storybook (i.e. run `storybook build` directly or indirectly) in a directory that contains a `.env` file (including variants like `.env.local`) and publish the built Storybook to the web. Storybooks built without a `.env` file at build time are not affected, including common CI-based builds where secrets are provided via platform environment variables rather than `.env` files. Storybook runtime environments (i.e. `storybook dev`) are not affected. Deployed applications that share a repo with your Storybook are not affected. Users should upgrade their Storybook—on both their local machines and CI environment—to version .6.21, 8.6.15, 9.1.17, or 10.1.10 as soon as possible. Maintainers additionally recommend that users audit for any sensitive secrets provided via `.env` files and rotate those keys. Some projects may have been relying on the undocumented behavior at the heart of this issue and will need to change how they reference environment variables after this update. If a project can no longer read necessary environmental variable values, either prefix the variables with `STORYBOOK_` or use the `env` property in Storybook’s configuration to manually specify values. In either case, do not include sensitive secrets as they will be included in the built bundle.
From the CVE record · GitHub_M
Storybook builds can unexpectedly include variables from a `.env` file in published bundle artifacts. Anyone with access to the published Storybook can view the bundle source and potentially see those variables. This requires a `.env` file in the build directory when `storybook build` runs and the resulting Storybook to be published to the web; no authentication or user interaction is described.
Teams running the npm `storybook` package in versions >=7.0.0 <7.6.21, >=8.0.0 <8.6.15, >=9.0.0 <9.1.17, or >=10.0.0 <10.1.10 should check their builds.