π‘οΈ Sentinel: [HIGH] Fix XSS in event preview formatting#867
π‘οΈ Sentinel: [HIGH] Fix XSS in event preview formatting#867kevinaboos wants to merge 1 commit into
Conversation
Sanitized user-controlled fields within `AnyOtherStateEventContentChange` and `OtherMessageLike` (like aliases, custom rules, and event types) in `src/event_preview.rs` when generating HTML previews. Co-authored-by: kevinaboos <1139460+kevinaboos@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π¨ Severity: HIGH
π‘ Vulnerability: Cross-Site Scripting (XSS) / HTML injection via unsanitized Matrix event previews. User-controlled text such as custom event types, custom guest access rules, custom history visibility, custom join rules, aliases, and canonical aliases were directly embedded into formatted strings in
src/event_preview.rsand rendered as HTML without escaping.π― Impact: An attacker could inject malicious HTML or script tags into the application by setting crafted custom rules, aliases, or sending messages with malicious event types. When a user views the timeline, the unsanitized preview could execute arbitrary code or corrupt the UI, potentially compromising their session.
π§ Fix: Updated
text_preview_of_other_stateandtext_preview_of_other_message_liketo properly escape the relevant string values usinghtmlize::escape_textwheneverformat_as_htmlis true.text_preview_of_other_message_likewas also updated to accept theformat_as_htmlparameter and all its call sites were adjusted accordingly.β Verification: Ran
cargo check,cargo clippy, andcargo test --libsuccessfully. Reviewed the code to ensurehtmlize::escape_textis correctly applied to the user-controlled strings and that lifetimes are managed correctly (e.g. usingCow::Borrowedwhen escaping is not needed and allocating where necessary).PR created automatically by Jules for task 7387762487924466894 started by @kevinaboos