Potential fix for code scanning alert no. 10: DOM text reinterpreted as HTML - #6174
Open
0xcucumbersalad wants to merge 2 commits into
Open
Potential fix for code scanning alert no. 10: DOM text reinterpreted as HTML#61740xcucumbersalad wants to merge 2 commits into
0xcucumbersalad wants to merge 2 commits into
Conversation
…as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Biome format check failed on PR #6174 (line too long).
0xcucumbersalad
marked this pull request as ready for review
August 18, 2026 14:47
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.
Potential fix for https://github.com/decocms/studio/security/code-scanning/10
The best fix is to validate and sanitize image URLs at the point they enter state (input change) and at render time before assigning to
img.src, using a strict allowlist of protocols (http:/https:) plus optional relative URLs. This preserves existing functionality (users can still paste normal image URLs and upload images) while preventing unsafe schemes from ever being rendered.Concretely:
apps/web/src/views/registry/image-upload.tsxonChangehandler soonChangereceives only safe values (or empty string if unsafe).<img src=...>as defense in depth.No new package is required; use built-in
URL.Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by cubic
Sanitizes image URLs in the registry image upload to address code scanning alert #10 (DOM text reinterpreted as HTML). Previously raw input was assigned to img.src; now only http/https (including relative) are accepted and normalized to absolute, otherwise cleared, preventing unsafe schemes from rendering and affecting how values display/store.
sanitizeImageUrlinapps/web/src/views/registry/image-upload.tsx; used in URL inputonChangeand when rendering<img src>.http:/https:; trims input; invalid or disallowed schemes return an empty string. Relative inputs render as absolute.data:,file:, andjavascript:are rejected; update any callers that relied on those schemes.onChangehandler for formatting only; no behavior change.Written for commit e429ddd. Summary will update on new commits.