@saltcorn/server
Affected
- introduced
0, fixed1.0.0-beta.16(semver)
Fixed versions
1.0.0-beta.16
Fix
- Fixed version
1.0.0-beta.16npm install @saltcorn/[email protected]
Advisory
Also known as: None
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.
http://localhost:3000/table/newTable name my_table_xss and click CreateAdd field to add a field with Label called payload of type String and click Next >>Attributes and click Next >> - it should redirect to http://localhost:3000/table/<table-number>Edit table properties, set Minimum role to read and Minimum role to write to staffhttp://localhost:3000/viewedit anc click Create ViewView name: my_xss_view - View pattern: Edit - Table: my_table_xss - Minimum role: staffConfigure >>http://localhost:3000/viewedit/config/my_xss_view click Next >> and then Finish >>View my_xss_view savedstaff users can access ithttp://localhost:3000/menuType: View - View: my_xss_view [Edit] - Text label: view - Minimum role: staffAddmy_table_xss table create at step 1http://localhost:3000/eventlog/settingsWhich events should be logged? select: - [X] Insert - [X] Insert my_table_xssLogin with a user with staff role (you can do the same steps also with an admin user)
http://localhost:3000/view/my_xss_viewpayload field insert "<svg/onload=alert(`xss`)> and click SaveWith an admin user inspect the log entry generated by the above action:
http://localhost:3000/eventloghttp://localhost:3000/eventlog/<event-number>)Impact
Stored Cross-Site Scripting (XSS)
Recommended Mitigation
Sanitize the user input before building HTML elements
Medium Basis: The source's own band: MODERATE
0, fixed 1.0.0-beta.16 (semver)1.0.0-beta.16
1.0.0-beta.16npm install @saltcorn/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0