Skip to content

Very fishy file-name / hash generation in incoming_form.js #247

@x00mario

Description

@x00mario

https://github.com/felixge/node-formidable/blob/master/lib/incoming_form.js#L516

The code used to generate the file-name looks quite fishy to me - to say the least:

var name = '';
for (var i = 0; i < 32; i++) {
    name += Math.floor(Math.random() * 16).toString(16);
}

Is there any reason why you don't use the NodeJS crypto API (specifically crypto.createHash(algorithm) or alike) to get an actual hash and not this "Hey let's concat the single-char content from the provably insecure Math.random() function of doom?"

Cheers,
.mario

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions