Skip to content

Commit 03f81ba

Browse files
committed
fix(docs): add security note to hashKey
1 parent 45997d8 commit 03f81ba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/entry-index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,20 @@ function bucketPath (cache, key) {
185185

186186
module.exports._hashKey = hashKey
187187
function hashKey (key) {
188-
// sha1 conflicts can be generated, but it doesn't matter in this case,
188+
// NOTE (SECURITY)
189+
//
190+
// `sha1` conflicts can be generated, but it doesn't matter in this case,
189191
// since we intend for there to be regular conflicts anyway. You can have
190192
// the entire cache in a single bucket and all that'll do is just make a big
191193
// file with a lot of contention, if you can even pull it off in the `key`
192194
// string. So whatever. `sha1` is faster and it doesn't trigger the warnings
193195
// `md5` tends to (yet?...).
196+
//
197+
// Not to mention, that in the case of pacote/npm, the amount of control
198+
// anyone would have over this key is so minimal that it's incredibly
199+
// unlikely that they could intentionally generate a large number of
200+
// conflicts just with a package key such that they'd do anything resembling
201+
// a hash flood DOS.
194202
return crypto
195203
.createHash('sha1')
196204
.update(key.toLowerCase()) // lump case-variant keys into same bucket.

0 commit comments

Comments
 (0)