diff --git a/src/shared/Dialogs/Messages.ts b/src/shared/Dialogs/Messages.ts
index 76d51d8d..520966af 100644
--- a/src/shared/Dialogs/Messages.ts
+++ b/src/shared/Dialogs/Messages.ts
@@ -14,6 +14,7 @@ I build this plugin as a labor of love. Curious about the philosophy behind it?
- ExcaliAI now shows an **"AI Usage: input/output"** button next to the Run button. Clicking it opens the same usage modal.
- Added an explicit opt-in for executing cmd:// links from drawings. Command links are now blocked by default, with a security warning prompt on first use and a dedicated setting under Excalidraw Automate.
- Replaced the dropped-link title resolver from Iframely with an HTTPS oEmbed endpoint, and restricted auto title resolution to HTTPS links.
+- Hardened data URL embeddables: HTML loaded through data:text/html now renders in a sandboxed iframe with a defensive CSP to keep interactive content contained inside the embeddable.
## New in ExcalidrawAutomate
- Added \`getPathForImageFileId(fileId: FileId): string | null\` — returns the vault path for an image element identified by its Excalidraw fileId. Note: Excalidraw does not maintain a persistent index of fileIds to paths; the path is only available for images that have appeared in an open drawing during the current Obsidian session.
diff --git a/src/view/components/CustomEmbeddable.tsx b/src/view/components/CustomEmbeddable.tsx
index 692cbc93..5ba79c85 100644
--- a/src/view/components/CustomEmbeddable.tsx
+++ b/src/view/components/CustomEmbeddable.tsx
@@ -48,6 +48,57 @@ const CANVAS_VIEWTYPES = new Set([
"pdf",
]);
+const DATA_URL_IFRAME_SANDBOX = "allow-scripts allow-forms allow-popups";
+const DATA_URL_IFRAME_CSP =
+ "default-src 'none'; script-src https: data: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:; font-src https: data:; connect-src https:; media-src https: data: blob:; frame-src https: data:; form-action https:; base-uri 'none'";
+
+function decodeDataUrlToHtml(dataUrl: string): string | null {
+ const commaIndex = dataUrl.indexOf(",");
+ if (commaIndex === -1) {
+ return null;
+ }
+
+ const header = dataUrl.slice(0, commaIndex).toLowerCase();
+ const payload = dataUrl.slice(commaIndex + 1);
+
+ try {
+ return header.includes(";base64")
+ ? atob(payload)
+ : decodeURIComponent(payload);
+ } catch {
+ return null;
+ }
+}
+
+function injectDefensiveCsp(html: string): string {
+ if (!html || /http-equiv\s*=\s*["']content-security-policy["']/i.test(html)) {
+ return html;
+ }
+
+ const cspTag = ``;
+
+ if (/