Skip to content

Warden skill: detect unsafe URI rendering in HTML templates #843

@sentry-junior

Description

@sentry-junior

Summary

PR #842 fixed a stored XSS in the OAuth approval dialog where client_uri, policy_uri, and tos_uri fields were rendered as clickable href attributes without validating the URI scheme. javascript: URIs bypassed HTML escaping entirely. The fix added an allow-list (sanitizeHrefURL) restricting schemes to http/https.

This class of bug — untrusted string → href without scheme validation — is easy to miss in review and should be caught automatically via a Warden rule.

Current behavior

No static analysis or Warden rule exists to flag patterns like:

// dangerous: href value from external input without scheme validation
`<a href="${uri}">`

Gap

HTML-escaping does not protect against javascript: URIs. Any place where user-controlled or API-sourced strings are interpolated directly into href, src, or action attributes is a latent XSS vector that code review can silently miss.

Options

  • Warden semgrep rule — pattern-match template literals or string concatenation that feeds into href/src/action without passing through an allow-list sanitizer. Flag for human review.
  • ESLint plugin (e.g. eslint-plugin-no-unsanitized) — enforce at lint time in CI; blocks merges rather than async Warden alerts.
  • Both — Warden for existing codebase sweep + ESLint for ongoing enforcement.

Recommendation

Ship a Warden rule first for a broad sweep across the codebase, then layer in an ESLint rule (or extend the existing config) so new instances are caught at PR time before merge.

Action taken on behalf of David Cramer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions