Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Output Sanitizer to Enhance Security and Data Integrity #1774

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pi-2r
Copy link
Member

@pi-2r pi-2r commented Oct 24, 2024

This pull request introduces a new safeHTML function to sanitize user inputs and prevent XSS attacks. The changes span multiple files and include updates to processing logic, utility functions, and unit tests.

XSS Prevention and HTML Sanitization:

  • BotAdminService.kt: Updated to use safeHTML for sanitizing request labels.
  • WebConnector.kt: Added a new processSafeHtml property to WebMessageProcessor to enable safe HTML processing.
  • WebMessageProcessor.kt: Modified to incorporate safeHTML in text post-processing, ensuring both Markdown and HTML safety. [1] [2]
  • Strings.kt: Introduced safeHTML function and supporting utilities to escape and filter unsafe HTML content. [1] [2]

Unit Tests:

  • StringsTest.kt: Added comprehensive unit tests for safeHTML to validate its effectiveness against various XSS attack vectors and ensure proper functionality.

@pi-2r pi-2r self-assigned this Oct 25, 2024
@rkuffer
Copy link
Contributor

rkuffer commented Nov 13, 2024

Hi Pierre,
How about using a tried-and-tested lib that can handle the very long list of possible injections at https://github.com/nahsra/antisamy?

@Benvii Benvii marked this pull request as draft November 21, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants