Page MenuHomePhabricator

Sandboxing Strategy for Wikifunctions
Closed, ResolvedPublic

Description

This is a top-level task to capture discussion surrounding sandboxing strategies for the Wikifunctions executor, which runs untrusted code from contributors (honeypot-as-a-service).

This discussion began on the #talk-sre Slack channel: https://wikimedia.slack.com/archives/CTFK3B423/p1691507756371529

Our top-level process is an Express service which needs certain permissions. In addition to receiving REST requests, it must delegate the execution of untrusted code to programming language interpreters (currently, just node and python, although we plan to support other languages in the future). It does this by spawning a subprocess.

Our goal is that the subprocess have far fewer rights than the top-level process. In particular, it should not be able to read or execute anything on the file system.

Solutions we have considered:

  • WASM to run all programming language binaries (suggested originally here);
  • LD_PRELOAD to intercept specific syscalls;
  • seccomp to limit the permitted syscalls (if this is possible to implement at the process level);
  • special sudo-er (would need special support in Blubber): we create a nobody user who can't do anything, and we give the runuser sudo power ONLY to call setuid(nobody)

Event Timeline

cmassaro updated the task description. (Show Details)

Question for RelEngers, especially @dduvall when you're back, would it be a reasonable ask for Blubber to let the runuser drop permissions down to the un-priv'ed nobody user account? Happy to create a sub-task if yes.

https://code.google.com/archive/p/seccompsandbox/wikis/overview.wiki seems like an interesting short-to-mid-term solution - or an inspiration for a solution- for the protections you're interested in.

Thinking more about this, I think compiling a javascript and python interpreters to wasm, include those in your containers together with a wasm runtime would be our best option even on the short-ish term.

It's by far the best sandboxing experience and while it wouldn't be the "ideal" architecture to run generic programs compiling them to webassembly, it would give us all the sandboxing advantages.

Jdforrester-WMF changed the task status from Open to In Progress.Aug 24 2023, 3:24 PM
Jdforrester-WMF assigned this task to cmassaro.
Jdforrester-WMF triaged this task as High priority.
Jdforrester-WMF moved this task from To Triage to In Progress on the Abstract Wikipedia team board.

Change 966868 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Update evaluators to WASM images

https://gerrit.wikimedia.org/r/966868

Change 966868 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Update evaluators to WASM images

https://gerrit.wikimedia.org/r/966868

Change 966898 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Temporarily add WASM JS service for testing

https://gerrit.wikimedia.org/r/966898

Change 966898 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Temporarily add WASM JS service for testing

https://gerrit.wikimedia.org/r/966898

Change 967246 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Bump evaluators to noisy-logged ones

https://gerrit.wikimedia.org/r/967246

Change 967246 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Bump evaluators to noisy-logged ones

https://gerrit.wikimedia.org/r/967246

Change 968722 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Switch JS evaluator to WASM, drop staging copy

https://gerrit.wikimedia.org/r/968722

Change 968722 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Switch JS evaluator to WASM, drop staging copy

https://gerrit.wikimedia.org/r/968722