Skip to content

Commit 6ec23b8

Browse files
Potential fix for code scanning alert no. 39: Client-side cross-site scripting
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 6f4c294 commit 6ec23b8

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

client/public/sandbox_proxy.html

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,9 @@
3434
return window.DOMPurify.sanitize(html, { RETURN_TRUSTED_TYPE: false });
3535
}
3636

37-
// Very conservative fallback: strip <script> tags and common inline event handlers.
38-
const parser = new DOMParser();
39-
const doc = parser.parseFromString(html, "text/html");
40-
41-
// Remove all <script> elements.
42-
doc.querySelectorAll("script").forEach((el) => el.remove());
43-
44-
// Remove inline event handlers such as onclick, onload, etc.
45-
doc.querySelectorAll("*").forEach((el) => {
46-
[...el.attributes].forEach((attr) => {
47-
if (/^on/i.test(attr.name)) {
48-
el.removeAttribute(attr.name);
49-
}
50-
});
51-
});
52-
53-
return doc.documentElement.innerHTML;
37+
// If DOMPurify is not available, do not attempt to sanitize manually.
38+
// Returning an empty string avoids rendering untrusted HTML with a weak sanitizer.
39+
return "";
5440
}
5541

5642
// Notify host that we are ready to receive the app resource

0 commit comments

Comments
 (0)