XSS via unescaped data injected into map.php script block and Leaflet popup #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
map.phpembeds PHP data directly into a<script>block usingjson_encodewithout theJSON_HEX_TAGflag. PHP's defaultjson_encodedoes not escape<and>, so atakenAtvalue containing</script>in the BeReal export JSON would terminate the script tag and allow injecting arbitrary HTML/JavaScript into the page.Additionally, the Leaflet popup HTML is built by raw string concatenation on the JavaScript side with no sanitization:
bindPopupinterprets its argument as HTML, so any HTML inp.atis executed as markup.Location
map.php— PHP JSON embedding (~line 22):And the JavaScript popup builder (~lines 33–36).
Risk
A maliciously crafted BeReal export with an invalid or injected
takenAtfield (wherefmt_date()falls back to returning the raw string) or a field containing</script>could inject and execute JavaScript in the browser of whoever views the map page. For a local viewer this is lower severity, but it violates the principle that data from the export should never reach the DOM unescaped.Suggested fix direction
Add
JSON_HEX_TAGto thejson_encodecall so<and>are emitted as</>. On the JavaScript side, usedocument.createTextNode/.textContentassignments or a safe templating approach instead of HTML string concatenation for popup content.Severity
moderate
Found by
Automated audit by Claude Code