Skip to content

security: validate batch spec mount name#1284

Open
cbrnrd wants to merge 2 commits intomainfrom
security/fix-mount-path-injection
Open

security: validate batch spec mount name#1284
cbrnrd wants to merge 2 commits intomainfrom
security/fix-mount-path-injection

Conversation

@cbrnrd
Copy link
Copy Markdown
Contributor

@cbrnrd cbrnrd commented Apr 2, 2026

Problem

step.Mount paths are validated to reject commas (via invalidMountCharacters), but step.Files keys are not, even though both end up interpolated into Docker --mount arguments in run_steps.go:

fmt.Sprintf("type=bind,source=%s,target=%s,ro", source.Name(), target)

A malicious batch spec could exploit this by using a files key containing commas to inject additional mount parameters:

steps:
  - files:
      "/tmp/x,source=/var/run/docker.sock,target=/var/run/docker.sock": "IGNORED"

This produces a --mount argument where the injected source= and target= values override the legitimate ones, potentially mounting arbitrary host paths (e.g., the Docker socket) into the container.

Solution

Add the same comma validation to step.Files keys that already exists for step.Mount paths and mountpoints. This will reject any files target path containing commas during batch spec parsing.

Copy link
Copy Markdown
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So according to https://ampcode.com/threads/T-019d4fb2-9f9c-7675-9802-e4dc35a15d4f docker just uses golangs encoding/csv to parse this argument.

As such you should also reject ". An attacker could use that as well. I think newlines and carriage return could also be used to bypass protections.

Alternatively we could encode the argument value using encoding/csv.

@cbrnrd cbrnrd requested a review from keegancsmith April 3, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants