CVE-2024-24828: Pkg Pkg Local Privilege Escalation Vulnerability

MODERATE
Advisory Identifier: GHSA-22r3-9w55-cj54
CVSS 6.6
CWE-276
Published
Advisory Summary

CVE-2024-24828 is a MODERATE (CVSS 6.6) pkg local privilege escalation vulnerability (CWE-276: Incorrect Default Permissions) affecting Pkg libraries in the npm ecosystem. The issue involves pkg local privilege escalation. Remediation is available in the latest vendor maintenance releases.

CVE-2024-24828 at a Glance

CVE Identifier CVE-2024-24828
GHSA Identifier GHSA-22r3-9w55-cj54
Severity MODERATE
CVSS v3.1 Base Score 6.6
CWE Classification CWE-276: Incorrect Default Permissions
Affected Product Pkg
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2024-24828

To remediate this vulnerability, upgrade all affected Pkg dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pkg fixed: Latest secure release
npm install pkg@Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls pkg

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-24828, inspect your project dependencies using npm:

npm ls pkg

Analyze the terminal output to locate any version of Pkg in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The npm ls pkg command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-276: Incorrect Default Permissions, where during installation, installed file permissions are set to allow anyone to modify those files. In Pkg, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Any native code packages built by `pkg` are written to a hardcoded directory. On unix systems, this is `/tmp/pkg/*` which is a shared directory for all users on the same local system. There is no uniqueness to the package names within this directory, they are predictable. An attacker who has access to the same local system has the ability to replace the genuine executables in the shared directory with malicious executables of the same name. A user may then run the malicious executable without realising it has been modified. ### Patches This package is deprecated. Therefore, there will not be a patch provided for this vulnerability. ### Recommended Action: To check if your executable build by pkg depends on native code and is vulnerable, run the executable and check if `/tmp/pkg/` was created. Users should transition to actively maintained alternatives. We would recommend investigating Node.js 21’s support for [single executable applications](https://nodejs.org/api/single-executable-applications.html). ### Workarounds Given the decision to deprecate the pkg package, there are no official workarounds or remediations provided by our team. Users should prioritize migrating to other packages that offer similar functionality with enhanced security.

CVE-2024-24828 Affected Pkg Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
pkg
npm
≤ 5.8.1

References

Frequently Asked Questions

What is CVE-2024-24828?
CVE-2024-24828 is a security vulnerability in Pkg involving Pkg Local Privilege Escalation under CWE-276: Incorrect Default Permissions.
Which Pkg versions are affected?
Affected versions include releases prior to current release patches across affected packages: pkg.
What version fixes CVE-2024-24828?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is pkg affected?
Yes, pkg is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2024-24828?
CVE-2024-24828 has a CVSS v3.1 base score of 6.6 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2024-24828?
CVE-2024-24828 is classified under CWE-276: Incorrect Default Permissions (During installation, installed file permissions are set to allow anyone to modify those files.).
How can I check npm dependencies for CVE-2024-24828?
Run the dependency tree command: 'npm ls pkg'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-22r3-9w55-cj54",
  "modified" : "2024-02-12T15:03:11Z",
  "published" : "2024-02-09T15:20:27Z",
  "aliases" : [ "CVE-2024-24828" ],
  "summary" : "Pkg Local Privilege Escalation",
  "details" : "### Impact\nAny native code packages built by `pkg` are written to a hardcoded directory. On unix systems, this is `/tmp/pkg/*` which is a shared directory for all users on the same local system. There is no uniqueness to the package names within this directory, they are predictable.\n\nAn attacker who has access to the same local system has the ability to replace the genuine executables in the shared directory with malicious executables of the same name. A user may then run the malicious executable without realising it has been modified.\n\n### Patches\nThis package is deprecated. Therefore, there will not be a patch provided for this vulnerability.\n\n### Recommended Action:\nTo check if your executable build by pkg depends on native code and is vulnerable, run the executable and check if `/tmp/pkg/` was created.\n\nUsers should transition to actively maintained alternatives. We would recommend investigating Node.js 21’s support for [single executable applications](https://nodejs.org/api/single-executable-applications.html).\n\n### Workarounds\nGiven the decision to deprecate the pkg package, there are no official workarounds or remediations provided by our team. Users should prioritize migrating to other packages that offer similar functionality with enhanced security.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "pkg"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "5.8.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/vercel/pkg/security/advisories/GHSA-22r3-9w55-cj54"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-24828"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vercel/pkg"
  }, {
    "type" : "WEB",
    "url" : "https://nodejs.org/api/single-executable-applications.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-276" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-02-09T15:20:27Z",
    "nvd_published_at" : "2024-02-09T23:15:09Z"
  }
}