Umbraco Forms, Upload File.. any core protections against common exploits?

Would anyone know if UmbracoForms provides any out of the box protections for the file upload field?
Thinking things like checking that the supplied file restricted by extension looks like the filetype it says it is (string comparison or bytes?).

I did see the docs mention Server-side file validation | Umbraco CMS

But couldn’t see that anything out of the box was in the Umbraco Source Code, maybe we have something in Forms already leveraging that?

We are using blob storage on azure so may benefit from the Native malware scanning capabilities are available through Microsoft Defender for Storage

Wondered how others handled questions from clients re How are Umbraco Forms Upload Fields protected against common exploits?

Cheers for any insight. :slight_smile:

In the same link you posted it states

Umbraco supplies a FileStreamSecurityValidator that runs all registered IFileStreamSecurityAnalyzer implementations on the file streams it receives from it’s different file upload endpoints

I also had a quick look at File Upload | Umbraco Forms which states it uses IFileStreamSecirityValidator

The file upload field type will verify the file contents using the registered set of IFileStreamSecurityValidator instances.”

So to me it looks like the default out of the box behaviour for forms also includes IFileStreamSecurityAnalyzer as part of the security.

Yep I read the same, so the question is what out of the box IFileStreamSecurityAnalyzers are there… though as ever with security knowing what’s exisiting in and of itself provides a surface for probing.. :thinking:

Found some further discussion and advice here..
https://discord-chats.umbraco.com/t/27000095/scanning-file-uploads-in-umbraco-forms-azure-blob-configurat

Interesting topic!

Looking in the source code it seems like there is no implementation of that interface in the core.. :thinking:

Seems like maybe one have to go DIY,

This seems cool, either a docker container running clamav:

Or with Windows Antivirus:

1 Like

Umbraco doesn’t implement any IFileStreamSecurityAnalyzers in Forms or in Core - it’s up to you to implement if you want/need to. All forms does is validate the extension against allowed/disallowed types[1].

I’ve been round the houses a bit on this, and would recommend talking to the client about what kind of protection they want and being open about what’s there. Clients that care about infosec should have someone to help you work out what kind of protection they want/need.

Some clients will be happy to mitigate via scanning on infrastructure (which is more normal IME).

For one client we’re scanning binary signatures on upload, parsing PDFs and SVGs and stripping out exploitable elements etc. - lots of IFileStreamSecurityAnalyzers. But they’re a finserv and want a more belt-and-braces approach.

Bear in mind that once you start doing something with a file, as opposed to just writing the binary to storage, there’s every chance you’re introducing a new attack vector to your Umbraco site.


  1. From what I can see from decompiling the NuGet package. ↩︎

1 Like

Jason, thanks for sharing your valuable experience, to lean on you a little more… :slight_smile:

Would I be correct in assuming that as Azure blob storage doesn’t have windows defender and active real-time scanning as standard (paid extras) that having that binary in the blob store doesn’t allow for virus/malware execution. So to some extent we can lean on the clients existing internal protections against accessing any pdf/img on the web?

Also in the event of IFileStreamSecurityAnalyzer providing a positive hit, what’s the process here… does it bubble back up to UForms and stop the entire entry being written, give scope to blacklist the IP etc??
Or would we need to do that in a overriden uForms fieldType validation?

Not as standard, no - there’s an extra monthly cost plus a price per GB scanned. I know some people have hooked up AV scanning to to blob storage via the APIs but I don’t know details.

One approach I’ve used before is to spin off the whole upload responsibility into a microservice - a custom form field stores a GUID and some JS that handles posting the file to an endpoint (Azure function) that processed, validated and saved the file to blob storage. Those files never touched production infrastructure that matters.

Yes, exactly that. Users can treat form submissions just like any other random internet file they may come across - with suspicion. If files are attached to emails then they’ll likely get properly scanned so that’s a nice way to deal with it too.

All the registered IFileStreamSecurityAnalyzer 's are iterated by the IFileStreamSecurityValidator which is a validation step for Umbraco Forms and is carried out alongside checking the file extension is valid . Just like any other validator (say regex or whatever) it will reject the form submission and do nothing further until validation is fixed.

ASP.NET Core stores all posted files over 64KB as a temp file locally, nothing will happen with these files after the request and they’ll get cleaned up in Azure when the machine changes/restarts etc.

If you want to blacklist then yes, you will need to override the behaviour of the FieldType. I think the easiest approach is to override the ValidateField(), and check for the presence of the ErrorMessageForFailedSecurityCheck in the base method, then do any custom logic there before returning the list of errors.

1 Like