Alert documentation links allow JavaScript URL execution from uploaded report data | pkg:npm/%40rsdoctor/client@2.0.0-beta.0
Description
@rsdoctor/client before version 1.6.5 does not validate the URL scheme of documentation links supplied in report data. A crafted report can use a javascript: URL to execute script when a viewer clicks an alert's “more” link.
Impact
An attacker who can provide a report file—for example through a shared CI artifact, attachment, or build output—can set an alert's link field to a malicious javascript: URL.
If a user imports the untrusted report into the Rsdoctor report viewer and clicks the alert's “more” link, the client passes the URL to window.open() without validating its scheme. The script runs in the report viewer's origin and can access the opener's same-origin DOM and browser storage.
This requires user interaction: the victim must open the attacker-controlled report and click the documentation link.
Affected Versions
@rsdoctor/client versions before 1.6.5 are affected.
Patches
This issue is fixed in @rsdoctor/client version 1.6.5.
The fix accepts only HTTP(S) external URLs and opens them using _blank with noopener,noreferrer.
Reproduction
- Open the Rsdoctor report uploader.
- Import a report containing an alert with a
javascript:value in itslinkfield, for example:
```json { "clientRoutes": ["Bundle.BundleSize"], "data": { "root": "/tmp/app", "errors": [ { "id": "poc", "code": "E1003", "category": "bundle", "title": "Proof of concept", "description": "Click more", "level": "warn", "type": "link", "link": "javascript:alert(document.domain)" } ] } }
- Navigate to the rendered alert and click its “more” link.
- In affected versions, the JavaScript URL executes. In version 1.6.5 and later, the URL is rejected and the script does not execute.
Workarounds
Upgrade to version 1.6.5 or later. If upgrading is not immediately possible, do not import reports from untrusted sources or click documentation links in untrusted reports