Babel-Loader Fails on FIPS: Digest method not supported
- Dominant language
- JavaScript
- Stars
- 4.8k
- Forks
- 456
- Avg merge
- 9h 19m
- Merged PRs (30d)
- 2
Description
**I'm submitting a bug report**
**Webpack Version:**
5.40.0
**Babel Core Version**:
7.14.6
**Babel Loader Version**:
8.2.2
**Please tell us about your environment:**
RHEL
**Current behavior:**
```
Error: Digest method not supported
at new Hash (internal/crypto/hash.js:46:19)
at Object.createHash (crypto.js:115:10)
at filename (/omitted_project_path/node_modules/babel-loader/lib/cache.js:94:23)
at /omitted_project_path/node_modules/babel-loader/lib/cache.js:120:39
at Generator.next ()
at asyncGeneratorStep (/omitted_project_path/node_modules/babel-loader/lib/cache.js:3:103)
at _next (/omitted_project_path/node_modules/babel-loader/lib/cache.js:5:194)
at /omitted_project_path/node_modules/babel-loader/lib/cache.js:5:364
at new Promise ()
at /omitted_project_path/node_modules/babel-loader/lib/cache.js:5:97
```
**Expected/desired behavior:**
* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.**
I cannot easily link a StackBlitz or GitHub repo as [fips has to be enabled on the Node distribution](https://nodejs.org/dist/latest-v14.x/docs/api/cli.html#cli_enable_fips). The error occurs when doing a build of a Node application on a FIPS-enabled system.
Webpack Config (used to splice out the md4 hashes in Webpack)
```
const webpack = require('webpack');
module.exports = {
output: {
hashFunction: 'sha256'
},
optimization: {
concatenateModules: false
},
plugins: [
new webpack.ids.HashedModuleIdsPlugin({
hashFunction: 'sha256'
})
]
};
```
* **What is the expected behavior?**
The hash changes from #638 and #639 use md4 which is not a supported hashing algorithm for FIPS-compliant systems. Although md4 is a faster hashing algorithm, a configuration option should be provided for those building in a FIPS-compliant environment to specify an alternative hash, such as sha-256.
* **What is the motivation / use case for changing the behavior?**
Allowing builds to use a compliant hashing algorithm.
Contributor guide
Assessment
This issue has not been assessed yet.