A malicious SVG icon can run script in your visitors' browsers. This is cross-site scripting (XSS): code from an attacker running as if it came from your site. The ux_icon() Twig function puts the icon's SVG straight into the page without escaping, and the icon wasn't fully cleaned first.

Who is affected

Apps on symfony/ux-icons from 2.17.0 up to (not including) 2.36.1, or 3.x before 3.2.0, that render icons with ux_icon(). The Symfony UX advisory names two ways in:

  • Local SVG files, such as icons from a third-party theme or a downloaded icon set. Only some <script> elements were stripped, and event handler attributes like onload were kept.
  • Icons fetched on demand from Iconify, which is on by default. Those weren't cleaned at all, so a malicious or poisoned iconify.endpoint could inject script.

If every icon you use comes from a source you control and trust, the risk is low.

What to do

Update symfony/ux-icons to 3.2.0, or to 2.36.1 on 2.x. The fix cleans every icon, from any source, before it's rendered. It removes scripts, event handlers and dangerous URLs. Icons without any of those come out unchanged.

Reported by Pascal Cescon.