Security: Potential Cross-Site Scripting (XSS) via ng-bind-html with user-controlled data#11173
Open
tomaioo wants to merge 1 commit into
Open
Conversation
The `display_privacy_policies_preview.html` template uses `ng-bind-html` to render content that comes from user-uploaded files (`$scope.content`). While the controller uses `$sanitize`, the `getHtml` function first decodes base64 content using `atob()` and `decodeURIComponent()` before sanitization. If the sanitization is bypassed or contains bugs, this could lead to XSS. Additionally, the `resourceIcon` filter uses `$sce.trustAsHtml()` which directly trusts HTML content without sanitization, potentially allowing malicious SVG or other HTML content. Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Member
|
@sugat009 would you be available to review this PR? Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Security: Potential Cross-Site Scripting (XSS) via ng-bind-html with user-controlled data
Problem
Severity:
High| File:admin/src/templates/display_privacy_policies_preview.html:L1The
display_privacy_policies_preview.htmltemplate usesng-bind-htmlto render content that comes from user-uploaded files ($scope.content). While the controller uses$sanitize, thegetHtmlfunction first decodes base64 content usingatob()anddecodeURIComponent()before sanitization. If the sanitization is bypassed or contains bugs, this could lead to XSS. Additionally, theresourceIconfilter uses$sce.trustAsHtml()which directly trusts HTML content without sanitization, potentially allowing malicious SVG or other HTML content.Solution
Ensure all user-controlled content passed to
ng-bind-htmlis properly sanitized. Consider usingng-bindinstead where possible, or implement a stricter content security policy. ForresourceIcon, validate and sanitize image content server-side before allowing it to be served.Changes
admin/src/templates/display_privacy_policies_preview.html(modified)