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

Implement sandbox(es) for Windows #83

Open
minhnhatnoe opened this issue May 15, 2023 · 3 comments
Open

Implement sandbox(es) for Windows #83

minhnhatnoe opened this issue May 15, 2023 · 3 comments
Labels
cat:worker Related to the back-end worker enhancement New feature or request go Pull requests that update Go code priority:low Low priority: Mostly for the future

Comments

@minhnhatnoe
Copy link
Contributor

Is your feature request related to a problem? Please describe.

It seems like an open-source sandbox for competitive programming has yet to appear. If kjudge is to support Windows, native sandboxing is a must.

Describe the solution you'd like

Below are a few solutions that can be considered.

Temporary user account

Create a temporary user account for executing the code. This account will have very limited access to file and folders present on the user's machine. Memory limits and other restrictions will be enforced using Windows Job Objects. This seems to be the solution used by many judging systems.

Advantages

Compatibility: Compatible with every Windows version known to man in use.

Disadvantages

Reinventing the wheel: This solution will require excessive penetration testing.

Vulnerable to tampering by outside apps: This is a half of the sandbox's purpose. Also, AVs such as Kaspersky are notorious for deleting compiled executables, simply because they do not have a certificate.

Security through obscurity: This is essentialy patching every hole manually, so chances are it can not be open-sourced.

Chromium sandbox

See here for the introduction of the Chromium Sandbox. In short, this sandbox is for running renderers, which are exposed to untrusted data and can be compromised.

Advantages

Should be easy enough to use.

Safe

Disadvantages

There is no documentation for this sandbox. Since memory limits and time limits are not implemented, we will have to configure the call to Windows Job Objects.

HCS/Moby

See HCSShim and Moby for details. In short, we are basically firing up Docker Containers for every test.

Advantages

Safe

Behaviour similar to isolate: the Host Compute Service (HCS) was created with the intention to imitate linux's cgroups and other access-limit services, which is how isolate functions.

Has half-decent docs: The docs generated on pkg.go.dev is sufficient to understand the inner workings of the code.

Disadvantages

Big code size: I haven't looked into the actual size of the executable, but I imagine it wouldn't be very lightweight.

@minhnhatnoe minhnhatnoe added the enhancement New feature or request label May 15, 2023
@natsukagami
Copy link
Owner

Also check DMOJ's old sandbox https://github.com/DMOJ/judge-server/tree/v1.4.0. They dropped Windows later on.

@natsukagami natsukagami added cat:worker Related to the back-end worker priority:medium Medium priority: Mostly for next minor go Pull requests that update Go code labels May 15, 2023
@natsukagami
Copy link
Owner

I'm thinking of keeping isolate and running under Docker/WSL for now, too much to do for a priority:medium thing.

@natsukagami natsukagami added priority:low Low priority: Mostly for the future and removed priority:medium Medium priority: Mostly for next minor labels May 29, 2023
@minhnhatnoe
Copy link
Contributor Author

I'm thinking of keeping isolate and running under Docker/WSL for now, too much to do for a priority:medium thing.

Me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:worker Related to the back-end worker enhancement New feature or request go Pull requests that update Go code priority:low Low priority: Mostly for the future
Projects
None yet
Development

No branches or pull requests

2 participants