CVE-2021-4430: Insufficient Information (NVD-CWE-noinfo)
value: A vulnerability classified as problematic has been found in Ortus Solutions ColdBox Elixir 3.1.6. This affects an unknown part of the file src/defaultConfig.js of the component ENV Variable Handler. The manipulation leads to information disclosure. Upgrading to version 3.1.7 is able to address this issue. The identifier of the patch is a3aa62daea2e44c76d08d1eac63768cd928cd69e. It is recommended to upgrade the affected component. The identifier VDB-244485 was assigned to this vulnerability.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
CVSS v3 base score: 7.5
Published: 2023-11-06T08:15Z
Repository: https://github.com/Ortus-Solutions/coldbox-elixir
Language: JavaScript
Files changed: src/config/index.js, src/config/ingredients/env.js, src/defaultConfig.js
Commit date: 2021-01-12 13:14:11 -0700
Commit message: Fix security vulnerability that echoed out all ENV vars.

In a mistaken attempt to make defining ENV vars easier, Elixir
would define every ENV var using Webpack's `DefinePlugin`.
This was a mistake.  The entire ENV of the server generating the
bundle would be serialized into an object and delivered in the
JavaScript bundle.  This code has been removed.  You need to allow
ENV variables using the webpack's `DefinePlugin` or `EnvironmentPlugin`.
To make this easier, Elixir now has a `mix.env` method that forwards
all arguments on to `EnvironmentPlugin`.

Diff: diff --git a/src/config/index.js b/src/config/index.js
index a5eeef5..82ee61d 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -1,13 +1,11 @@
 const ElixirConfig = require("./config");
 
 ElixirConfig.addIngredient("js", require("./ingredients/js"));
 ElixirConfig.addIngredient("vue", require("./ingredients/vue"));
-
 ElixirConfig.addIngredient("css", require("./ingredients/css"));
 ElixirConfig.addIngredient("sass", require("./ingredients/sass"));
-
 ElixirConfig.addIngredient("copy", require("./ingredients/copy"));
-
 ElixirConfig.addIngredient("browserSync", require("./ingredients/browserSync"));
+ElixirConfig.addIngredient("env", require("./ingredients/env"));
 
 module.exports = ElixirConfig;
diff --git a/src/config/ingredients/env.js b/src/config/ingredients/env.js
new file mode 100644
index 0000000..8fb860a
--- /dev/null
+++ b/src/config/ingredients/env.js
@@ -0,0 +1,9 @@
+const { EnvironmentPlugin } = require("webpack");
+
+module.exports = function(keys) {
+    return this.mergeConfig({
+        plugins: [
+            new EnvironmentPlugin(keys)
+        ]
+    });
+};
diff --git a/src/defaultConfig.js b/src/defaultConfig.js
index e952920..e6813fb 100755
--- a/src/defaultConfig.js
+++ b/src/defaultConfig.js
@@ -5,11 +5,10 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 const { CleanWebpackPlugin } = require("clean-webpack-plugin");
 const ManifestPlugin = require("webpack-manifest-plugin");
 const TerserPlugin = require("terser-webpack-plugin");
 const styleLoaders = require("./utils/styleLoaders");
 const webpackMerge = require("webpack-merge");
-const webpack = require("webpack");
 const path = require("path");
 const fs = require("fs");
 
 const dotEnvFile = path.resolve(process.cwd(), ".env");
 if (fs.existsSync(dotEnvFile)) {
@@ -113,17 +112,10 @@ module.exports = () => ({
         new MiniCssExtractPlugin({
             filename: global.elixir.versioning
                 ? "[name].[contenthash].css"
                 : "[name].css"
         }),
-        new webpack.DefinePlugin({
-            // stringify each value so webpack doesn't insert variables instead of strings
-            "process.env": Object.keys(process.env).reduce((obj, key) => {
-                obj[key] = JSON.stringify(process.env[key]);
-                return obj;
-            }, {})
-        })
     ],
     stats: {
         children: false
     },
     optimization: {

Vulnerable code: 


const webpack = require("webpack");
        new webpack.DefinePlugin({
            // stringify each value so webpack doesn't insert variables instead of strings
            "process.env": Object.keys(process.env).reduce((obj, key) => {
                obj[key] = JSON.stringify(process.env[key]);
                return obj;
            }, {})
        })
Fixed code: ElixirConfig.addIngredient("env", require("./ingredients/env"));
const { EnvironmentPlugin } = require("webpack");

module.exports = function(keys) {
    return this.mergeConfig({
        plugins: [
            new EnvironmentPlugin(keys)
        ]
    });
};