The script for the dynamic table format in Cargo retrieves HTML from a non-reserved data attribute, allowing for stored XSS since those data attributes can be used in wikitext.
Reproduction steps
- Create or preview a page with the following contents:
<div style="display:none">{{#cargo_query: |tables=Authors |fields=Country |format=dynamic table |details fields=Country }}</div> <table class="cargoDynamicTable display" data-details-fields="1" data-order="[]"><tr data-details="<img src=x onerror=alert(2)>"><td class="details-control">Click me</td></tr></table>
In the example, I'm using the Authors table from https://www.mediawiki.org/wiki/Extension:Cargo/Quick_start_guide, but this can be reproduced using any table.
- Click on the row with the "Click me" text
Cause
A non-reserved data attribute is used to store HTML:
https://github.com/wikimedia/mediawiki-extensions-Cargo/blob/e89d34eeb509874b1fc035d42fe9a5158aeedc58/libs/ext.cargo.datatables.js#L90
Another data attribute is used for HTML at https://github.com/wikimedia/mediawiki-extensions-Cargo/blob/e89d34eeb509874b1fc035d42fe9a5158aeedc58/libs/ext.cargo.datatables.js#L53, but I didn't immediately find a way to create a custom element inside a <tfoot> tag, at least using the dynamic table format in Cargo. It should still be fixed.
Additional information
MW: 1.46.0-alpha (0990aaf)
Cargo: 3.8.6 (dd8b1d5)
