Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating temporary files and directories #306

Open
bjorn3 opened this issue Jul 31, 2020 · 5 comments
Open

Support creating temporary files and directories #306

bjorn3 opened this issue Jul 31, 2020 · 5 comments
Labels
feature-request Requests for new WASI APIs

Comments

@bjorn3
Copy link

bjorn3 commented Jul 31, 2020

No description provided.

@caspervonb
Copy link
Contributor

As far as I know, implementations will fallback to getenv("TEMP_DIR") as the base temp directory, do we need to provide anything else here?

@bjorn3
Copy link
Author

bjorn3 commented Aug 5, 2020

std::env::temp_dir() panics on WASI: https://github.com/rust-lang/rust/blob/dab2ae0404014b4fbc5a32a8c954fe6068b25f71/library/std/src/sys/wasi/os.rs#L169

@tschneidereit
Copy link
Member

As far as I know, implementations will fallback to getenv("TEMP_DIR") as the base temp directory

WASI implementations really shouldn't be doing this, nor should WASI explicitly sanction it, as that'd go against WASI's design principles: it'd make shared global state available to content implicitly. Whatever data other processes leave in that directory would now be accessible from within the sandbox.

Even if you solve that part by instead creating an isolated temporary directory just for this sandboxed content, there are still tricky issues: depending on the OS and configuration, you can do DoS attacks by writing large files. And you can gather information about the system by figuring out the free space, again by writing large files, but incrementally until you get an error.

We clearly should have support for temp_dir etc, but it'll probably have to come through an explicit capability the application needs to request.

@theduke
Copy link

theduke commented Jun 15, 2022

Chiming in here: I had the exact same idea.

Many applications really want/need temporary files, especially considering how important it is on Wasm to not blow up the memory usage, since allocated memory can't be reclaimed.

It would also be nice to specify a minimum required size and a requested size when creating a temp dir/file, and to ask the environment for size allowance.

What's the best way to push this forward? A concrete API proposal?

@bjorn3
Copy link
Author

bjorn3 commented Jun 15, 2022

Even if you solve that part by instead creating an isolated temporary directory just for this sandboxed content, there are still tricky issues: depending on the OS and configuration, you can do DoS attacks by writing large files. And you can gather information about the system by figuring out the free space, again by writing large files, but incrementally until you get an error.

That is already possible if you have any directory exposed to the wasi module. So maybe just have a --allow-tmpdir option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Requests for new WASI APIs
Projects
None yet
Development

No branches or pull requests

5 participants