Security: what the IDE backend can access¶
Audience: administrators and security reviewers · about 5 minutes · Prerequisites: Security and privacy
What the IDE backend can access¶
The Theia backend (the Node process started by npm start, or built into the desktop app) runs with your
user's permissions. Through it, the IDE can read and write files, run git, run your programs and tests, load
plugins, and open a terminal. There is no login: whoever can reach the port can use it.
What protects it:
- Localhost binding. The
npm startscript passes--hostname 127.0.0.1, so only your own machine can connect. - Request checks. struktJS's own API (
/api/struktjs/*) only accepts requests whoseHostis a loopback name (or listed in theSTRUKTJS_ALLOWED_HOSTSenvironment variable), rejects requests from a different web origin, requires JSON bodies, and sends no permissive CORS headers. This blocks a web page you visit from driving the API (including through DNS rebinding). There is deliberately no access token, because any token a page could fetch from the same origin would also be fetchable by such an attacker. - File path limits. File requests must use absolute paths that, after resolving symlinks, are not inside credential and system folders:
~/.ssh,~/.aws,~/.gnupg,~/.kube,~/.docker,~/.azure,~/.netrc,~/.npmrc,~/.pypirc,~/.git-credentials,~/.password-store,~/.config/gcloud,~/.config/gh,~/.config/op,~/.config/1Password,~/.config/doctl,~/.config/helm,~/Library/Keychains, and system folders such as/etc. SettingSTRUKTJS_ALLOWED_ROOTSfurther limits access to the folders you list. Language files, git arguments, test patterns and plugin folders are validated. - Git hooks. A repository can ship hook scripts (
.git/hooks/*) andcore.fsmonitorsettings that run code. Every git command the IDE runs hascore.fsmonitordisabled, and hooks are disabled for everything the Git pane does exceptcommitandpush(includingcheckout,stash,merge,revert,pull,switch,worktree,rebaseandcherry-pick). Commit and push still run yourpre-commit,commit-msgandpre-pushhooks, so do not commit or push from a repository you have not inspected. Git started from the integrated terminal or a VS Code extension's own source-control view is not covered.
What localhost binding and the request checks do not stop
These controls stop web pages and other machines. They do not stop another program running on your
own machine that can open a connection to 127.0.0.1: such a program sends the right Host header and no
web origin, so it passes. That matters wherever unrelated processes share your loopback interface: WSL2 with networkingMode=mirrored, Docker with --network=host, and some corporate VPN or security drivers. Theia's own services (terminal, file system) are equally open to such a process, and Theia's connection cookie is handed to any plain HTTP request, so a script can fetch the page, take the cookie and connect. If you use
one of those setups, either turn on the launch token below, or do not run untrusted install scripts
(npm install of unreviewed packages) on the same network namespace as a running IDE, or run the IDE
inside the container or VM you trust.
Launch token (on by default)
The browser IDE (npm start) requires a launch token unless started with STRUKTJS_REQUIRE_LAUNCH_TOKEN=0
(npm run start:open does this for development). The backend creates a random secret that exists only in
memory and in a launch URL printed in the terminal (Launch token required. Open: http://127.0.0.1:PORT/?strukts_token=...).
Opening that URL sets an HttpOnly, SameSite=Strict cookie and removes the secret from the address bar;
every page, API call and WebSocket connection without that cookie is refused. A program that cannot read the terminal output or your browser's cookies can no longer drive the IDE. Open the printed URL each time the IDE starts; automated browser tests need it or the opt-out. The desktop app uses Electron's own token instead.
Do not expose the backend to a network
Binding the IDE to 0.0.0.0, forwarding its port, or putting it behind a reverse proxy gives everyone who
can reach it the ability to run commands as you. For remote access for yourself, use an authenticated tunnel or VPN. To collaborate, expose only the collaboration relay (see Collaboration and the relay), never the IDE. To run the IDE as a server for a company, follow Deploying the server: a container per person or trusted team, behind your own login, never on the open internet.
Two limits remain: the backend has no notion of "the open workspace" (the deny-list above is the confinement), and rule code is not sandboxed (Security and privacy).
Running programs¶
A Core program is generated as Python and run on a real interpreter; where that interpreter lives decides what it can reach.
- Python on this computer (used by the Automatic Python runtime preference when it exists): the backend starts
python3as a child process with your permissions, like a terminal, so the program can read and write your files, start programs and use the network. The debugger, coverage and the Test Language's assertions run the same text. - Built-in Python (Pyodide), CPython compiled to WebAssembly, runs in a background Web Worker. It has no direct access to your files (only an in-memory file system that disappears with the run) and cannot reach the page's DOM or
localStorage. It is not a network or origin sandbox: a program canimport jsand usefetchand IndexedDB like any script of the page's origin, and requests to that origin carry the page's credentials, in the IDE including the backend's HTTP interface. It runs Python without installing it; it does not make untrusted code safe. In the command-line tool it runs in a Node worker thread, also not a security boundary. - Limits protect against accidents, not attackers: a run stops after 30 seconds of computing, closing the tab ends it, and a stopped Pyodide run has its worker terminated.
- Nothing is downloaded without asking. The Pyodide runtime (about 10 MB, from jsDelivr) is fetched once after a consent dialog that offers Cancel first, with no user or project data; an organisation can point the page at its own copy (
__STRUKTJS_PYODIDE_URL__). The deep linkrunaction always asks before running anything.
Collaboration and the relay¶
Live collaboration connects through a relay you choose. The default is a local relay at http://localhost:8100/; nothing contacts the public Open Collaboration relay unless you type its URL.
- Session content is end-to-end encrypted between peers; the relay sees who is connected and message metadata, not decrypted model content. Keys use RSA-OAEP (4096-bit) and content AES-256-CBC, which does not authenticate data: the guarantee is confidentiality, not tamper-evidence. Without a secure context (HTTPS or localhost) encryption is unavailable unless you opt in to the weaker fallback on the collaboration page.
- Relay URLs must be
https://orwss://; plainhttp://orws://is accepted only for loopback addresses, and URLs with embedded credentials are refused. Join links contain a relay URL and joining connects to whatever it names: the confirmation shows it and warns if it is not your configured relay. Join only from people you trust. - Hosts approve every join. There is no way to remove someone after they joined and no read-only mode, so treat peers as trusted. If a link was shared too widely or a peer's machine is compromised, end the session and start a new one (new link and keys).
- Data from peers is validated before it touches your model (node-name syntax, depth and size limits) and names and colours are sanitized, but a peer can edit anything in the shared model, including text later rendered as Markdown or HTML (sanitized as described in Security and privacy) and
js()calls in a program you then run: review a shared program before running it. A session shares one model only and never transfers.lang.jsfiles or plugins. A name is not proof of identity: comment authors can be spoofed.
To collaborate across machines, put the relay behind TLS and share its https:// URL (Running the collaboration relay locally).
The desktop (Electron) app¶
The desktop build uses the same backend, so everything above about files, git and the terminal applies. It blocks in-app navigation (links open in your browser), denies <webview> attachment and runs the renderer with Electron's sandbox and context isolation on and Node integration off; the page can still reach the backend through the same local API, so script injection into it is as serious as described above.
Updates. The app can check for a new version only from an update server someone configured for your installation (an administrator's policy file, an environment variable or the customer build); the standard download has none and contacts nothing. The address must be https://, the app asks before downloading and again before restarting, and an administrator can turn updates off (Updating and uninstalling). Installers are signed (and on macOS notarized) only when the maintainers configured signing certificates for that release; otherwise they are unsigned and not notarized and your OS may warn. Every release lists a SHA-256 checksum per installer (SHA256SUMS-*.txt) and publishes CycloneDX bills of materials; compare the checksum before installing, and install only builds you made yourself or got from a source you trust.