Skip to content

Decide whether Citry checks the scheme of link URLs set through c-bind #601

Open

Description

@JuroOravec

The question

Should Citry check or allowlist the scheme of a URL that data puts in a link attribute (href, src, action) through c-bind? Today it does not, like plain Vue, Jinja and Django. Citry UI (Citry's component library) checks the URLs it accepts. How should deep links be handled?

c-bind is the template syntax that spreads a Python dict of attributes onto an element. A deep link is a link that opens a native app, such as myapp://item/3. The scheme is the part before the first colon, such as https.

This is a design question about a documented default, not a report of a bug. The security page says in "Check URL attributes" that the app checks the scheme itself before it passes request data to one of these attributes, because a javascript: URL in a link runs when a visitor clicks it.

What happens today

  • Citry escapes a value for the place it lands, but it does not look at the scheme of a URL given to a plain HTML attribute.
  • The opt-in settings security_csp and security_javascript scan the finished page and report a javascript: URL in a link attribute, wherever the value came from. Neither is on by default, and neither sees what Vue builds in the browser from a binding such as :href.
  • The Citry UI components that take a link or an image URL refuse other schemes themselves: links accept a relative URL, http:, https:, mailto:, sms: and tel:.
  • actions.Redirect has its own scheme check since 0.7.0, and Add a helper to check that a redirect URL stays on the site #568 plans a helper that checks a redirect URL stays on the site.

Options

  1. Keep the default and the docs. Nothing changes. App authors check the scheme.
  2. Check by default. A value that data puts in a link attribute must be a relative URL or use an allowed scheme. For links the list would be http:, https:, mailto:, sms: and tel:, as in Citry UI. Image sources also need data:image/ and blob:, so src gets its own list. A setting lists more schemes for apps with deep links.
  3. Check when asked. The same rule, behind a setting that starts off, like the other output checks.

Questions to answer

  • Which attributes does the rule read? The output check already has a list: href, src, action, formaction, xlink:href, and data on <object>.
  • Which ways of setting them does the rule cover? c-bind is one. c-href="...", href="{{ ... }}" and a Vue :href carry data the same way, and a Vue binding cannot be checked on the server.
  • What happens to a refused value: the render raises ValueError, the attribute is dropped, or the render warns? Raising is easiest to find in a test; dropping hides the mistake.
  • Does the rule apply to a URL the template author writes literally, or only to a value that comes from a binding?
  • How does an app allow a deep link: a list of schemes, a list of full URLs, or a function it supplies? A setting that lists javascript should be rejected when the app is built, with ValueError.
  • How does the rule read the URL? It should read it as a browser does: leading spaces, tabs and line breaks the browser removes, and letters in any case (see Add a helper to check that a redirect URL stays on the site #568).

Security pass

Options 2 and 3 add or change a security check. They need a written plan and the security pass that CLAUDE.md asks for before a change merges (Mechanism 7), with every way a value can reach these attributes listed.

Done when

  • One of the three options is chosen, with the reason.
  • If a check is added: the rule is one function that every path calls (with and without Vue, and from a cached render), its refusal is tested for each attribute, and the security page describes it.

Activity

  1. added
    next-sprint
    on Nov 2, 2026
  2. JuroOravec commented on Nov 13, 2026

    @JuroOravec
    MemberAuthor

    Decision for 1.0: the current behavior stays. Citry does not check the scheme of a URL that data puts in a link attribute, and the app checks the scheme itself, as the security page says under "Check URL attributes". An opt-in scheme allowlist may come after 1.0, so this issue stays open for it.

    Two small follow-ups come with this choice:

    • Merge the four places that read a URL scheme into one function.
    • Add the missing sms: scheme to the security page.

    Both are listed in the 1.0 plan (#624). Neither is part of this decision, and neither is done yet.

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