Skip to content

Attribute interpolations in llm-advisor app.js skip escapeAttr #94

Description

@jamditis

Observed while fixing an unsanitized innerHTML sink in #89.

resource-kit/docs/llm-advisor/app.js defines escapeAttr at line 469 and uses it in four places. These four attribute interpolations do not use it, and each carries data that MCP tools can write into the JSON catalog:

  • line 604, data-next="${option.next}" — written by add_decision_node
  • line 607, data-track="${option.track || currentTrack}" — written by add_decision_node
  • line 657, data-model-name="${item}" — model names inside a terminal option's tools, written by add_decision_node. The adjacent button label on the same line does call sanitizeHTML(item), so the label is escaped and the attribute is not.
  • line 1005, id="model-card-${name.replace(/\s+/g, '-')}" — model names from model-info.json, written by update_model_info

A value containing a double quote breaks out of the attribute. None of the current catalog data does.

Line 1005 cannot be fixed on its own: getElementById at line 1024 rebuilds the same string with the same .replace to find the card, so escaping the id without changing the lookup would break the scroll-to-model behaviour when a model name contains an escaped character. Both sites have to change together, which is why this was not folded into #89.

Not introduced by #89. That PR added a new data source to a separate unsanitized innerHTML sink at line 975 and routed it through sanitizeRichHTML; these attribute sites are pre-existing and were found while sweeping for siblings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions