Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ cluster_test.zip
/site
docs_old/**/*
docs_old/
docs/dev-guide/server-plugin-research.md
test_sc/
src/REvoDesign/UI/Ui_REvoDesign.py
# loopkit — keep installable scaffolding, ignore runtime artifacts
Expand All @@ -153,3 +154,7 @@ playground/config
4MB8_GREMLIN_mtx_zscore.png
/mutagenese
/temperal_pdb
# security audit working doc (internal, not a deliverable)
/server/security-audit-tracking.md
server/manage.sqlite
server/revocompute.sqlite3
165 changes: 134 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **Server auth hardening**: API keys are now stored as indexed sha256
digests (`api_key_digest`) with single-lookup validation; legacy KDF
hashes migrate over with existing keys invalidated by design. CAPTCHA
nonces and rate-limit counters are Redis-first with per-process in-memory
fallback when Redis is down — login/register/captcha endpoints never break
on a Redis outage. The rate limiter no longer re-executes the endpoint
when a Redis call fails mid-request.

### Removed

```
## [Unreleased]

### Added
- **Upload content validation**: uploaded inputs are now content-checked by
extension (FASTA/A3M/PDB/mmCIF/JSON) with generous DoS caps, so third-party
parsers never see pathological files. Previously only GREMLIN FASTA inputs
got a first-line `>` check; non-GREMLIN inputs were checked by extension and
a 4096-byte binary sniff alone. NUL bytes beyond the sniff window, gzip
streams disguised as PDB, degenerate record counts, and JSON bombs are all
rejected at upload time.
- **ESM-MSA-1b variant-effect task** (`esm_msa`): masked-marginal
per-position profile over an uploaded a3m alignment, using
`esm_msa1b_t12_100M_UR50S`. Outputs `msa1b_profile.csv` and
`msa1b_summary.json`.
- **Runner build-failure tolerance**: a failed Docker/SIF runner build
warns, drops the runner from `ENABLED_TASKRUNNERS`, and lets the
restart continue instead of aborting.
- **Multi-task server architecture**: task-type-agnostic compute server with a
YAML-based registry. Portable task schemas select one of nine shared runtime
families, while one machine-local runner YAML per family supplies mounts,
environment, timeout, and deployment defaults. Missing registry files fail
closed; `gremlin` is always enabled and additional tasks are gated by
`ENABLED_TASKRUNNERS`.
- **Server-driven dynamic form workflow**: the create-task page fetches form
schema from `GET /compute/api/types/<name>` and dynamically builds the file
input (accept extension, label), sequence editor visibility, and params form
(number/text inputs from `TaskParam` definitions). Adding a task type with
new params requires zero frontend changes.
- **`TaskSubmissionRequest` pydantic model**: flat form data
(`params[key]=value`) is parsed into a nested dict, validated against the
task type registry, and forwarded to Celery. Unknown params or task types
are rejected at the API boundary.
- **`GET /compute/api/types` and `GET /compute/api/types/<name>`**: public
endpoints listing all enabled task types with full param schemas.
- **Runner config directory deployment**: `CONFIG_DIR` env var points to the
active `task_types.yaml` and `runners/` directory. Production can mount an
external machine-owned configuration read-only instead of baking host paths
into the server image.
- **Structured issue reporting**: added GitHub Issue Forms for bugs,
installation and environment problems, feature requests, and documentation
problems, with private routing for security vulnerabilities.

### Changed
- **ESMFold v1 removed**: the `esmfold_3B_v1` checkpoint is built against
Expand All @@ -47,8 +86,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Accepted tasks snapshot their effective policy; Docker and SLURM consume the
same values, invalid settings fail closed, allowed partitions are enforced,
and CPU tasks cannot accidentally inherit GPU GRES.

### Changed
- **Create-task scientific workflow**: replaced page-specific form assembly
with capability composition, explicit primary/auxiliary file roles, nested
folder selection, local structure summaries and residue selection, grouped
Expand All @@ -58,33 +95,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
SLURM CPU/memory controls with canonical per-task overrides and visible
effective values. Legacy database fields remain migration fallbacks, empty
overrides restore inheritance, and multi-field updates are transactional.
### Added
- **Multi-task server architecture**: task-type-agnostic compute server with a
YAML-based registry. Portable task schemas select one of nine shared runtime
families, while one machine-local runner YAML per family supplies mounts,
environment, timeout, and deployment defaults. Missing registry files fail
closed; `gremlin` is always enabled and additional tasks are gated by
`ENABLED_TASKRUNNERS`.
- **Server-driven dynamic form workflow**: the create-task page fetches form
schema from `GET /compute/api/types/<name>` and dynamically builds the file
input (accept extension, label), sequence editor visibility, and params form
(number/text inputs from `TaskParam` definitions). Adding a task type with
new params requires zero frontend changes.
- **`TaskSubmissionRequest` pydantic model**: flat form data
(`params[key]=value`) is parsed into a nested dict, validated against the
task type registry, and forwarded to Celery. Unknown params or task types
are rejected at the API boundary.
- **`GET /compute/api/types` and `GET /compute/api/types/<name>`**: public
endpoints listing all enabled task types with full param schemas.
- **Runner config directory deployment**: `CONFIG_DIR` env var points to the
active `task_types.yaml` and `runners/` directory. Production can mount an
external machine-owned configuration read-only instead of baking host paths
into the server image.
- **Structured issue reporting**: added GitHub Issue Forms for bugs,
installation and environment problems, feature requests, and documentation
problems, with private routing for security vulnerabilities.

### Changed
- **Server deployment and adapter documentation**: reconciled the server
README and developer guides with the global executor/runtime model,
runtime-family sharing, immutable multi-file workspaces, manifest-first
Expand Down Expand Up @@ -187,8 +197,101 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Gunicorn error, Celery worker, and maintenance logs through fixed-name
admin-only endpoints. Rotated ZIPs are grouped in a lazy file tree and can
be downloaded individually.

### Fixed
- **Server: artifact responses default to attachment + sandbox CSP**: result
artifacts (untrusted runner output) are served with
`Content-Disposition: attachment` by default (`?download=0` opts back into
inline rendering) and every Flask-mode artifact response carries
`Content-Security-Policy: sandbox`, closing the stored-XSS path via inline
SVG/HTML/XML artifacts (nginx mode sets the same header in
`docker/nginx/default.conf.template`).
- **Server: CSP no longer allows inline scripts**: all four inline
`<script>` blocks were removed — the three data bootstraps
(`__RESULT_TASK__`, `__DASHBOARD_*`, `__IS_ADMIN__`) became inert
`<script type="application/json">` blocks and the reset-password handler
moved to `static/js/reset-password.js`. `script-src` is now
`'self' https://cdn.jsdelivr.net`; the py2Dmol fallback viewer was
verified (code reading of the pinned `viewer-mol.js`) to emit no inline
scripts and never eval.
- **Server: authenticated Redis and loopback-only publish**: `restart.sh
setup` generates `REDIS_PASSWORD` and persists it in the deployment env
file; the compose stack applies it to `redis-server --requirepass` and to
the Celery broker/backend URIs (defaults become
`redis://:<password>@...`). The gateway publishes `${PORT}` on
`127.0.0.1` only (the host TLS/Basic-Auth nginx is the entry point), and
the SLURM override publishes Redis on `127.0.0.1:6380` only — never on
non-loopback interfaces.
- **Server: executor-scoped Docker socket**: the base worker is
executor-neutral and socket-free; a new `docker-compose.docker.yml`
override (merged by `restart.sh` when `job_executor: docker`) adds
`/var/run/docker.sock` + `DOCKER_GID`. Compose concatenates volume lists
across `-f` files, so SLURM-mode workers can no longer inherit
host-root-equivalent Docker access; `DOCKER_GID` is no longer required in
SLURM mode.
- **Server: trusted HTTPS proxy chain**: the host nginx example forwards
`X-Forwarded-Proto $scheme`, gunicorn trusts forwarded headers only from
the compose gateway (`--forwarded-allow-ips 127.0.0.1,172.16.0.0/12`),
and `AUTH_COOKIE_SECURE=true` (default false, so plain-HTTP dev login
keeps working) force-sets the auth cookie's `Secure` flag on HTTPS-only
deployments.
- **Server: scientific-runner sandboxes assumed hostile** — SLURM jobs run
under `apptainer --containall --cleanenv` (private `/dev`/`/proc`/`/sys`,
fresh tmpfs `/tmp` and `$HOME`, host env dropped; all required mounts are
the explicit `--bind` entries), and Docker jobs run with a read-only root
filesystem (`HOME=/tmp` on a tmpfs), `cap_drop=ALL`,
`no-new-privileges`, a 1024 PID ceiling, and no network — weights and
databases arrive only via declared mounts.
- **Server: O(1) API-key validation**: API keys are stored as an indexed
sha256 digest (one lookup + constant-time compare) instead of a KDF hash
scanned across all users; existing KDF-hashed keys are not convertible and
become invalid by design (re-issue from the profile page). Rate limiting
and CAPTCHA nonces moved to Redis fixed-window / `SET NX EX` counters
shared across gunicorn workers, with a documented per-worker in-memory
fallback when Redis is down.
- **Server: symlink-aware path containment**: `_safe_join` now re-checks
realpath-based containment after the lexical check, so symlinks planted
inside a trusted base (including dangling ones) cannot point the real
target outside it.
- **Server: post-completion workspace cleanup**: the per-task input
workspace (immutable snapshot) is deleted when a job reaches a terminal
state — results, the manifest, and the audit row remain untouched.
- **Server: debug capture of submissions**: every finalized task now stores
`debug/submission.json` (form params + file metadata) and
`debug/inputs/<user-facing paths>` (uploaded files under their original
names) inside the results directory before workspace cleanup, so failures
can be reproduced; the debug files are intentionally part of the result
manifest and ZIP.
- **Dashboard performance**: the dashboard reads only a bounded 4 KiB
preview per task (full snapshot remains on the task's results page) and
marks truncated sequences in the UI; the create-task review step no longer
shows resolved resource usage (the types API still fails early on broken
resource policies).
- **Dashboard structure snapshots**: structure-input tasks (`.pdb`/`.cif`/
`.mmcif`) render an interactive py2Dmol alpha-trace snapshot on the
dashboard card instead of the sequence block — lazy-loaded on first
expand from the new owner/admin-only `/compute/api/tasks/<md5>/input`
endpoint. The py2Dmol loading/parsing helpers moved to a shared
`static/js/py2dmol-preview.js` used by both the dashboard and the results
page's Mol* fallback.

### Fixed
- **PRIME runner `trust_remote_code` removal**: the pinned Pro-Prime OGT/DMS
snapshots ship custom transformers code inside their weights dirs, which the
runner previously imported and executed from the mounted model directory at
task time (`trust_remote_code=True`) — a supply-chain code-execution path.
The custom `modeling_*` / `tokenization_*` / `configuration_*` modules are
now vendored into the image at build time
(`docker/runners/prime/vendor/`), imported and registered with
`AutoConfig` / `AutoModel` / `AutoTokenizer`, and the weights load with
`trust_remote_code=False, local_files_only=True`. Missing or broken vendored
code fails the task loudly with remediation pointing at `vendor/README.md`;
an optional `manifest.sha256` pins the weights dir and is verified with
`sha256sum -c` before loading.
- **ESM runner missing `scipy`**: the ESM image did not pin scipy, so
`esm_if1_design.py` crashed at import
(`esm2.inverse_folding.gvp_transformer` → `scipy.spatial.transform`,
`ModuleNotFoundError`) on the SLURM path. Pinned `scipy==1.12.0`
(matching the `prime` image) and extended the build-time smoke import to
cover the inverse-folding chain.
- **SLURM execution diagnostics**: scheduler stdout/stderr are now stored under
explicit `execution/slurm-<username>-<task>-<task-id>.stdout.log` and
`.stderr.log` paths. They are
Expand Down
2 changes: 1 addition & 1 deletion dev/tools/generate_ui_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def render_types(bindings: list[UiBinding], ui_path: Path = UI_PATH) -> str:
"",
"from typing import Protocol",
"",
"from REvoDesign.Qt import QtCore, QtGui, QtWidgets",
"from REvoDesign.Qt import QtGui, QtWidgets",
"",
"",
"class REvoDesignUiProtocol(Protocol):",
Expand Down
16 changes: 13 additions & 3 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,15 @@ ENABLE_REGISTER=false
# ============================================================================
# Redis — message broker and result backend for Celery
# ============================================================================
REDIS_URL=redis://redis:6379/0
BROKER_URL=redis://redis:6379/0
RESULT_BACKEND=redis://redis:6379/0
# Redis is authenticated. `restart.sh setup` generates REDIS_PASSWORD and
# persists it in this file; the compose stack then applies it both to
# redis-server (--requirepass) and to the Celery URIs.
# Uncomment REDIS_URL/BROKER_URL/RESULT_BACKEND only to point at an external
# Redis, and include the password in the URI (redis://:<password>@host:6379/0).
# REDIS_PASSWORD=
# REDIS_URL=redis://:<password>@redis-host:6379/0
# BROKER_URL=redis://:<password>@redis-host:6379/0
# RESULT_BACKEND=redis://:<password>@redis-host:6379/0

# ============================================================================
# Runner settings — non-root container identity
Expand Down Expand Up @@ -181,6 +187,10 @@ WORKER_CONCURRENCY=2
PORT=8080
# Gunicorn worker count for the Flask web process.
GUNICORN_WORKERS=2
# Force the auth cookie's Secure flag even if the proxy chain fails to
# report HTTPS. Enable only on HTTPS-only deployments (plain-HTTP clients
# would otherwise stop receiving the cookie).
# AUTH_COOKIE_SECURE=true
# Web requests exceeding this duration are terminated. Result ZIP bytes are
# served by Nginx and do not occupy Gunicorn for the transfer duration.
GUNICORN_TIMEOUT=120
Expand Down
33 changes: 27 additions & 6 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ When `REVODESIGN_SERVER_ENV` is unset, the helper uses
| `GUNICORN_WORKERS` | Gunicorn worker count. |
| `GUNICORN_TIMEOUT` | Gunicorn request timeout in seconds (default: `120`). Result transfers are handled by Nginx and do not require a long timeout. |
| `RESULT_DOWNLOAD_MODE` | Result delivery backend: `nginx` in Compose production, or `flask` for direct local Flask development. |
| `PORT` | Public HTTP port. |
| `PORT` | Public HTTP port. Published loopback-only (`127.0.0.1`) — the host TLS/Basic-Auth nginx is the entry point, and it must reach the gateway at `localhost:8080`. |
| `REDIS_PASSWORD` | Redis `requirepass` secret. Generated and persisted into the env file by `restart.sh setup`; the compose stack applies it to `redis-server` and to the Celery broker/backend URIs. Set explicitly only for an external Redis. |
| `AUTH_COOKIE_SECURE` | Force the auth cookie's `Secure` flag even if the proxy chain fails to report HTTPS (default: `false`). Enable on HTTPS-only deployments; plain-HTTP clients would otherwise stop receiving the cookie. |
| `RESULT_RETENTION_DAYS` | Optional positive number of days to retain terminal-task result directories and archives. Fractions are allowed (`0.1` = 2.4 hours). Leave unset to disable cleanup; task audit rows remain. |
| `BACKUP_DB_CRON` | Five-field crontab schedule for database snapshots. Leave unset to disable; recommended daily schedule: `0 0 * * *`. |
| `BACKUP_DB_PATH` | Snapshot directory inside the maintenance container. `/var/lib/revodesign-auth/backups` persists at `${AUTH_DIR}/backups` on the host. |
Expand Down Expand Up @@ -755,13 +757,25 @@ You can start from:

- `server/nginx_sites/REvoCompute.app`

The example forwards `X-Forwarded-Proto $scheme` so the app can mark auth
cookies `Secure` and add HSTS; keep that header in any custom proxy config.
Gunicorn trusts forwarded headers only from the compose gateway
(`--forwarded-allow-ips 127.0.0.1,172.16.0.0/12`), so client-supplied
`X-Forwarded-Proto` values are ignored. On HTTPS-only deployments, also set
`AUTH_COOKIE_SECURE=true` as a belt-and-braces force.

## 10. Security

### Docker socket

Only the worker mounts `/var/run/docker.sock` to spawn runner containers. This
separates Docker authority from the public web process, but it is not a
container-escape boundary:
Only the worker mounts `/var/run/docker.sock` to spawn runner containers, and
only in docker-executor deployments: the mount and `DOCKER_GID` live in
`docker-compose.docker.yml`, which `restart.sh` merges in when
`job_executor: docker`. The base worker is executor-neutral, and SLURM-mode
workers get no socket at all (compose concatenates volume lists across `-f`
files, so a socket defined in the base file could never be removed by the
SLURM override). This separates Docker authority from the public web process,
but it is not a container-escape boundary:

- The worker runs as a non-root user for file ownership, but Docker socket
access remains effectively Docker-daemon/host-level authority regardless of
Expand Down Expand Up @@ -795,8 +809,15 @@ banned users, and login throttling are maintained in
### Redis

- Redis is on an internal Docker network; do not expose its port publicly.
- The current Compose stack does not configure Redis authentication. Do not
assume that setting `REDIS_PASSWORD` alone enables it.
- Redis is authenticated: `restart.sh setup` generates `REDIS_PASSWORD` and
persists it in the env file; the compose stack applies it to
`redis-server --requirepass` and to the Celery broker/backend URIs
(`redis://:<password>@...`). The SLURM override publishes Redis only on
`127.0.0.1:6380` (loopback) because its host-networked worker cannot reach
the internal Docker DNS name. Uncomment `REDIS_URL`/`BROKER_URL`/
`RESULT_BACKEND` only for an external Redis, and include the password in
the URI.
- Never publish a Redis port on non-loopback interfaces.

### Data

Expand Down
22 changes: 22 additions & 0 deletions server/docker-compose.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Docker-executor override — merged automatically when the selected task
# registry sets job_executor: docker. It adds the Docker socket to the
# worker; the base worker service is executor-neutral and socket-free.
#
# Compose merges service `volumes` lists by concatenation across -f files,
# so the socket must live here rather than in the base file: an override
# can add mounts but never remove them, and SLURM-mode workers must not
# inherit host-root-equivalent Docker access.

services:
worker:
# Docker socket group access is host-root-equivalent — the Docker API
# can start privileged containers or bind-mount host paths. This is
# an accepted architecture choice; constrain it with a socket proxy or
# separate runner service for a stronger boundary.
# Set DOCKER_GID to the socket group as seen inside containers. On Linux
# this is usually the host docker group id; on Docker Desktop/OrbStack for
# macOS the bind-mounted socket commonly appears as group 0.
group_add:
- "${DOCKER_GID:?Run server/run/restart.sh so DOCKER_GID is auto-detected, or export it explicitly}"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Loading
Loading