NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

GHSA-pf56-h9qf-rxq4: Saltcorn Server Stored Cross-Site Scripting (XSS) in event logs page

mediumCVSS 4.0 5.1 · 3.1 6.1

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 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…

Published Oct 7, 2024

Affected packages

@saltcorn/server

Ecosystem
npm
Affected
< 1.0.0-beta.16
Fixed in
1.0.0-beta.16
Check
npm ls @saltcorn/server

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

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
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)
  2. visit http://localhost:3000/table/new
  3. create a table with Table name my_table_xss and click Create
  4. click Add field to add a field with Label called payload of type String and click Next >>
  5. leave default values for Attributes and click Next >> - it should redirect to http://localhost:3000/table/<table-number>
  6. under Edit table properties, set Minimum role to read and Minimum role to write to staff
  1. create an edit view so that staff users can insert more data
  2. visit http://localhost:3000/viewedit anc click Create View
  3. set the following values:
  4. View name: my_xss_view
  5. View pattern: Edit
  6. Table: my_table_xss
  7. Minimum role: staff
  8. click Configure >>
  9. on page http://localhost:3000/viewedit/config/my_xss_view click Next >> and then Finish >>
  10. you should see a message View my_xss_view saved
  1. edit the site structure to add the View just created so that staff users can access it
  2. visit http://localhost:3000/menu
  3. set the following values:
  4. Type: View
  5. View: my_xss_view [Edit]
  6. Text label: view
  7. Minimum role: staff
  8. click Add
  1. create an event that will log when data is inserted in the my_table_xss table create at step 1
  2. visit http://localhost:3000/eventlog/settings
  3. under Which events should be logged? select:
  4. [X] Insert
  5. [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

Credited to dellalibera.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology

More npm vulnerabilities

All npm entries