Skip to content

Commit 6ba3f22

Browse files
authored
Merge pull request #965 from stevebio/task/fipsMD5Fix2
MLE-24397 - fix reported issue on Linux FIPS around exception caused by default load of FIPS-forbidden MD5 digest algorithm. Incorporate the source from the abandoned www-authenticate project and fix in place.
2 parents 739c156 + 9d57aef commit 6ba3f22

7 files changed

Lines changed: 45 additions & 27 deletions

File tree

lib/requester.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
33
*/
44
'use strict';
5-
var createAuthInitializer = require('./www-authenticate/www-authenticate');
5+
var createAuthInitializer = require('./www-authenticate-patched/www-authenticate');
66
var Kerberos = require('./optional.js')
77
.libraryProperty('kerberos', 'Kerberos');
88
var Multipart = require('multipart-stream');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
12+
var crypto= require('crypto');
13+
14+
function md5(s) {
15+
return crypto.createHash('md5').update(s).digest('hex');
16+
}
17+
18+
module.exports= md5;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
112
var ParseAuth= /(\w+)\s+(.*)/ // -> scheme, params
213
, Separators= /([",=])/
314
;

lib/www-authenticate/user-credentials.js renamed to lib/www-authenticate-patched/user-credentials.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
112
var md5= require('./md5');
213

314
/*

lib/www-authenticate/www-authenticate.js renamed to lib/www-authenticate-patched/www-authenticate.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/*
1010
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
1111
*/
12-
1312
'use strict';
1413

1514
var crypto= require('crypto')
@@ -42,20 +41,6 @@ var www_authenticator = function(username,password,options)
4241
cnonce= options.cnonce;
4342
}
4443
if (cnonce === void 0) cnonce= crypto.pseudoRandomBytes(8).toString('hex');
45-
46-
/**
47-
* @typedef {Object} Authenticator
48-
* @property {any} [err]
49-
* @property {function(string=, string=): string} [authorize]
50-
* @property {any} [parms]
51-
* @property {string} [cnonce]
52-
*/
53-
54-
/**
55-
* Parses the WWW-Authenticate header.
56-
* @param {string} www_authenticate
57-
* @returns {Authenticator}
58-
*/
5944
var parse_header= function(www_authenticate)
6045
{
6146
function Authenticator()

lib/www-authenticate/md5.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

test-basic/digestauth-fips-nomd5load.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('FIPS test - ensure MD5 hash digester object is not loaded by default o
2222
* To simulate the require/load, we first delete the module from Node's require cache
2323
* and then require it again, which forces a reload of the module.
2424
*/
25-
delete require.cache[require.resolve('../lib/www-authenticate/www-authenticate')];
26-
delete require.cache[require.resolve('../lib/www-authenticate/md5')];
25+
delete require.cache[require.resolve('../lib/www-authenticate-patched/www-authenticate')];
26+
delete require.cache[require.resolve('../lib/www-authenticate-patched/md5')];
2727
const crypto = require('crypto');
2828
const originalCreateHash = crypto.createHash;
2929

@@ -40,8 +40,8 @@ describe('FIPS test - ensure MD5 hash digester object is not loaded by default o
4040
(() => crypto.createHash('md5')).should.throw('FIPS emulation: MD5 digest algorithm is not allowed on this system!');
4141

4242
// Require the module - should not call to get MD5 digester so should not throw
43-
(() => require('../lib/www-authenticate/md5')).should.not.throw();
44-
(() => require('../lib/www-authenticate/www-authenticate')).should.not.throw();
43+
(() => require('../lib/www-authenticate-patched/md5')).should.not.throw();
44+
(() => require('../lib/www-authenticate-patched/www-authenticate')).should.not.throw();
4545

4646
} finally {
4747
// Restore the original createHash function to avoid side effects

0 commit comments

Comments
 (0)