Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

What we learned running untrusted GitHub repos in the browser

You find an interesting project on GitHub. Before you can tell whether it's any good, you have to clone it, install the dependencies, fix whatever version conflict appears, maybe set up a database, and then read the READ

You find an interesting project on GitHub. Before you can tell whether it's any good, you have to clone it, install the dependencies, fix whatever version conflict appears, maybe set up a database, and then read the README again to find the start command. Most of the time, people give up somewhere along the way.

We built Repospin to remove that step: paste a public repo (or click a "Try it live" badge in its README) and the app starts in a private sandbox in your browser. No login, no install. Each demo lives for 10 minutes and is then deleted.

👉 Try a real one: a stock dashboard with live data

This post is about what it takes to make "one click" true for code you have never seen before, written by people you don't know, and what broke along the way.

The pipeline

Every demo goes through the same four steps:

  1. Fetch the repo at its current commit (a tarball, no git clone).
  2. Detect how to start it, by reading files only. Nothing from the repo runs at this stage.
  3. Build it in a sandbox that can only reach package registries.
  4. Run it in a second sandbox with no internet, and proxy the visitor's browser to it.

Builds are cached by commit, so the second visitor gets a running app in about two seconds.

Detection: reading code without running it

Detection looks for the usual suspects: import streamlit, gr.Blocks(...).launch(), Dash(__name__), FastAPI(), Flask(__name__), a Django manage.py, a package.json with next, vite or express, and so on. A few lessons:

  • Prefer the visual app. Plenty of repos contain both a dashboard and an HTTP API. Our first version started whichever file it found first, and visitors got {"detail":"Not Found"}. Now a UI framework anywhere in the repo wins, and an API-only repo opens its /docs page so you can still try it.
  • Libraries are not apps. A file named app.py inside a Python package is usually library code. Treating every module as a possible entry point produced a lot of nonsense starts.
  • Have an escape hatch. A repospin.yml with type: custom, an install line and a start command covers everything detection can't guess.

Sandboxing: assume every repo is hostile

Both sandboxes run under gVisor (runsc), which gives each container its own user-space kernel. On top of that:

--read-only root filesystem      --cap-drop ALL
--security-opt no-new-privileges --user 10001
--pids-limit, --memory, --cpus   --tmpfs /tmp (size-limited)
network: internal-only, no container-to-container traffic
  • Builds can reach PyPI, npm and GitHub through an allowlisting proxy and nothing else. A malicious setup.py that tries to phone home simply gets refused.
  • Running demos have no internet, except an allowlist of public, keyless data sources (stock prices, crypto prices, Hugging Face models, weather). Without that, half of all dashboards show nothing but error messages. The proxy refuses private and loopback addresses, so a demo can't use it to reach the host.
  • Crypto miners get noticed quickly: a demo that keeps its CPU limit pegged is stopped, and a repo that gets stopped three times is blocked.

The hard parts nobody warns you about

Apps listen wherever they like. You can ask for $PORT=8080; you will get Dash on 127.0.0.1:8050, Express hardcoded to 3000 and a Bottle app on 127.0.0.1:9999. The fix was a tiny forwarder that runs inside each sandbox next to the app. It reads /proc/net/tcp to find whatever port the app actually opened (including localhost-only ones) and forwards to it.

Old projects need old Pythons. A repo pinning numpy==1.24 simply won't install on Python 3.12. We switched builds to uv, which can fetch older interpreters. The Python version comes from .python-version, requires-python or known old pins, and a failed install automatically retries on 3.11 and then 3.10. As a bonus, uv made installs several times faster.

READMEs lie by omission. Requirements files regularly forget packages the code imports. A build step parses every .py file's imports (AST only, nothing executes), drops the standard library and the repo's own modules, and installs the rest under their PyPI names (cv2 → opencv-python-headless, sklearn → scikit-learn, ...).

Apps need databases. Instead of wiring up separate database containers, Postgres, MySQL and Redis start inside the app's own sandbox, on localhost, empty for every demo. The app gets the usual DATABASE_URL, REDIS_URL and friends, and Django, Flask-Migrate and Prisma migrations run before start. No extra network, nothing shared between visitors.

"It started" is not "it works". Streamlit renders script errors in the browser, so the first page load always looks fine. Our repo checker now runs each Streamlit script once with Streamlit's own AppTest inside the sandbox and fails apps that raise errors, show an error box with a real problem, or render nothing at all.

gVisor and docker commit disagree sometimes. With gVisor's default in-memory overlay, committed build images came out empty, so builds use a runtime with the overlay disabled. Even then, packages that replace themselves during install (pip upgrading pip, for example) could leave Docker's layer diff confused. Building with uv, plus a retry, made that go away.

The honest numbers

We regularly scan GitHub for Streamlit, Gradio, Dash, Flask, FastAPI, Django and Next.js projects. Of roughly 300 recently updated repos:

  • About 265 were skipped without building: libraries, tools that need paid API keys or GPUs, monorepos, apps that need MongoDB or Firebase.
  • Of the rest, about half run as live apps without any changes to the repo.
  • The failures are mostly the repos' own problems: code that needs a newer library than its own pins install, data files missing from the repo, or apps that only work with a specific cloud account.

So "run any repo as an app" is not realistic. What is realistic is that every repo opens: when something can't start as an app, Repospin opens it as VS Code in the browser instead, with the code, its README and a terminal, dependencies already installed.

Try it

  • Paste any public repo: repospin.dev
  • Maintainers: add the badge to your README so visitors can try your project instantly:
[![Try it live](https://repospin.dev/badge.svg)](https://repospin.dev/r/OWNER/REPO)

It's free for public repositories. If your repo doesn't start, leave a comment with the link: we read every one, and each failure makes the detection better for everybody.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.