Event log data is not properly sanitized leading to stored Cross-Site Scripting (XSS) vulnerability.
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)) : "" //<---
),
},
});
})
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.
create a table with one column of type string set read/write permission to staff users (just as an example)
http://localhost:3000/table/new
Table name
my_table_xss
and click Create
Add 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 staff
create an edit view so that staff users can insert more data
http://localhost:3000/viewedit
anc click Create View
View name
: my_xss_view
View pattern
: Edit
Table
: my_table_xss
Minimum role
: staff
Configure >>
http://localhost:3000/viewedit/config/my_xss_view
click Next >>
and then Finish >>
View my_xss_view saved
edit the site structure to add the View just created so that staff
users can access it
http://localhost:3000/menu
Type
: View
View
: my_xss_view [Edit]
Text label
: view
Minimum role
: staff
Add
create an event that will log when data is inserted in the my_table_xss
table create at step 1
http://localhost:3000/eventlog/settings
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
Stored Cross-Site Scripting (XSS)
Sanitize the user input before building HTML elements
{ "github_reviewed_at": "2024-10-07T15:14:40Z", "cwe_ids": [ "CWE-79" ], "nvd_published_at": null, "severity": "MODERATE", "github_reviewed": true }