X Tutup
Skip to content

False positive: docker/build-push-action, context input #21428

@mkielar

Description

@mkielar

Description of the false positive
This was originally reported for zizmorcore/zizmor#1705, please see the ticket for more context and an SSCCE. It's been explained that zizmor is showing that vulnerability report as a result of this entry in CodeQL:

extensions:
- addsTo:
pack: codeql/actions-all
extensible: actionsSinkModel
data:
- ["docker/build-push-action", "*", "input.context", "code-injection", "manual"]

Code samples or links to source code
The full, step-by-step analysis was documented here: zizmorcore/zizmor#1705 (comment), but for the sake of clarity:

  1. docker/build-push-action passes context as a string item in an array:
  2. That last call to Exec.getExecOutput(...) leads to docker/actions-toolkit, which still processes all args as an array:
    https://github.com/docker/actions-toolkit/blob/main/src/exec.ts#L27-L30
  3. The implementation of getExecOputpt(...) calls exec(...) in the same class:
  4. The exec(...) functions processes the args array, but only to extract the first element of it (the command - build or buildx depending on the earlier setup), and passes the args array to ToolRunner class, in the same library.
  5. The implementation of ToolRunner only processes the args via _getSpawnArgs function, which still returns them as array and then uses Node.js built-in child_process.spawn() (see here: https://github.com/actions/toolkit/blob/main/packages/exec/src/toolrunner.ts#L437-L441) to invoke docker.

The args are being passed down as an array through all these layers, and finally end up in a Node.js built-in. So, unless the're a vulnerability in Node.js child_process.spawn, passing the context as . --buildArg FOO=foo will not cause the FOO build argument to be passed to docker. Instead the whole thing will be treated as context path and cause docker build command to fail.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup