Security¶
Trust boundaries¶
%%{init: {"flowchart": {"nodeSpacing": 35, "rankSpacing": 70}}}%%
flowchart LR
browser([Browser]) -->|1| ui[Web UI on IIS]
ui -->|2| api[Backend]
api -->|3| llm[(LLM)]
api -->|4| scm[(Azure DevOps<br/>or GitHub)]
docs([Uploaded<br/>documents]) -.->|untrusted| api
| Boundary | Protection |
|---|---|
| 1. Browser → UI | HTTPS with HSTS in production; antiforgery; Data Protection keys persisted. There is no user login yet: anyone who can reach the site can use it (see Known limitations). Restrict the site at the network or IIS level (Windows authentication, IP restrictions) if needed. |
| 2. UI → backend | The backend is reachable only from the IIS servers (bind address and firewall). Every request except /health* must carry X-Forge-Api-Key, compared in constant time. CORS is off. |
| 3. Backend → LLM | TLS verified against FORGE_CA_BUNDLE. Document excerpts and operation lists are sent to the LLM; use a local or contractually covered endpoint. |
| 4. Backend → source control | A service-account token, read at use time from a file or variable and passed to git only through GIT_ASKPASS in the command's environment. It is never written to .git/config, logs or API responses, and is redacted from git error messages. |
Handling untrusted input¶
Uploaded documents and chat messages are untrusted.
- Paths are server-controlled. Uploads go to
uploads/{session_id}/with a sanitised bare file name (naming.safe_filename). Session, run and repository ids are validated (naming.require_safe_id). Clients never send paths or output folders. - Containment checks. Every file the backend writes or serves is resolved and checked to stay inside its root, with symlinks followed (
naming.ensure_within): generated artifacts, reused units, artifact downloads, repository worktrees. - Allowed upload types and sizes. Only the listed extensions, at most 10 files of 10 MB per request by default.
- XML safety. Values interpolated into templates and builders are XML-escaped (
generators/xmlsafe). Names that become XML names, folders and files are validated or coerced to safe NCNames. - No code execution. Generated artifacts are data. LLM output is parsed and validated, never executed, and chat can only produce structured plan operations from a fixed set.
- Repository targets are allow-listed. Clients select a repository by
idfromFORGE_REPOS; they cannot supply URLs. Existing files that Middleware Forge did not write are never overwritten without an explicit per-file decision, and nothing is deleted.
Runtime hardening¶
- The backend container runs as uid 10001 with a read-only root filesystem,
cap_drop: ALL,no-new-privilegesand a size-limited/tmp. - The image contains only the Python runtime,
gitandca-certificates. - Secrets come from the environment or mounted files;
.dockerignorekeeps.env*anddeploy/out of the build context. - Startup refuses to run in production without an API key of at least 16 characters, with
*in CORS, or with a missing CA bundle.
Data protection¶
- Uploaded documents, generated projects, chat history and plan versions are stored unencrypted in the
/datavolume. Use an encrypted disk or volume if the contracts are sensitive, and restrict access to the Docker host. - Retention deletes data after
FORGE_RETENTION_DAYS. - Logs contain ids, file names and messages, not document contents or tokens. LangSmith tracing is off by default; turning it on sends prompts and outputs to LangSmith.
Recommendations¶
- Keep the backend on an internal network segment reachable only from IIS.
- Generate the API key with
openssl rand -hex 32and rotate it periodically (how). - Give the repository service account access only to the repositories in
FORGE_REPOS, with pull-request policies on the base branch so every write is reviewed. - Put the site behind your organisation's authentication until user login is implemented (future improvements).
- Pin the base image by digest and rebuild regularly for security updates.