Skip to content

item.icon is interpolated into markup on the Font Awesome paths #810

Description

@bbrala

Found while hardening selector handling for #731. Same defect family, different mechanism, and deliberately left out of that PR because icon is arguably trusted config rather than untrusted input.

Problem

src/jquery.contextMenu.js:1732 and :1742 build the icon element by string concatenation:

item._icon = $('<i class="' + item.icon + '"></i>');
// and
item._icon = $('<i class="fa ' + item.icon + '"></i>');

An item.icon value containing " or > breaks out of the attribute and injects arbitrary markup. This matters for any application that derives icon names from user-controlled or server-controlled data, for example a menu built from records where the icon is a stored field.

Suggested fix

Build the element and set the class without parsing, which is behaviourally identical for every legitimate value:

item._icon = $('<i></i>').addClass(item.icon);
// and
item._icon = $('<i></i>').addClass('fa').addClass(item.icon);

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions