Repository navigation
Description
Pentest Finding 3.1.1 — High (CVSS 8.8)
CVSS Vector: CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H
Location: POST /api/agents — services/agent_service/crud.py line 440
Impact
Any authenticated user can deploy an agent container running an arbitrary Docker image by supplying the base_image field with any registry reference. The platform pulls and executes any publicly accessible Docker image with no allowlist validation. The attacker-controlled container is placed inside the trinity-agent-network Docker network alongside the backend, MCP server, and Redis, enabling:
- Network-internal SSRF — container can reach
http://backend:8000,http://mcp-server:8080, andredis://redis:6379 - Credential exfiltration — all agent environment variables (ANTHROPIC_API_KEY, TRINITY_MCP_API_KEY, GITHUB_PAT) are accessible
- Persistent backdoor — container runs continuously until stopped
- Redis access — network access to Redis exposes all cached secrets
Root Cause
services/agent_service/crud.py line 440 passes config.base_image directly to Docker's container creation API with no validation. The AgentConfig model defines base_image as a free-text string with no validator, no allowlist, no regex constraint, and no registry restriction.
Steps to Reproduce
- As any authenticated user, create an agent with an arbitrary Docker image:
POST /api/agents
{"name": "pentest-alpine", "base_image": "alpine:latest"}- Docker pulls the image from Docker Hub without validation
- Container runs inside
trinity-agent-networkwith full internal access
Remediation
- Define
ALLOWED_BASE_IMAGESas a configurable list of approved image name patterns (e.g.,["trinity-agent-base:.*", "trinity-agent-base-gemini:.*"]) - Add a Pydantic
@validatoronAgentConfig.base_imagethat rejects images not matching the allowlist - Alternatively, restrict
base_imageto local images only (Docker pull disabled) unless the user is an admin - Log and alert on any agent creation request with a non-standard base image
References
Source: UnderDefense Web Pentest Report, March 2026
Activity
fix(security): Base image allowlist — block arbitrary Docker image pu…
vybe commentedon Mar 26, 2026
Fixed in 14f2c85. Agent creation now validates
base_imageagainst a configurable allowlist (base_image_allowlistsystem setting, default["trinity-agent-base:*"]). Disallowed images return HTTP 403. Validation applied in bothcreate_agent_internal()andrecreate_container_with_updated_config(). 19 unit tests added.merge: Resolve changelog conflict after merging upstream/main
merge: integrate upstream/main into feature branch
fix(operator-queue): key the test's auth override off the routes' cap…
fix(operator-queue): the file sync tells the truth — per-row sync and…