Arbitrary SQL query execution and reflected XSS in the "SQL Query Form"
The SQL Query Form module accepts a Base64-encoded SQL query in a GET parameter, allowing an attacker to execute arbitrary SQL if an authenticated admin clicks a crafted link. The same parameter reflects unencoded MySQL errors, enabling reflected XSS that can also read query results.
- Fixed in 14 days
- Disclosed after 44 days
Hello,
The mentioned module is vulnerable to SQL injection due to the fact that a query can be done in a GET request, with the query is Base64 encoded and supplied as the value of the parameter "thequery".
This allows an attacker to perform arbitrary SQL queries if they trick an authenticated admin to click a specially crafted link, which can have devastating outcomes, including the deletion/dropping of whole records/databases, the insertion of new data, etc, following is a PoC:
With c2VsZWN0ICogZnJvbSBleHBfbWVtYmVycw== as the Base64 encoded form of select * from exp_members.
Also, the same GET parameter is vulnerable to reflected XSS, which originates from the fact that MySQL errors get thrown unencoded when a malformed SQL query is processed. This, in combination with the previously mentioned flaw, can make an attacker not only capable of executing arbitrary SQL queries, but also able to read whatever data is returned from a query, in addition to the normal attacks that can be done with an XSS, following is a PoC:
Where c2VsZWN0IDxzdmcgb25sb2FkPWFsZXJ0KDEpPg== is the Base64 encoded form of select <svg onload=alert(1)>.
Regards
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application accepts a Base64-encoded SQL query via a GET parameter and executes it without proper authorisation or input validation, and it reflects raw MySQL error messages without encoding.
Impact
An attacker could execute arbitrary SQL queries, leading to data deletion, insertion, or disclosure, and could run script in the admin's browser to read query results and perform other XSS attacks.
What the attacker needed
Victim is an authenticated admin; victim clicks a crafted link
How it was found
- Craft a URL to the admin query page with the 'thequery' parameter set to a Base64-encoded SQL statement.
- Trick an authenticated admin into clicking the crafted link.
- The SQL query executes, allowing data deletion, insertion, or reading.
- For XSS, supply a Base64-encoded malformed SQL query containing an SVG with an onload handler.
- The resulting MySQL error is reflected unencoded, executing the script in the admin's browser.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web page lets an admin run database queries, but it also accepts the query from the web address (URL) instead of a form. An attacker can build a link that contains a hidden database command; if an admin clicks it, the command runs with the admin's permissions. The same link can also inject a script that runs in the admin's browser.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.