Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1wZjU2LWg5cWYtcnhxNM4ABAA4

Saltcorn Server Stored Cross-Site Scripting (XSS) in event logs page

Summary

Event log data is not properly sanitized leading to stored Cross-Site Scripting (XSS) vulnerability.

Details

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)
  1. create an edit view so that staff users can insert more data
  1. edit the site structure to add the View just created so that staff users can access it
  1. create an event that will log when data is inserted in the my_table_xss table create at step 1

Login with a user with staff role (you can do the same steps also with an admin user)

With an admin user inspect the log entry generated by the above action:

Impact

Stored Cross-Site Scripting (XSS)

Recommended Mitigation

Sanitize the user input before building HTML elements

Permalink: https://github.com/advisories/GHSA-pf56-h9qf-rxq4
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1wZjU2LWg5cWYtcnhxNM4ABAA4
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: 11 days ago
Updated: 11 days ago


CVSS Score: 6.1
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Identifiers: GHSA-pf56-h9qf-rxq4
References: Repository: https://github.com/saltcorn/saltcorn
Blast Radius: 6.8

Affected Packages

npm:@saltcorn/server
Dependent packages: 8
Dependent repositories: 13
Downloads: 3,622 last month
Affected Version Ranges: < 1.0.0-beta.16
Fixed in: 1.0.0-beta.16
All affected versions: 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.7.4, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.8.7, 0.8.9, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7, 0.9.8, 1.0.0-beta.0, 1.0.0-beta.1, 1.0.0-beta.2, 1.0.0-beta.3, 1.0.0-beta.4, 1.0.0-beta.5, 1.0.0-beta.6, 1.0.0-beta.7, 1.0.0-beta.8, 1.0.0-beta.9, 1.0.0-beta.10, 1.0.0-beta.11, 1.0.0-beta.13, 1.0.0-beta.14, 1.0.0-beta.15
All unaffected versions: