Summary
A DOM-based cross-site scripting vulnerability in MapLibre GL JS can allow a dangerous event-handler attribute to bypass attribution sanitization. If an attacker controls an untrusted style attribution or custom attribution string, script may execute when a victim renders the affected map.
Affected context
The issue occurs in MapLibre GL JS attribution controls when untrusted attribution content is sanitized before being inserted into the page with innerHTML. It is relevant where third-party styles or user-supplied custom attributions can contain consecutive dangerous attributes and a victim loads the resulting map content.
Exploit preconditions
- Attack surface: Browser-side attribution rendering in MapLibre GL JS
- Required access: Ability to control or influence a style attribution string or custom attribution value
- Trigger point: Rendering the attribution control and inserting sanitized content into the DOM
- Victim interaction: A victim must load or otherwise render the affected map content
- Why exploitation is possible: DOM.sanitize() iterates a live NamedNodeMap while removing attributes, allowing an adjacent dangerous attribute to be skipped
Why this happens
The vulnerability results from modifying a live DOM attribute collection while iterating over it by index. When removeAttributes() deletes an attribute from the same collection being traversed, later attributes shift positions and an adjacent dangerous attribute may not be inspected. This insecure sanitization pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-influenced markup can reach an HTML insertion sink without reliable neutralization.
Potential impact
- Arbitrary JavaScript execution in a victim's browser
- Theft of accessible application data or session information
- Unauthorized actions performed in the victim's authenticated context
- Defacement or manipulation of map-related interface content
- Exposure of other data available to the affected web application
General mitigation guidance
Mitigation generally focuses on making DOM sanitization independent of mutable collections and reducing trust in attribution content.
Common defensive patterns include:
- Use a proven HTML sanitization mechanism with a strict allowlist for elements and attributes
- Avoid inserting untrusted attribution content through innerHTML when text-only rendering is sufficient
- Snapshot or safely traverse attribute collections before removing entries
- Explicitly reject event-handler attributes and other executable markup
- Treat third-party style metadata and custom attributions as untrusted input
- Apply a restrictive Content Security Policy as defense in depth
- Limit the privileges and sensitive data available to pages that render external map content
How teams detect issues like this
Organizations can detect similar issues through:
- Static analysis rules for innerHTML and other HTML insertion sinks
- Code review checks for sanitizers that mutate live DOM collections during iteration
- Tests containing adjacent dangerous attributes and mixed benign and dangerous markup
- Browser security testing that verifies event-handler attributes cannot survive sanitization
- Dependency and policy checks for vulnerable client-side libraries
- Content Security Policy violation monitoring and browser telemetry
Automated security review tools may help identify unsafe DOM sinks and incomplete sanitization logic, but should be supplemented with focused behavioral tests.

