How to make sure data is deleted from a tmpfs mount using Java?

49 views Asked by At

Given a tmpfs mount, how do I make sure everything I delete, cannot be recovered?

The service I am working on uses a tmpfs mount that is also shared with a few other services. I want to make sure that a file deleted from this mount cannot be accessed anymore.

On a traditional hard drive, I would use srm or shred. My theory is, that also for a tmpfs mount, I would need to overwrite the allocated space before actually deleting the file. To make sure, nothing stays in memory, I would overwrite the file with zeroes and then delete it (single pass, no random values).

A little more context

  • Files can be as large as 300 MB
  • The services are running a multi-tenant environment and it is important that data is only accessible for a limited amount of time.
  • The services sharing a single tmpfs mount are all exclusive to a single tenant, however there are multiple of these running on the same host (podman/docker).

I would like to mitigate the risk of an information leak in case memory contents can be read.

The main part of the service is running in Java, so my assumption is that the following alternatives should effectively do what I want

In both cases I would create a small byte[] and then call the write method multiple times to fill up the file in order to avoid creating a byte array as large as the file.

Does that make sense? Is there a recommended solution or anything that can be shared from experience?

0

There are 0 answers