Form scope missing after interrupted file upload

We have been investigating an error in our application that seems to be unique to Lucee that we had not previously seen in ACF. All values in the FORM scope are missing on occasion for a page that processes file uploads from a multipart/form-data POST.

We came across partial uploaded files in the lucee temp directory correlated with the errors leading us to dig into the Lucee form processing code.

We have been able to reproduce a similar issue using the following steps (it is a bit convoluted, my apologies):

  • Start up Fiddler, select Rules->Performance->Simulate Modem Speeds (this helps to slow things down so you can do the remainder of the steps)
  • Submit an upload with a form similar to the index.html below and a 20MB file. The size isn’t too important, the larger file just gives you time to shut down fiddler.
  • Exit fiddler to simulate a network exception

The behavior we are seeing is that in lucee.runtime.type.scope.FormImpl#initializeMultiPart the call to getItemIterator() is returning with an empty iterator because the network exception is swallowed by lucee.runtime.net.http.HTTPServletRequestWrap#storeEL. This causes the initializeMultiPart method to exit without setting any exception condition and an empty Form scope.

The request continues processing as if no issue had occurred but the Form scope has no values.

We played around with not suppressing the exception in storeEL(). In that case, the finally clause in initializeMultiPart will set an initException. That was better but still not ideal since the network exception is not discovered until a call to the cfform tag; references to the FORM scope are mysteriously empty until then.

I suspect the desired behavior would be to abort the request in the case of an incomplete POST because of a network exception, or to throw an exception that can be caught in CF code.

We can test for the missing FORM scope as an error condition but figured we’d share our research into the issue in case a Lucee behavior change is warranted.

Thanks.

OS: Windows 10
Java Version: 11.0.7
Tomcat Version: 9.0.11
Lucee Version: 5.3.8.206

index.html

<form action="processUpload.cfm" method="post" name="DocumentForm" enctype="multipart/form-data">
  <input type="hidden" name="SomeValue" value="1">
  <input type="file"   name="MediaFile">
  <input type="hidden" name="AnotherValue" value="2">
  <input type="hidden" name="YetAnotherValue" value="3">
  <input type="submit" value="Upload">
</form>

processUpload.cfm

<cflog text="Form element count: #ArrayLen(structKeyArray(Form))#" log="application" type="error">
<cflog text="request_method: #CGI.request_method#" log="application" type="error">

<cftry>
    <cfparam name="Form.MediaFile"> <!--- this won't exists since the Form scope is empty --->
    <cffile action="UPLOAD" filefield="MediaFile" destination="c:\temp" nameconflict="MAKEUNIQUE" attributes="Normal">
<cfcatch type="any">
    <cflog text="Upload error: #cfcatch.message#" log="application" type="error">
</cfcatch>
</cftry>

Check the app application.log for output
2 Likes

great bug report! it’s useful to include direct links to the code in question, i.e

can you file a bug in jira? https://luceeserver.atlassian.net/ (thanks for posting here first, much appreciated)

Case LDEV-3943 has been created for this.

2 Likes