GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Metadata is printed to the log unescaped, so an untrusted commit message or PR body can inject workflow commands · Issue #1612 · docker/build-push-action

Metadata is printed to the log unescaped, so an untrusted commit message or PR body can inject workflow commands #1612

New issue
Copy link
New issue
Copy link
Closed
#1617
Closed
Metadata is printed to the log unescaped, so an untrusted commit message or PR body can inject workflow commands#1612
#1617
Copy link

Description

@konard
konard
opened on Sep 9, 2026
Issue body actions

Contributing guidelines

  • I've read the contributing guidelines and wholeheartedly agree

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

The Metadata group prints the buildx metadata file to the job log at info level:

if (metadata) {
  await core.group(`Metadata`, async () => {
    const metadatadt = JSON.stringify(metadata, null, 2);
    core.info(metadatadt);
    core.setOutput('metadata', metadatadt);
  });
}

— src/main.ts#L137-L142

Since buildx v0.30.0 that metadata file can contain the entire GitHub event payload. The docker-container driver writes GITHUB_EVENT_PATH into the builder at create time (util/ghutil/ghutil.go: m["github_event_payload"] = evt) and the default metadata-provenance mode min keeps it under buildx.build.provenance.invocation.environment.github_event_payload. --provenance=false does not remove it — that flag only drops the image attestation. I've filed that half separately as docker/buildx#4066.

So core.info is handed unbounded, third-party-controlled text: commit messages on push, PR title and body on pull_request. And the runner parses workflow commands out of every line it is given.

What actually happened

A release run of ours (link-foundation/box run 34293699247) finished with every build job green and 56 annotations at level failure attached to those same green jobs — path .github, line numbers pointing at nothing. The annotation text was the body of one of our own commits, which quoted a runner message while explaining a fix:

##[error]Process completed with exit code 143.

That commit body reached the log because it was in the push payload, in the provenance, in the metadata file, printed by this step. The runner's legacy command parser (ActionCommand.TryParse) searches for ##[ anywhere in a line rather than only at the start, so each occurrence became a failure annotation.

Escaping does not save it: JSON.stringify turns the newlines into \n escapes, so the whole multi-line commit body arrives as a single physical log line containing ##[error] mid-line — exactly the shape the legacy parser accepts.

The severity is not limited to noisy annotations. stop-commands is a registered command as well, so a commit message or PR body containing the right text can silence command processing for the remainder of the step. On a public repository that input comes from whoever opened the pull request.

Reproduction

Minimal, no buildx build needed — this reproduces the runner half in isolation:

jobs:
  demo:
    runs-on: ubuntu-24.04
    steps:
      - run: |
          node -e 'console.log(JSON.stringify({m: "hello\n##[error]not a real error"}, null, 2))'

The job succeeds and carries a failure annotation reading not a real error.

End to end, with buildx: push a commit whose message body contains ##[error]something, then run docker/build-push-action with a docker-container builder created by docker/setup-buildx-action in the same job. The Metadata group prints the commit message and the annotation appears on the successful job. Recorded artefacts (metadata files with and without the GitHub env, the printed output, the disabled-mode control): https://github.com/link-foundation/box/tree/main/dev/log/issues/121/pulls/122/probes/provenance-injection

Workaround

Set the buildx env var at workflow or job scope, which stops buildx writing provenance to the metadata file at all:

env:
  BUILDX_METADATA_PROVENANCE: disabled

This is what we shipped (link-foundation/box#122). docker/setup-buildx-action with driver-opts: provenance-add-gha=false also works and keeps the rest of the provenance, but an unrecognised --driver-opt is a hard error on buildx before v0.30.0.

Neither is a fix for this repository's part: any metadata content that happens to contain ##[ or a leading :: is still printed unescaped.

Suggested fixes

The output (core.setOutput('metadata', …)) is the part consumers depend on and it is not affected — this is only about the human-readable print.

Option A — wrap the print in stop-commands (smallest change, fixes it completely). The runner stops parsing commands until the token is echoed back:

import {issueCommand} from '@actions/core/lib/command';
import * as crypto from 'crypto';

if (metadata) {
  await core.group(`Metadata`, async () => {
    const metadatadt = JSON.stringify(metadata, null, 2);
    const token = crypto.randomUUID();
    issueCommand('stop-commands', {}, token);
    core.info(metadatadt);
    issueCommand(token, {}, '');
    core.setOutput('metadata', metadatadt);
  });
}

Option B — neutralise the two command prefixes before printing:

const safe = metadatadt
  .replace(/##\[/g, '#\u200b#[')
  .replace(/^\s*::/gm, m => m.replace('::', ':\u200b:'));
core.info(safe);

Less invasive, but it mutates displayed content by inserting zero-width characters, and it has to track whatever prefixes the runner accepts.

Option C — print only when core.isDebug(). The metadata file is rarely read by a human in a green run, and ${{ steps.build.outputs.metadata }} remains available. This also happens to cut a lot of log volume now that provenance is in there by default.

I'd suggest A: it is exactly what stop-commands exists for, and it is correct regardless of what buildx decides to put in the file.

Same code in docker/bake-action

src/main.ts#L178-L179 prints the metadata the same way and is exposed identically. Happy to open a separate issue there if you'd prefer.

Version

docker/build-push-action@v7, docker/setup-buildx-action@v3, buildx v0.34.1, ubuntu-24.04 and ubuntu-24.04-arm GitHub-hosted runners.

Activity

  1. konard
    added a commit that references this issue on Sep 9, 2026

    docs: file the three upstream reports behind the 56 false failure ann…

    395aab6
  2. github-actions
    added a commit that references this issue on Sep 9, 2026

    2.9.0: Make every CI annotation mean what it says, and give every che…

    1e202f5
  3. tonistiigi
    closed this as completedin #1617on Sep 11, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.