Skip to content
Discussion options

You must be logged in to vote

If this is meant to handle untrusted SVG, the bar is “no executable surface left”. Removing “unsafe” or “non-standard” elements is not sufficient.

Key requirements:

  1. Whitelist, not blacklist

    • Explicit allowed tag list (svg, g, path, rect, circle, defs, linearGradient, etc.).
    • Explicit allowed attributes per tag.
    • Drop everything else.
      “Non-standard” ≠ unsafe. Many standard SVG features are executable.
  2. Eliminate all script vectors

    • Remove <script>, <foreignObject>, <iframe>, <object>, <embed>.
    • Strip all on* attributes (onload, onclick, etc.).
    • Reject any attribute value starting with javascript:, vbscript:, data:text/html.
    • Validate href / xlink:href strictly.
  3. Block external resource lo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MathiasReker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Security Build security into your GitHub workflow with features to keep your codebase secure Question Ask and answer questions about GitHub features and usage
2 participants