Fixed XSS in report section #3333
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version: 3.28.0
Description
Malicious Python code can be embedded within reports to execute arbitrary JavaScript in users' browsers. The issue occurs because the application allows users to store Python code in reports that is automatically executed when viewed by other users. The vulnerability stems from the ability to use Pyodide's JavaScript bridge without any restrictions, allowing attackers to break out of the intended Python execution sandbox.
Source - Sink Analysis
/api/reports
API endpoint which accepts user-supplied Python code in thecode
field of POST requests.Report
model inaim/web/api/reports/models.py
)Board.tsx
where:pyodide.code.run_js()
to execute arbitrary JavaScriptThe vulnerability exists because there is no sanitization between the API input and the JavaScript execution.
Proof of Concept
Create a malicious report:
Note the report ID returned in the response
Visit the report and upon loading, the malicious JavaScript executes in the victim's browser context, sending all reports data to the attacker-controlled server
This demonstrates data exfiltration, but other payloads could perform different malicious actions.
Impact