On Jan 22, 2022, a high severity SQL Injection vulnerability was reported in Casdoor which affected versions before 1.13.1 release. The vulnerability is tracked as CVE-2022-24124 with CVSS V3 7.5 score has a publicly available simple proof of concept which makes it easier for skilled attackers to manually craft advance SQL queries and exploit this vulnerability.
Qualys Web Application Scanning has released a new QID 150470 which sends specially crafted request to the endpoint being tested to determine the vulnerability. The crafted request concatenates a SQL injection payload to the parameter of the target application to confirm the possibility of exploitation. Once the vulnerability is confirmed by Qualys Web Application Scan , users can remediate the vulnerability by upgrading to Casdoor 1.13.1 or later version.
Casdoor is an Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0 / OIDC and SAML authentication.
According to GitHub Security Advisory Casdoor versions below 1.13.1 are vulnerable to this SQL Injection attack.
SQL Injection Analysis
The vulnerability exists in the query API due to insufficient validation of user-supplied inputs in
parameter, a remote attacker can trigger the vulnerability by accessing publicly available
endpoint inserting arbitrary SQL queries inside
The user input supplied to the
parameter is inserted into a raw SQL expression which in turn executes the query leading to a SQL Injection vulnerability. The researcher identified the vulnerability by examining the following line of code :
Looking at the code, it appears
is taking string data using
SQL wild card character and function
is formatting that data, details about the SnakeString function can be found inside
The vulnerability can be exploited by injecting XPATH functions ex. UpdateXML() or ExtractValue() inside the field parameter to generate error and get the query output.
The UpdateXML function in MySQL takes three arguments
UpdateXML(xml_target, xpath_expr, new_xml)
where an attacker can inject SQL query in the second argument which is XPath expression
Similarly, ExtractValue() function takes two string arguments
where the query can be injected inside second argument.
Whenever the XPATH query is having an incorrect syntax, we get presented with an error message dumping the output of SQL query :
XPATH syntax error: <output of query>
In the HTTP Response we can see output of
function inside the XPATH syntax error, however the output is truncated and displays limited characters in the response. A skilled attacker can bypass this restriction using function such as
which can be used to extract part of a string, from a specified offset with a specified length.
Qualys WAS has developed a PoC exploit which bypasses the limited character output restriction and dumps the entire contents of
file, similarly contents of sensitive files such as
can also be dumped from the application server :
Detecting the vulnerability with Qualys WAS
Customers can detect this vulnerability with Qualys Web Application Scanning using the following QID :
- 150470 : Casdoor SQL Injection Vulnerability (CVE-2022-24124)
On a successful detection, users shall see similar kind of results in the vulnerability scan report :
The vulnerability has been patched since Casdoor 1.13.1 by implementing a whitelist character check inside
function to filter the field parameter consists only upper-case, lower-case letters and numbers, this function has been added inside
Organizations using Casdoor < 1.13.1 are advised to upgrade to 1.13.1 or later version to remediate the vulnerability, more information regarding can be referred from GitHub Security Advisory and Casdoor SQLi issue.
GitHub Security Advisory :
CVE Details :
Credits for the vulnerability discovery goes to :
wuhan005 – https://github.com/wuhan005