Lucene search

K
hackeroneAshi009H1:965914
HistoryAug 24, 2020 - 3:18 p.m.

Node.js: `fs.realpath.native` on darwin may cause buffer overflow

2020-08-2415:18:48
ashi009
hackerone.com
131

7.8 High

CVSS3

Attack Vector

LOCAL

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

4.6 Medium

CVSS2

Access Vector

LOCAL

Access Complexity

LOW

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:L/AC:L/Au:N/C:P/I:P/A:P

0.001 Low

EPSS

Percentile

16.4%

> NOTE! Thanks for submitting a report! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!

Summary:

The libuv’s implementation of realpath is flawed on darwin and may cause buffer overflow.

Description:

libuv’s realpath implementation determines the buffer size with pathconf and fallback to _POSIX_PATH_MAX (256) if that fails for any reason (eg. ENOENT). However realpath requires a buffer of at least PATH_MAX (1024) bytes to be used, hence causes the buffer overflow if the resolved path is longer than 256 bytes.

Steps To Reproduce:

  1. LONG_PATH='/tmp/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/path/254B'
  2. SHORT_LINK='/tmp/short'
  3. mkdir -p "${LONG_PATH}"
  4. ln -s "${LONG_PATH}" "${SHORT_LINK}"
  5. node -e "fs.realpathSync.native('${SHORT_LINK}/file-not-exist')"

Impact:

Cause node process to crash.

Supporting Material/References:

Impact

Given that nodejs on darwin are mostly desktop applications and used as developer tools, exploit this is very unlikely to cause more damage than an application crash.

7.8 High

CVSS3

Attack Vector

LOCAL

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

4.6 Medium

CVSS2

Access Vector

LOCAL

Access Complexity

LOW

Authentication

NONE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:L/AC:L/Au:N/C:P/I:P/A:P

0.001 Low

EPSS

Percentile

16.4%