Skip to content

Let <a download href="data:..."> pass security_javascript="forbid" #600

Open

Description

@JuroOravec

Priority: high. An app that offers a file as a data: URL, such as a zip or spreadsheet export, cannot turn on security_javascript="forbid" since 0.7.0 unless it serves the file from a URL or labels it application/octet-stream.

What happens

security_javascript="forbid" is for pages that must run no JavaScript, such as an HTML email or a static export. It raises ValueError when a page has a data: URL that a browser could open as a document that runs scripts. Since 0.7.0 it reads these URLs in links and forms too, and a download link is judged like any other link:

<a
  download="export.zip"
  href="data:application/zip;base64,UEsDBA..."
>Export</a>

The check skips a data: URL of plain text, CSS, CSV, JSON, an image, audio, video, a font, a PDF or application/octet-stream. It reports a zip, a spreadsheet, a calendar file, Markdown, XML or SVG export. It reports an HTML export when the document holds a script or the check cannot read it. The 0.7.0 changelog and the security page give the workaround. The code has no special case for the download attribute.

The download attribute asks the browser to save the file instead of showing it. In one Chromium test, no script ran from a download link to a data: HTML or SVG document. Firefox is untested: the automated click failed on such links. So 0.7.0 keeps reporting them.

What we want

  1. Find out what each browser does when a visitor uses a <a download href="data:..."> link whose type is HTML, SVG or another XML type. Test Chromium and Firefox, and WebKit if it can be run, with each way a visitor can use the link: a click, the keyboard, "open in a new tab" from the context menu, and a link whose target names a frame. Record, for each, whether the browser saves the file or opens the document, and whether the document's script runs.
  2. If every browser tested only saves the file, and the maintainers decide that forbid should accept such links (the first open question), stop reporting <a download> links under forbid. Make the change where the output check reads data: URLs in crates/citry_html_transform/src/output_policy.rs, and in the Python copy of the rules that the comparison test uses (packages/py/citry/tests/_output_policy_reference.py), so they agree. Update the security page, the changelog and the Rust test cases, and add a browser test that fails if a browser starts opening such a document.
  3. If any browser opens the document, keep reporting these links, and say in the docs which browser and which way of opening it.

Open questions

  • A saved .html or .svg file runs its script when the visitor opens it later from disk, outside the page. Should forbid accept a link to such a file, or keep reporting every download link whose type can run script when opened? If it keeps reporting them, this issue ends with a clearer error message and docs, and the links stay reported.
  • Which spellings count as a download link: download with no value, an empty value, or a file name; the name in any letter case.
  • <area download> is a link too. Does it follow the same rule?
  • A link where the browser ignores download is not a download link. If the tests find one, it stays reported.

Security pass

This change makes a security check accept more. It needs the security pass that CLAUDE.md asks for before a change merges (Mechanism 7), with the browser results from step 1 as its evidence, and a review record in docs/security/reviews/.

Done when

  • A browser test records what Chromium and Firefox do for each way of using the link.
  • The rule matches that result, in the Rust check and its Python reference copy, with a test for each side.
  • The security page and the changelog say what a download link does under forbid.

Activity

  1. added
    next-sprint
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions