Stored XSS: $row['country'] inserted into HTML without escaping in index.php #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
index.phpembeds the storedcountryvalue directly into an HTML string passed toadd_footer()with no escaping:The
countryvalue originates from the externalipapi.coAPI response (fetched inget_country()inmessage.php) and is stored verbatim in the database.Location
index.php, line 33message.php, lines 22–38 (get_country()function)Risk
If the
ipapi.coservice is compromised, returns unexpected data, or an attacker somehow influences the stored country value, HTML/JavaScript in that value is rendered directly in every visitor's browser for that message. For example, a response like</small><script>alert(1)</script>would execute as script. This is a stored XSS via a third-party supply chain.Suggested fix direction
Escape the value at render time:
htmlspecialchars($row['country'], ENT_QUOTES, 'UTF-8'). Never trust data from external APIs when embedding into HTML.Severity
moderate
Found by
Automated audit by Claude Code