Apache OFBiz's ProgramExport screen runs an attacker-supplied Groovy program. The script lives behind an auth-required URL and a substring deny-list. CVE-2024-38856 is the unauthenticated chain that goes through both gates without satisfying either. The patch is a three-line if (!security.hasPermission(...)) return at the top of the script; it addresses one of the gates and leaves the other one exactly as the developer who wrote it described it in November 2020.
CVE-2024-38856: Apache OFBiz's Auth Gate Saw `main`. The Renderer Ran `ProgramExport`.
vendor
patterns
cve
proof of concept
The auth gate inspected the path segment the attacker did not invoke
OFBiz routes requests through RequestHandler.doRequest. The vulnerable build (commit 0b26b915, in tree through 18.12.14) takes the request URI and pulls two distinct names out of it:
String overrideViewUri = getOverrideViewUri(path);getOverrideViewUri returns everything after the first path segment. For /webtools/control/main/ProgramExport, the first segment is main and the override view is ProgramExport.
The auth check then runs against the first segment:
if (requestMap.securityAuth) {
...
String checkLoginReturnString = (String) checkLoginEvent.invoke(...);
if (!"success".equalsIgnoreCase(checkLoginReturnString)) {
...
}
}In framework/webtools/webapp/webtools/WEB-INF/controller.xml, the main request-map declares <security https="true" auth="false"/>. Auth is satisfied trivially. The request-map for ProgramExport declares auth="true", but the handler never visits it. It visited main.
Then the view name is computed and rendered:
String viewName = (UtilValidate.isNotEmpty(overrideViewUri)
&& (eventReturn == null || "success".equals(eventReturn)))
? overrideViewUri : nextRequestResponse.value;overrideViewUri is ProgramExport. The view-map for ProgramExport in the same controller.xml:
<view-map name="ProgramExport" type="screen"
page="component://webtools/widget/EntityScreens.xml#ProgramExport"/>There is no auth attribute on view-maps in 18.12.14. The renderer reads the view-map, walks the screen widget, and executes the Groovy script the screen names.
The attacker named one URL segment to satisfy auth and a second URL segment to pick the renderer. The handler asked each gate about the segment that gate cared about, got the answer it wanted, and moved on.
The sandbox forbade exec. The Groovy lexer decoded \u0065\u0078\u0065\u0063 back into exec.
ProgramExport.groovy evaluates parameters.groovyProgram in a GroovyShell. Before the patch lineage that produced CVE-2024-38856, the sandbox between request body and shell.evaluate looked like this (commit 0b26b915, November 13 2020):
// TODO more can be added...
if (groovyProgram.contains("new File")
|| groovyProgram.contains(".jsp")
|| groovyProgram.contains("<%=")) {
request.setAttribute("_ERROR_MESSAGE_", "Not executed for security reason")
return
}By the build that shipped CVE-2024-38856, the gate had been promoted to a call into SecuredUpload.isValidText:
if (!org.apache.ofbiz.security.SecuredUpload.isValidText(groovyProgram, ["import"])) {
request.setAttribute("_ERROR_MESSAGE_", "Not executed for security reason")
return
}SecuredUpload.isValidText is a case-insensitive substring scan against a 32-token deny-list. Among the tokens: exec, import, runtime.getruntime().exec(, processbuilder. The implementation is one line:
private static boolean isValid(String content, String string, List<String> allowed) {
return !content.toLowerCase().contains(string) || allowed.contains(string);
}The PoC body, before any HTTP parsing, is:
groovyProgram=\u0074\u0068\u0072\u006f\u0077\u0020\u006e\u0065\u0077\u0020\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0028\u0027\u0069\u0064\u0027\u002e\u0065\u0078\u0065\u0063\u0075\u0074\u0065\u0028\u0029\u002e\u0074\u0065\u0078\u0074\u0029\u003bThat string is what isValidText sees. Lowercased and substring-scanned, it contains none of: exec, import, processbuilder, runtime.getruntime. The deny-list passes the string through to shell.evaluate.
GroovyShell.evaluate hands the string to the Groovy lexer. The lexer resolves \uXXXX escapes during pre-tokenization, before identifier tokens are formed. After pre-tokenization the source reads:
throw new Exception('id'.execute().text);Now there are tokens. Exception, execute, text. None of them existed when isValidText looked. The string the deny-list scanned and the program the lexer compiled are different artifacts. The deny-list looked at the first one and the lexer compiled the second one.
'id'.execute() is the Groovy idiom for spawning a shell, and .text reads stdout. The PoC throws the output back as an exception message, which OFBiz writes into _ERROR_MESSAGE_ and renders into the response body. The nuclei matcher pattern uid=\d+\(([^)]+)\) gid=\d+\(([^)]+)\) reads the result.
Source grep is not a sandbox. The deny-list inspects bytes, the interpreter compiles a program, and the bytes and the program are not the same artifact.
The // TODO more can be added... shipped in November 2020
Commit 0b26b915 introduced the new File / .jsp / <%= substring check. It was patching OFBIZ-12055, a Groovy-injection finding from an earlier disclosure. The first line of the if-statement is the comment:
// TODO more can be added...This is a TODO that shipped. The developer wrote a substring check, named it inadequate in the same commit, and pushed it. OFBIZ-12305 (2021) re-opened the same screen for a different bypass and re-tightened the substring list. OFBIZ-13128 (the CVE-2024-38856 ticket, July 2024) added the permission check inside the script:
if (!security.hasPermission('ENTITY_MAINT', userLogin)) {
return
}OFBIZ-13130 (August 2024) added auth gating to view-maps in RequestHandler so the override-view trick stops bypassing request-map auth:
if (viewMap.isSecurityAuth() && UtilValidate.isEmpty(userLogin)) {
...checkLoginEvent...
if (!"success".equalsIgnoreCase(checkLoginReturnString)) {
throw new RequestHandlerException(
"An active login is required for view with name [" + view + "]");
}
}Four JIRA tickets, four patches, four years, one screen. ProgramExport.groovy is the design debt driver: the patches address symptoms, the screen holds the primitive. The substring sandbox in SecuredUpload.isValidText is still the sandbox. The TODO that shipped on its first ancestor was written three years and nine months before CISA added CVE-2024-38856 to the Known Exploited Vulnerabilities catalog.
The patch closes this CVE. The substring sandbox is still the sandbox.
security.hasPermission('ENTITY_MAINT', userLogin) is the right check for who should run a Groovy script against the production delegator. The OFBIZ-13130 patch closes the override-view auth bypass for ProgramExport and for every other view-map whose request-map was supposed to be the auth gate.
What no patch in the CVE-2024-38856 cluster touches is the premise that string-matching tokens against attacker-controlled source is the way to keep a Groovy interpreter from running attacker-controlled programs. SecuredUpload.isValidText still ships, still scans the request body for the substring exec, and still hands the surviving string to a lexer that decodes \u0065\u0078\u0065\u0063 back into exec before any token is constructed. The next disclosure against ProgramExport.groovy will run the same line of the deny-list and lose for the same reason.
Both gates inspected an artifact the next stage did not act on, and both were documented as inadequate by the developers who wrote them three years and nine months before CVE-2024-38856 landed in KEV.