Skip to content

SEC: Arbitrary Docker Image Pull — No Image Allowlist #172

Closed

Description

@vybe

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, and redis://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

  1. As any authenticated user, create an agent with an arbitrary Docker image:
POST /api/agents
{"name": "pentest-alpine", "base_image": "alpine:latest"}
  1. Docker pulls the image from Docker Hub without validation
  2. Container runs inside trinity-agent-network with full internal access

Remediation

  • Define ALLOWED_BASE_IMAGES as a configurable list of approved image name patterns (e.g., ["trinity-agent-base:.*", "trinity-agent-base-gemini:.*"])
  • Add a Pydantic @validator on AgentConfig.base_image that rejects images not matching the allowlist
  • Alternatively, restrict base_image to 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

  1. added
    priority-p0
    security
    pentest
    severity-high
    on Mar 26, 2026
  2. vybe commented on Mar 26, 2026

    @vybe
    ContributorAuthor

    Fixed in 14f2c85. Agent creation now validates base_image against a configurable allowlist (base_image_allowlist system setting, default ["trinity-agent-base:*"]). Disallowed images return HTTP 403. Validation applied in both create_agent_internal() and recreate_container_with_updated_config(). 19 unit tests added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pentestpriority-p0securityseverity-high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions