#1757·cross

image field in Cross.toml should sanitize newlines to prevent malformed Dockerfiles

Author: golang-not-rustCreated Mar 17, 2026Updated Jun 18, 2026
LabelsA-config

Checklist

Describe your issue

The image field in Cross.toml is interpolated directly into a FROM instruction via format!("FROM {image}") in src/docker/shared.rs:140-149. If the value contains newline characters (which TOML supports via escape sequences like \n), the generated Dockerfile will contain additional unintended instructions.

For example:

[target.aarch64-unknown-linux-gnu]
image = "ubuntu:20.04\nRUN echo unexpected"

Generates:

FROM ubuntu:20.04
RUN echo unexpected

While this isn't a security boundary bypass (since Cross.toml already supports arbitrary Dockerfiles via the dockerfile field), it's a correctness issue — the image field should only produce a valid FROM instruction.

Suggested fix: Use a Dockerfile ARG for the image name:

ARG CROSS_IMAGE=ubuntu:20.04
FROM ${CROSS_IMAGE}

This ensures the value is treated as a Docker image reference regardless of its content.

(Follows from discussion in GHSA advisory with the maintainers.)

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

lastest

Example

No response

Additional information / notes

No response