Skip to content

Sanitize browseableMessage html#17581

Merged
seanbudd merged 3 commits into
masterfrom
sanitizeBrowseableMsg
Jan 15, 2025
Merged

Sanitize browseableMessage html#17581
seanbudd merged 3 commits into
masterfrom
sanitizeBrowseableMsg

Conversation

@seanbudd

@seanbudd seanbudd commented Jan 6, 2025

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #16985

Summary of the issue:

ui.browsableMessage can inject unsanitized HTML into NVDA.
This is an issue if translations are passed in as unsanitized HTML.
Translations are fairly unregulated, translation strings are the only "code" included in NVDA without a direct review from NV Access or as a review as a dependency. If NVDA translations can perform RCE, we have a problem.
Considering no NVDA source code uses the isHtml functionality of this function currently, this isn't an active vector.
However, if we ever start using isHtml, it becomes an active vector, which is something we want to avoid and prevent from becoming a possibility.

Description of user facing changes

HTML is now sanitised for browseableMessages. This will only affect add-ons. It may cause some add-ons to lose formatting in browseableMessages that use HTML. To restore certain formatting, authors can update the whitelisting by calling nh3.clean with their own desired parameters.

Description of development approach

Added a sanitization function to browseableMessage.

Testing strategy:

  • Tested from console by calling ui.browseableMessage
import ui
import nh3
clean = lambda x: nh3.clean(x, tags={"i"})
ui.browseableMessage("<b><i>test</i></b>", "title example", isHtml=True, sanitizeHtmlFunc=clean)

Confirm only italic formatting is shown.

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@seanbudd seanbudd marked this pull request as ready for review January 6, 2025 00:17
@seanbudd seanbudd requested a review from a team as a code owner January 6, 2025 00:17
@seanbudd seanbudd requested a review from SaschaCowley January 6, 2025 00:17
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 2d1a334176

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nitpicky suggestions

Comment thread source/ui.py Outdated
Comment thread source/ui.py Outdated
Comment thread user_docs/en/changes.md Outdated
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
@SaschaCowley SaschaCowley added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jan 6, 2025
@seanbudd seanbudd requested a review from SaschaCowley January 7, 2025 01:05
@SaschaCowley

Copy link
Copy Markdown
Member

Do changes need to be made to bundle nh3 with NVDA, or will it automatically be included because it has been imported in source/?

@seanbudd

Copy link
Copy Markdown
Member Author

It should be automatically included - this is proven when running the installer. However, it won't import everything, only what is needed like other dependencies

@seanbudd seanbudd merged commit 19296bf into master Jan 15, 2025
@seanbudd seanbudd deleted the sanitizeBrowseableMsg branch January 15, 2025 03:46
@github-actions github-actions Bot added this to the 2025.1 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-breaking-change conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sanitize browsableMessage HTML

3 participants