GHSA-pf56-h9qf-rxq4: @saltcorn/server Cross-Site Scripting Vulnerability

MODERATE
CVSS 6.1
CWE-79
Published
Advisory Summary

GHSA-pf56-h9qf-rxq4 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @saltcorn/server libraries in the npm ecosystem. The issue involves saltcorn server stored cross-site scripting (xss) in event logs page. Remediation is available by upgrading affected packages to version 1.0.0-beta.16.

GHSA-pf56-h9qf-rxq4 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-pf56-h9qf-rxq4
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product @saltcorn/server
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.1

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:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix GHSA-pf56-h9qf-rxq4

To remediate this vulnerability, upgrade all affected @saltcorn/server dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@saltcorn/server fixed: 1.0.0-beta.16
npm install @saltcorn/server@1.0.0-beta.16
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @saltcorn/server

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-pf56-h9qf-rxq4, inspect your project dependencies using npm:

npm ls @saltcorn/server

Analyze the terminal output to locate any version of @saltcorn/server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0-beta.16), your application is affected.

Note: The npm ls @saltcorn/server 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In @saltcorn/server, 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

### Summary Event log data is not properly sanitized leading to stored Cross-Site Scripting (XSS) vulnerability. ### Details - file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/eventlog.js#L445 ```js router.get( "/:id", isAdmin, error_catcher(async (req, res) => { const { id } = req.params; const ev = await EventLog.findOneWithUser(id); send_events_page({ [...] contents: { type: "card", contents: [...] ) + div( { class: "eventpayload" }, ev.payload ? pre(JSON.stringify(ev.payload, null, 2)) : "" //<--- ), }, }); }) ``` ### PoC The following PoC demonstrates how a non-admin user with permission to read/write on a table can inject malicious javascript code that will be executed in the event log admin panel if event logs are enabled. To demonstrate this issue, we need to prepare some components. The following steps should be executed with an admin user. 1. create a table with one column of type string set read/write permission to staff users (just as an example) - visit `http://localhost:3000/table/new` - create a table with `Table name` `my_table_xss` and click `Create` - click `Add field` to add a field with `Label` called `payload` of type `String` and click `Next >>` - leave default values for `Attributes` and click `Next >>` - it should redirect to `http://localhost:3000/table/<table-number>` - under `Edit table properties`, set `Minimum role to read` and `Minimum role to write` to `staff` 2. create an edit view so that staff users can insert more data - visit `http://localhost:3000/viewedit` anc click `Create View` - set the following values: - `View name`: `my_xss_view` - `View pattern`: `Edit` - `Table`: `my_table_xss` - `Minimum role`: `staff` - click `Configure >>` - on page `http://localhost:3000/viewedit/config/my_xss_view` click `Next >>` and then `Finish >>` - you should see a message `View my_xss_view saved` 3. edit the site structure to add the View just created so that `staff` users can access it - visit `http://localhost:3000/menu` - set the following values: - `Type`: `View` - `View`: `my_xss_view [Edit]` - `Text label`: `view` - `Minimum role`: `staff` - click `Add` 4. create an event that will log when data is inserted in the `my_table_xss` table create at step 1 - visit `http://localhost:3000/eventlog/settings` - under `Which events should be logged?` select: - `[X] Insert` - `[X] Insert my_table_xss` Login with a user with staff role (you can do the same steps also with an admin user) - visit `http://localhost:3000/view/my_xss_view` - in the `payload` field insert ``"<svg/onload=alert(`xss`)>`` and click `Save` With an admin user inspect the log entry generated by the above action: - visit `http://localhost:3000/eventlog` - click on the event log generated (`http://localhost:3000/eventlog/<event-number>`) - an alert will appear ### Impact Stored Cross-Site Scripting (XSS) ### Recommended Mitigation Sanitize the user input before building HTML elements

GHSA-pf56-h9qf-rxq4 Affected @saltcorn/server Versions

1 component(s)
Fixed Versions:
1.0.0-beta.16
Product / Package Ecosystem Affected Versions Fixed Version
@saltcorn/server
npm
< 1.0.0-beta.16
1.0.0-beta.16

References

Frequently Asked Questions

What is GHSA-pf56-h9qf-rxq4?
GHSA-pf56-h9qf-rxq4 is a security vulnerability in @saltcorn/server involving Saltcorn Server Stored Cross-Site Scripting (XSS) in event logs page under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which @saltcorn/server versions are affected?
Affected versions include releases prior to 1.0.0-beta.16 across affected packages: @saltcorn/server.
What version fixes GHSA-pf56-h9qf-rxq4?
Upgrading to 1.0.0-beta.16 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @saltcorn/server affected?
Yes, @saltcorn/server is affected in releases prior to 1.0.0-beta.16. Upgrade your dependency to 1.0.0-beta.16 or later.
What is the CVSS score of GHSA-pf56-h9qf-rxq4?
GHSA-pf56-h9qf-rxq4 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with GHSA-pf56-h9qf-rxq4?
GHSA-pf56-h9qf-rxq4 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for GHSA-pf56-h9qf-rxq4?
Run the dependency tree command: 'npm ls @saltcorn/server'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pf56-h9qf-rxq4",
  "modified" : "2024-10-07T15:14:40Z",
  "published" : "2024-10-07T15:14:40Z",
  "aliases" : [ ],
  "summary" : "Saltcorn Server Stored Cross-Site Scripting (XSS) in event logs page",
  "details" : "### Summary\n\nEvent log data is not properly sanitized leading to stored Cross-Site Scripting (XSS) vulnerability.\n### Details\n\n- file: https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/eventlog.js#L445\n\n```js\nrouter.get(\n  \"/:id\",\n  isAdmin,\n  error_catcher(async (req, res) => {\n    const { id } = req.params;\n    const ev = await EventLog.findOneWithUser(id);\n    send_events_page({\n      [...]\n      contents: {\n        type: \"card\",\n        contents:\n          [...]\n          ) +\n          div(\n            { class: \"eventpayload\" },\n            ev.payload ? pre(JSON.stringify(ev.payload, null, 2)) : \"\" //<---\n          ),\n      },\n    });\n  })\n\n```\n\n\n### PoC\n\nThe following PoC demonstrates how a non-admin user with permission to read/write on a table can inject malicious javascript code that will be executed in the event log admin panel if event logs are enabled.\n\nTo demonstrate this issue, we need to prepare some components. The following steps should be executed with an admin user.\n\n1. create a table with one column of type string set read/write permission to staff users (just as an example)\n  - visit `http://localhost:3000/table/new`\n  - create a table with `Table name` `my_table_xss` and click `Create`\n  - click `Add field` to add a field with `Label` called `payload` of type `String` and click `Next >>`\n  - leave default values for `Attributes` and click `Next >>` - it should redirect to `http://localhost:3000/table/<table-number>`\n  - under `Edit table properties`, set `Minimum role to read` and `Minimum role to write` to `staff`\n\n2. create an edit view so that staff users can insert more data\n  - visit `http://localhost:3000/viewedit` anc click `Create View`\n  - set the following values:\n    - `View name`: `my_xss_view`\n    - `View pattern`: `Edit`\n    - `Table`: `my_table_xss`\n    - `Minimum role`: `staff`\n  - click `Configure >>`\n  - on page `http://localhost:3000/viewedit/config/my_xss_view` click `Next >>` and then `Finish >>`\n  - you should see a message `View my_xss_view saved`\n\n3. edit the site structure to add the View just created so that `staff` users can access it\n  - visit `http://localhost:3000/menu`\n  - set the following values:\n    - `Type`: `View`\n    - `View`: `my_xss_view [Edit]`\n    - `Text label`: `view`\n    - `Minimum role`: `staff`\n  - click `Add`\n\n4. create an event that will log when data is inserted in the `my_table_xss` table create at step 1\n  - visit `http://localhost:3000/eventlog/settings`\n  - under `Which events should be logged?` select:\n    - `[X] Insert`\n    - `[X] Insert my_table_xss`\n\nLogin with a user with staff role (you can do the same steps also with an admin user)\n- visit `http://localhost:3000/view/my_xss_view`\n- in the `payload` field insert ``\"<svg/onload=alert(`xss`)>`` and click `Save`\n\n\nWith an admin user inspect the log entry generated by the above action:\n- visit `http://localhost:3000/eventlog`\n- click on the event log generated (`http://localhost:3000/eventlog/<event-number>`)\n- an alert will appear\n\n\n### Impact\n\nStored Cross-Site Scripting (XSS)\n\n### Recommended Mitigation\n\nSanitize the user input before building HTML elements",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@saltcorn/server"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.0-beta.16"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/saltcorn/saltcorn/security/advisories/GHSA-pf56-h9qf-rxq4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/saltcorn/saltcorn/commit/3c551261d0e230635774798009951fa83a07cc3a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/saltcorn/saltcorn"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/saltcorn/saltcorn/blob/v1.0.0-beta.13/packages/server/routes/eventlog.js#L445"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-07T15:14:40Z",
    "nvd_published_at" : null
  }
}