What is the best way to upload a file securely?
My client is a .NET Desktop Application and server is Apache Tomcat running JSP Files, running on a Linux OS.
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.Sign up to join this community
You can normally upload the file using standard HTTPS way, however, exposing application server for uploads is always very risky. Especially if the application server has a lot of libraries built-in and so on. So ideally:
On top of that, you can encrypt the file itself. If it's .NET application, it could be dedicated (per app instance, e.g. per customer) pre-shared symmetric key which is not stored on the destination server, so the file is copied from the upload Tomcat instance to another, isolated instance where it is decrypted. Regarding pre-shared keys, it's not the best way, so you can use another Tomcat instance as Key Server. Having client certificate already, you can connect to Key Tomcat Instance and request one-time symmetric key, and the decrypting Tomcat Instance will re-request this key during decryption.
You can bypass the extra upload server if you trust your Main Tomcat. However, using HTTPS and Key Server with encryption is really recommended if upload needs to be secure. Also, the stored file might remain encrypted and the Main Tomcat server might not need / be able to query the Key Server at all.
This way, if your upload server gets compromised, the files are unreadable. If your key server gets compromised, the files are not readable either. Reducing the attack surface is the main thing. Use cheap Tomcat hosting to achieve that. Use JRE8 with G1GC to reduce memory usage. Use streams and don't load files into RAM.