Short background
I am currently in the process of designing a web-application where the user uploads some files to the server and then asks the server to do some calculations based on these files (task may be queued if the current workload is high). Then the server stores the result and makes it available for the user to view.
These files may contain private and/or sensitive data and therefore I decided to look into ways to keep these files secure on the server side.
I have done some research into this topic but not found the solution that I am looking for. I do have a general idea for the design, but I feel it is flawed and that I might be reinventing the wheel (lacking experience in this field).
I will start with the basic requirements, then present my idea and end with the questions i have.
Security requirements
- System must encrypt the files before storing on the file system
- System administrators etc must not be able to decrypt the files on their own (next requirement takes priority over this requirement)
- System must be able to decrypt the files only if user provides authentication
- System must support multiple simultaneous users with each user able to only authenticate decryption the files uploaded by that user.
Current idea
Storing the files in a way that decryption is possible only for the user seems quite straight forward. Currently I am thinking of the following workflow:
- User creates a public/private key pair (with some 3rd party tools)
- User uploads the public key to the system
- User uploads file (file stays in memory for now)
- System generates shared key for encrypting the file
- System encrypts the file with the shared key
- System stores the file
- System encrypts the shared key with the public key
- System stores the encrypted shared key
I believe this approach is quite common and does not have any serious draw-backs.
Now the problematic part. Since I want the user to be able to allow the system to decrypt the file in some situations then this is the only workflow I came up with:
- User starts a task that requires an encrypted file
- User uploads the private key (stays only in memory)
- System decrypts the shared key (stays only in memory)
- System deletes the private key from memory
- System decrypts the file into memory
- System deletes the decrypted shared key from memory
- System completes the task
- System deletes the decrypted file from memory
- System stores the task result
Questions
While I do believe that this approach would be functional, I am still worried about a couple of things:
- I am not sure if uploading a private key as a regular file can even be considered as a viable option? - If i'm not mistaken, then this at least goes against the usual norms.
- Can the private key be transferred securely over the internet? - I am inclined to believe that it can, however I have not jet looked into how exactly.
- Even if the encrypted file (or the private key) is only held in memory for the minimum time needed, would it still be a security risk? - I feel that it is still a risk, but not a serious one.
- Is this already a solved problem? - If so than I was unable to find the solutions
As a final remark I would like to add that I am fully aware that any such system would require trust from the users. Mainly I would like to know if this is achievable at all, is my idea viable and is there a better/alternative way?