π‘οΈ Sentinel: [MEDIUM] Fix Rich Text HTML injection in QTextEdit widgets - #222
π‘οΈ Sentinel: [MEDIUM] Fix Rich Text HTML injection in QTextEdit widgets#222dieterolson wants to merge 2 commits into
Conversation
`QTextEdit` parses HTML by default, which can lead to UI redressing or HTML injection if untrusted text (like system prompts or logs) is pasted or appended. This commit explicitly sets `setAcceptRichText(False)` on all relevant `QTextEdit` instances in `chat_panel.py`, `hub_dialog.py`, `settings_panel.py`, and `setup_dialog.py`. Co-authored-by: dieterolson <198168927+dieterolson@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. |
|
`QTextEdit` parses HTML by default, which can lead to UI redressing or HTML injection if untrusted text (like system prompts or logs) is pasted or appended. This commit explicitly sets `setAcceptRichText(False)` on all relevant `QTextEdit` instances in `chat_panel.py`, `hub_dialog.py`, `settings_panel.py`, and `setup_dialog.py`. It also updates `SPEC.md` to pass the spec-check CI workflow. Co-authored-by: dieterolson <198168927+dieterolson@users.noreply.github.com>
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29c6093593
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| **Vulnerability:** `QTextEdit` accepts rich text (HTML) by default, meaning that any text resembling HTML pasted or programmatically inserted into it can be rendered as rich text. This opens up possibilities for HTML injection or UI redressing via pasted content or unchecked external data. | ||
| **Learning:** In PyQt6, `QTextEdit` widgets expose a rich text functionality by default. To enforce plain text input or display (especially when handling user input like a chat box or system prompt), it is critical to explicitly disable the rich text feature. | ||
| **Prevention:** Always apply `.setAcceptRichText(False)` to `QTextEdit` instances to prevent HTML injection unless rich text functionality is actively required and the input is sanitized. |
There was a problem hiding this comment.
Use plain-text APIs for programmatic insertions
When a future caller follows this new prevention rule for untrusted output, it can still pass HTML through append() or setHtml(): acceptRichText governs rich-text input from the user, such as paste and drag/drop, rather than programmatic rich-text APIs. The current display helpers happen to use insertPlainText(), but this entry explicitly claims programmatic insertion is covered and can therefore reintroduce the vulnerability it is meant to prevent; require insertPlainText() or setPlainText() for programmatic content and describe setAcceptRichText(False) only as input hardening.
AGENTS.md reference: AGENTS.md:L25-L26
Useful? React with πΒ / π.
|
Closing in favor of consolidated batch PR #227. |
π¨ Severity: MEDIUM
π‘ Vulnerability:
QTextEditwidgets in PyQt6 accept and render rich text (HTML) by default. If untrusted data (like external logs, or user-pasted system prompts containing HTML) is processed, it can lead to HTML injection or UI redressing.π― Impact: Malicious actors could theoretically inject misleading UI elements or hide text (e.g.,
<module name>being parsed as an invalid HTML tag and hidden from the log) via pasted content or unsanitized output.π§ Fix: Explicitly set
.setAcceptRichText(False)on all instances ofQTextEdit(chat history, setup logs, hub download logs, and system prompt settings) to force plain-text handling.β Verification: Verified that tests pass via
uv run pytest.Added a learning entry to
.jules/sentinel.mddocumenting thisQTextEditbehavior in PyQt.PR created automatically by Jules for task 12939595658233424047 started by @dieterolson