Title: id(web/markdown): image src bypasses the #5745 scheme neutralization — javascript:/data:text/html/vbscript:/file: survive import, raw-HTML , collab PM JSON, and save · Issue #6364 · developing-today/code · GitHub
Open Graph Title: id(web/markdown): image src bypasses the #5745 scheme neutralization — javascript:/data:text/html/vbscript:/file: survive import, raw-HTML , collab PM JSON, and save · Issue #6364 · developing-today/code
X Title: id(web/markdown): image src bypasses the #5745 scheme neutralization — javascript:/data:text/html/vbscript:/file: survive import, raw-HTML , collab PM JSON, and save · Issue #6364 · developing-today/code
Description: Summary The #5745 fix (PR #6339, merged today) neutralizes executable URL schemes in Markdown links at every entry point of pkgs/id/src/web/markdown.rs — but image src was left out of the same treatment in every direction. An image whose...
Open Graph Description: Summary The #5745 fix (PR #6339, merged today) neutralizes executable URL schemes in Markdown links at every entry point of pkgs/id/src/web/markdown.rs — but image src was left out of the same trea...
X Description: Summary The #5745 fix (PR #6339, merged today) neutralizes executable URL schemes in Markdown links at every entry point of pkgs/id/src/web/markdown.rs — but image src was left out of the same trea...
Opengraph URL: https://github.com/developing-today/code/issues/6364
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web/markdown): image src bypasses the #5745 scheme neutralization — javascript:/data:text/html/vbscript:/file: survive import, raw-HTML \u003cimg>, collab PM JSON, and save","articleBody":"## Summary\n\nThe #5745 fix (PR #6339, merged today) neutralizes executable URL schemes in Markdown **links** at every entry point of `pkgs/id/src/web/markdown.rs` — but **image `src` was left out of the same treatment in every direction**. An image whose source is `javascript:`, `data:text/html`, `vbscript:`, `file:`, or any other non-image scheme survives import, raw-HTML `\u003cimg>` import, the raw-ProseMirror-JSON (collab) path, and save — sized images even emit it verbatim into a raw `\u003cimg src=\"…\">` HTML tag. Links in the same document, through the same converter, are neutralized to `#`.\n\nThis is the exact gap #5745's own oracle says not to leave: `link_url_is_safe` (markdown.rs:3943) documents that safety must come from an explicit allowed-scheme set and \"do not rely on browser sanitization\". Image sources currently rely on browser behaviour alone.\n\n## Evidence (file:line, main @ 6f4e4e37a9)\n\nSanitized (links, for contrast):\n- markdown.rs:2992 — parse direction: `\"href\": sanitize_link_url(&link.url)`\n- markdown.rs:3943 / :3984 — `link_url_is_safe` / `sanitize_link_url` (allowed: `http`, `https`, `mailto`, or scheme-less)\n- markdown.rs:4016, :5047, :5271, :5616 — raw-HTML anchor href and all save-direction link hrefs also sanitized\n\nNot sanitized (images):\n- markdown.rs:3013-3015 — parse direction, `NodeValue::Image` arm: `\"src\": image.url` verbatim\n- markdown.rs:3903 — `parse_img_tag`: raw-HTML `\u003cimg src>` imported verbatim (`let src = attr(\"src\")?`)\n- markdown.rs:5060 — save direction, unsized image: `url: src.to_owned()` verbatim\n- markdown.rs:5023 — save direction, sized image: `format!(\"\u003cimg src=\\\"{}\\\"\", escape_attr_value(src))` — attribute-escaped only; the scheme itself is emitted verbatim into an HTML tag\n- pkgs/id/web/src/image-node-view.ts:55 — the editor assigns the stored value directly: `img.src = node.attrs.src || \"\"`\n\n## Verified this run (laptop, real `id` crate, probe `~/git/fleet/probe-md-img-scheme`, main @ 6f4e4e37a9)\n\nProbe called the public `id::web::{markdown_to_prosemirror, prosemirror_to_markdown}` (feature `web`):\n\nParse direction (`markdown_to_prosemirror`):\n- `)` → image `src = \"javascript:alert(1)\"`\n- `)` → `src = \"JaVaScRiPt:alert(1)\"`\n- `` → src preserved verbatim\n- `)` → preserved; `` → preserved\n- `\u003cimg src=\"javascript:alert(1)\" alt=\"x\">` → image src preserved verbatim\n- `\u003cimg src=\"data:text/html;base64,PHNjcmlwdD4=\" alt=\"x\" width=\"10\">` → src + width preserved verbatim\n- Control, same converter: `[x](javascript:alert(1))` → link mark `href = \"#\"` (the #5745 behaviour)\n\nSave direction (`prosemirror_to_markdown` on raw ProseMirror JSON — the collab Rich path that never passed the parse-direction converter):\n- image `src = \"javascript:alert(1)\"` → saved as `)`\n- image `src = \"data:text/html;base64,PHNjcmlwdD4=\"` → saved verbatim\n- sized image (width 10) `src = \"javascript:alert(1)\"` → saved as `\u003cimg src=\"javascript:alert(1)\" alt=\"x\" width=\"10\" />`\n\nControls that must keep working: `https://example.com/a.png`, `/local/a.png`, and `data:image/png;base64,iVBORw0KGgo=` all parse with src preserved (see the policy note — the last one is why the image oracle cannot simply reuse the link oracle).\n\n## Why it matters\n\n- Stored/collaborative documents are shared content: a doc imported from Markdown, pasted as raw HTML, or pushed as raw ProseMirror JSON over collab can plant an image node whose src is an executable or local-file scheme, and it round-trips indefinitely — every save re-emits it, including as a raw HTML `\u003cimg>` tag for sized images. Any present or future consumer that renders that HTML, opens the image in a top-level context, or follows the src outside an `\u003cimg>` element inherits the payload. #5745 was filed and fixed at priority/high precisely because this converter must not rely on downstream/browser sanitization.\n- The asymmetry is invisible: a reader of the #5745 fix reasonably believes \"URL schemes in this codec are neutralized\", while the image half of the same codec is untouched.\n\n## Policy note (the design call for triage)\n\nThe image oracle is **not** the link oracle verbatim: `data:image/*` (at least the raster types, e.g. `data:image/png`) is a legitimate, currently-working image source and must not be neutralized. The fix needs an image-specific allowed set — e.g. scheme-less / `http` / `https` / `data:image/\u003craster>` — with everything else (`javascript:`, `vbscript:`, `data:text/html`, `data:image/svg+xml` if script-bearing SVG is in scope, `file:`, unknown schemes, and TAB/LF/CR-obfuscated spellings of them, mirroring `link_url_is_safe`'s stripping probe) neutralized the same way links are. Whether to neutralize to `\"#\"` (link precedent) or drop/replace the src is part of the same call.\n\n## Acceptance criteria\n\n- [ ] An image-specific scheme check exists beside `link_url_is_safe` in markdown.rs, with the allowed set documented as the oracle (including the `data:image/*` decision and its rationale)\n- [ ] Parse direction: Markdown images and raw-HTML `\u003cimg>` imports with a disallowed scheme no longer produce a PM image node carrying that src (neutralized per the chosen shape); TAB/LF/CR-obfuscated and mixed-case spellings are caught\n- [ ] Save direction: raw ProseMirror JSON image nodes with a disallowed src are neutralized in both the unsized (``) and sized (`\u003cimg …>`) emission paths, and a sanitized document is a stable round-trip fixpoint (re-parsing/re-saving changes nothing further)\n- [ ] Controls preserved byte-for-byte in both directions: `http:`/`https:` images, relative/absolute local paths, and the allowed `data:image/*` forms\n- [ ] Pinning tests in the markdown module cover each path above, in the style of the #5745 tests (`test_link_executable_schemes_neutralized` and siblings), naming the image oracle\n- [ ] The linked-image case still works: the wrapping link's `linkHref` keeps its #5745 neutralization and the image src check does not break `[](href)` round-trips\n\n## Dedup\n\n`gh search issues` for \"5745 image\", \"markdown image src scheme\", \"sanitize image\", \"img src\" (2026-11-05): #5745 (closed) is links-only in title, body, and fix; #873 (closed) is attribute escaping of src/alt/title, not schemes; no open or closed issue covers image-src schemes. Related: #5745 / PR #6339 (the link fix this extends).\n","author":{"url":"https://github.com/apps/developing-today","@type":"Person","name":"developing-today"},"datePublished":"2026-11-05T19:04:49Z","url":"https://github.com/developing-today/code/issues/6364"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:746aa7f9-4924-d1f0-b337-a4b7f1ed0098 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C10:26A1D6:D5031F:11291AB:6B06417A |
| html-safe-nonce | 5cf45960bb78247c8b9bfded1feb99e291be5ee4c36791b4ae9b6607a74c1ff8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzEwOjI2QTFENjpENTAzMUY6MTEyOTFBQjo2QjA2NDE3QSIsInZpc2l0b3JfaWQiOiIzMzk3MzQzOTc0MDAyNjkxNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 071c063330833eac34904795e1123dbfb87ed427c4e5b92f565fa5a88d340618 |
| hovercard-subject-tag | issue:6229782218 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/6364/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77967a3183f2b616705a5b83e40a2022693d0493294531bcfbfa9311cbb62ec6/developing-today/code/issues/6364 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77967a3183f2b616705a5b83e40a2022693d0493294531bcfbfa9311cbb62ec6/developing-today/code/issues/6364 |
| og:image:alt | Summary The #5745 fix (PR #6339, merged today) neutralizes executable URL schemes in Markdown links at every entry point of pkgs/id/src/web/markdown.rs — but image src was left out of the same trea... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | developing-today[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac613d3698d3d8565651455086e1f74da07bf277 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width