A critical flaw in one of the web’s most widely used open-source mapping libraries could let attackers run malicious code in a victim’s browser without any clicks, downloads, or logins required. The vulnerability affects MapLibre GL JS, an interactive mapping library used across an estimated 2.7 million websites and applications, and stems from a subtle bug in the very function meant to keep the library safe from this exact type of attack.
A Sanitizer That Skips Its Own Homework
The flaw, tracked as CVE-2026-85061, lives inside MapLibre’s DOM.sanitize() function — code specifically designed to strip out unsafe HTML attributes before content gets inserted into a webpage. Researchers found that the sanitizer works by looping through an element’s attributes using a live, constantly-updating browser object, while simultaneously removing dangerous attributes as it goes.
That combination creates a subtle but serious problem. Every time the sanitizer deletes one unsafe attribute, the remaining attributes shift into new positions in the list — but the loop’s counter simply advances to the next index regardless, rather than re-checking what just moved into the spot it already passed. The practical effect is that a malicious attribute placed directly next to another malicious attribute can slip through entirely unnoticed, because removing the first one bumps the second one into a position the sanitizer has already skipped past.
How an Attacker Would Exploit It
According to the GitHub Security Advisory documenting the flaw, an attacker could exploit this by crafting HTML containing two dangerous attributes back-to-back — for example, an element carrying both an open attribute and event-handler attributes like onload and ontoggle. The sanitizer might successfully strip one of these, but because of the index-shifting bug, fail to inspect or remove the one that shifts into its place. When MapLibre subsequently inserts the surviving content into the page through its map-attribution display, the leftover event handler can execute automatically — no user interaction required.
This is what makes the flaw a genuine zero-click vulnerability: it requires no authentication, no special privileges, and no action from the victim beyond simply loading a page that displays attacker-influenced map content. That puts any application pulling map styles, attribution text, or other mapping metadata from third-party or user-supplied sources squarely at risk, including services that let end users define their own custom map attributions without independently validating that input first.
What a Successful Attack Could Achieve
Because the flaw allows arbitrary JavaScript execution within the security context of the victim’s browser, the potential consequences extend well beyond a cosmetic map glitch. Depending on how the affected application is built, successful exploitation could enable theft of an active user session, unauthorized actions performed on the victim’s behalf, access to sensitive on-page data, silent redirection to a phishing page, or manipulation of what the map itself displays to the user.
The vulnerability carries a critical severity rating under CVSS v3.1, with a score reflecting network-based exploitability, low attack complexity, no privileges required, and zero user interaction needed — about as favorable a combination as it gets from an attacker’s perspective. It’s formally classified under CWE-79, the standard weakness category for cross-site scripting, or improper neutralization of input during webpage generation.
The Fix, and What Site Operators Should Do Now
MapLibre’s maintainers addressed the issue in version 6.4.1, which changes how the sanitizer iterates over an element’s attributes. Rather than working directly against the live, shifting attribute collection, the patched code first creates a static, unchanging snapshot of the attributes using a standard array-conversion method. That snapshot can then be safely inspected and have dangerous entries removed without altering the very collection the loop is iterating over — closing the index-shifting gap that made the original bug possible.
Organizations running MapLibre GL JS should treat upgrading to 6.4.1 or later as the priority action, since the flaw sits deep in the library’s internal sanitization logic rather than in application-level code that can be easily patched around. Recommended steps include:
- Upgrade all instances of maplibre-gl to version 6.4.1 or the latest available release without delay.
- Audit applications for any use of untrusted map style metadata or third-party attribution strings passed into MapLibre.
- Identify and review any features that allow end users to submit custom map attribution text, since these represent the most direct exposure path.
- As a stopgap while upgrades are rolled out, independently sanitize attribution-related input before it ever reaches MapLibre’s rendering pipeline — though this should not be treated as a substitute for patching.
With millions of users potentially exposed and no interaction required to trigger the flaw, security teams running web applications built on MapLibre GL JS should prioritize this update alongside any other outstanding critical patches this week.
Leave a Reply
You must be logged in to post a comment.