Skip to content

Insecure Buffer Allocation

Description

The application uses the deprecated `new Buffer` constructor, which can lead to memory allocation issues and potential security vulnerabilities. Older versions of Node.js may return uninitialized memory, potentially exposing sensitive information. To remediate this issue, use `Buffer.alloc` or `Buffer.from` instead to allocate a new `Buffer`.

Examples

Insecure Code

javascript
const buf = new Buffer([1, 2, 3, 4]);

Secure Code

javascript
const buf = Buffer.from([1, 2, 3, 4]);

Remediation

Replace `new Buffer` with `Buffer.alloc` or `Buffer.from`

Rule Details

FieldValue
IDCODE-0193
CategoryInsecureConfig
SeverityMEDIUM
CWECWE-770
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsbuffer, allocation, deprecation
OWASPA9:2017-Using Components with Known Vulnerabilities, A06:2021-Vulnerable and Outdated Components