Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Webpack to use more secure hashing routines #70

Open
PeterHaughie opened this issue Feb 16, 2023 · 0 comments
Open

Update Webpack to use more secure hashing routines #70

PeterHaughie opened this issue Feb 16, 2023 · 0 comments

Comments

@PeterHaughie
Copy link

When using node 18 the wpstart and wpbuild scripts bail with errors:

npm run wpstart

> barebones@0.1.0 wpstart
> wptheme-scripts wpstart

Browser Refresh Server ready.
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at runSyncOrAsync (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
    at iterateNormalLoaders (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
    at Array.<anonymous> (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/@devloco/react-scripts-wptheme/scripts/wpstart.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:417:16)
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:452:10
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/webpack/lib/NormalModule.js:323:13
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/peterhaughie/Projects/tm2022-2/wp-content/themes/tm-2023/react-src/node_modules/@devloco/react-scripts-wptheme/node_modules/babel-loader/lib/index.js:55:103
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

This is due to the webpack using the SHA512 hash which has been replaced in Webpack5 with xxhash64. The solutions are either to update the Webpack version to 5 and methodically go through all of the webpack build scripts to fix the breaking API changes or to try and enforce a different hashing algorithm in Webpack4 with something along the lines of:

module.exports = {
  //...
  experiments: {
    futureDefaults: true,
  },
};
module.exports = {
  //...
  output: {
    hashFunction: require('metrohash').MetroHash64,
  },
};

https://webpack.js.org/configuration/output/#outputhashfunction

https://webpack.js.org/configuration/experiments/#experimentsfuturedefaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant