{"id":"GHSA-cfqx-f43m-vfh7","aliases":[],"status":"published","title":"@saltcorn/server arbitrary file and directory listing when accessing build mobile app results","description":"### Summary\n\nA user with admin permission can read arbitrary file and directory names on the filesystem by calling the `admin/build-mobile-app/result?build_dir_name=` endpoint.  The `build_dir_name` parameter is not properly validated and it's then used to construct the `buildDir` that is read. The file/directory names under the `buildDir` will be returned. \n\n### Details\n\n- file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/admin.js#L2884-L2893\n\n```js\nrouter.get(\n  \"/build-mobile-app/result\",\n  isAdmin,\n  error_catcher(async (req, res) =\u003e {\n    const { build_dir_name } = req.query; // [1] source\n    const rootFolder = await File.rootFolder();\n    const buildDir = path.join(\n      rootFolder.location,\n      \"mobile_app\",\n      build_dir_name // [2]\n    );\n    const files = await Promise.all(\n      fs\n        .readdirSync(buildDir) // [3] sink\n        .map(async (outFile) =\u003e await File.from_file_on_disk(outFile, buildDir))\n    );\n    [...]\n  })\n);\n```\n\n### PoC\n\n- log into the application as an admin user\n- visit the following url: `http://localhost:3000/admin/build-mobile-app/result?build_dir_name=/../../../../../../../../`\n\n\n**NOTE**: it's possible to only see file and directory names but not to download their content.\n\n### Impact\n\nInformation disclosure\n\n### Recommended Mitigation\n\nResolve the `buildDir` and check if it starts with `${rootFolder.location}/mobile_app`.","severity":{"version":"4.0","score":5.5,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P","level":"medium","from":"ghsa"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-548"],"published":"2024-10-03T19:46:42Z","modified":"2024-10-04T16:51:51Z","fixes":[{"ecosystem":"npm","package":"@saltcorn/server","fixed_in":["1.0.0-beta.14"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"@saltcorn/server","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"1.0.0-beta.13"},{"fixed":"1.0.0-beta.14"}]}]},{"source":"osv","ecosystem":"npm","package":"@saltcorn/server","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.0-beta.14"}]}]}],"references":[{"url":"https://github.com/saltcorn/saltcorn/security/advisories/GHSA-cfqx-f43m-vfh7","tags":["web"]},{"url":"https://github.com/saltcorn/saltcorn/commit/81adaf78430a9b59804894574d67d2a0c7bb3dc5","tags":["web"]},{"url":"https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/admin.js#L2884-L2893","tags":["web"]},{"url":"https://github.com/advisories/GHSA-cfqx-f43m-vfh7"},{"url":"https://github.com/saltcorn/saltcorn","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-cfqx-f43m-vfh7","title":"@saltcorn/server arbitrary file and directory listing when accessing build mobile app results","description":"### Summary\n\nA user with admin permission can read arbitrary file and directory names on the filesystem by calling the `admin/build-mobile-app/result?build_dir_name=` endpoint.  The `build_dir_name` parameter is not properly validated and it's then used to construct the `buildDir` that is read. The file/directory names under the `buildDir` will be returned. \n\n### Details\n\n- file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/admin.js#L2884-L2893\n\n```js\nrouter.get(\n  \"/build-mobile-app/result\",\n  isAdmin,\n  error_catcher(async (req, res) =\u003e {\n    const { build_dir_name } = req.query; // [1] source\n    const rootFolder = await File.rootFolder();\n    const buildDir = path.join(\n      rootFolder.location,\n      \"mobile_app\",\n      build_dir_name // [2]\n    );\n    const files = await Promise.all(\n      fs\n        .readdirSync(buildDir) // [3] sink\n        .map(async (outFile) =\u003e await File.from_file_on_disk(outFile, buildDir))\n    );\n    [...]\n  })\n);\n```\n\n### PoC\n\n- log into the application as an admin user\n- visit the following url: `http://localhost:3000/admin/build-mobile-app/result?build_dir_name=/../../../../../../../../`\n\n\n**NOTE**: it's possible to only see file and directory names but not to download their content.\n\n### Impact\n\nInformation disclosure\n\n### Recommended Mitigation\n\nResolve the `buildDir` and check if it starts with `${rootFolder.location}/mobile_app`.","status":"published","published":"2024-10-03T19:46:42Z","modified":"2024-10-04T16:51:51Z","cvss":[{"version":"4.0","score":5.5,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P","level":"medium"},{"version":"3.1","score":4.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N","level":"medium"}],"cwes":["CWE-548"],"updated_at":"2026-11-02T14:38:08.742903Z"}],"osv":[{"id":"GHSA-cfqx-f43m-vfh7","title":"@saltcorn/server arbitrary file and directory listing when accessing build mobile app results","description":"### Summary\n\nA user with admin permission can read arbitrary file and directory names on the filesystem by calling the `admin/build-mobile-app/result?build_dir_name=` endpoint.  The `build_dir_name` parameter is not properly validated and it's then used to construct the `buildDir` that is read. The file/directory names under the `buildDir` will be returned. \n\n### Details\n\n- file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/admin.js#L2884-L2893\n\n```js\nrouter.get(\n  \"/build-mobile-app/result\",\n  isAdmin,\n  error_catcher(async (req, res) =\u003e {\n    const { build_dir_name } = req.query; // [1] source\n    const rootFolder = await File.rootFolder();\n    const buildDir = path.join(\n      rootFolder.location,\n      \"mobile_app\",\n      build_dir_name // [2]\n    );\n    const files = await Promise.all(\n      fs\n        .readdirSync(buildDir) // [3] sink\n        .map(async (outFile) =\u003e await File.from_file_on_disk(outFile, buildDir))\n    );\n    [...]\n  })\n);\n```\n\n### PoC\n\n- log into the application as an admin user\n- visit the following url: `http://localhost:3000/admin/build-mobile-app/result?build_dir_name=/../../../../../../../../`\n\n\n**NOTE**: it's possible to only see file and directory names but not to download their content.\n\n### Impact\n\nInformation disclosure\n\n### Recommended Mitigation\n\nResolve the `buildDir` and check if it starts with `${rootFolder.location}/mobile_app`.","status":"published","published":"2024-10-03T19:46:42Z","modified":"2024-10-03T19:46:43Z","cvss":[{"version":"3.1","score":4.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N","level":"medium"},{"version":"4.0","score":5.5,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P","level":"medium"}],"cwes":["CWE-548"],"updated_at":"2026-11-02T15:46:44.927642Z"}]}}
