Cloudanix VulnDB

CVE-2023-24531

Critical · 9.8

CVSS

9.8

EPSS

0.8%

Published

Jul 2, 2024

CISA due date

—

Cloudanix analysis

Monitor only SSVC: Track

A Go language tool that prints configuration settings can accidentally run attacker commands if its printed results are fed directly into a script without checking them first.

Chainable
Exploitation
Remote Unauthenticated
Attacker needs
None
Complexity
Moderate
Impact
Remote Code Execution
Component
Application
Class
Command Injection
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

The go env command outputs environment variable values without sanitization, allowing shell metacharacters or new variable assignments in the printed output that are executed when the output is sourced as a script.

Why it matters to the business

Organizations relying on Go tooling in build pipelines, scripts, or CI systems face a risk of unintended command execution or environment manipulation if go env output is ever treated as trusted shell input, though the practical impact is limited because attackers who can already control environment variables usually have stronger options.

How an attack unfolds

An attacker who can influence environment variables on a system sets values containing shell commands or new variable definitions; a subsequent invocation of go env whose output is piped or sourced into a shell then executes the attacker-controlled content.

How to fix it

Avoid sourcing or executing the raw output of go env in any shell context; prefer go env -json for machine-readable output and parse it safely with language-native tools instead of shell evaluation.

How to confirm the fix worked

Confirm that no build or deployment scripts invoke go env and then source or eval its stdout; test by setting an environment variable containing a harmless command and verifying it does not execute when go env output is used.

Typical attack path

  1. Attacker obtains ability to set arbitrary environment variables on a target system
  2. Attacker ensures go env will be executed and its output sourced or evaluated by a shell script or build step
  3. go env prints the malicious variable values without escaping
  4. Shell sourcing of the output executes the injected commands or defines attacker variables

How to detect it

Review build logs, CI job output, and shell history for invocations of go env whose output is subsequently sourced, evaled, or piped to sh/bash; look for environment variables containing shell metacharacters or unexpected command strings around the time of such invocations.

What your security team should do

  • Audit all scripts and CI pipelines that invoke go env and replace any sourcing or eval usage
  • Add static analysis or lint rules to flag direct shell sourcing of go env output
  • Educate developers on using go env -json and safe parsing instead of shell evaluation

The record

Command go env is documented as outputting a shell script containing the Go environment. However, go env doesn't sanitize values, so executing its output as a shell script can cause various bad bahaviors, including executing arbitrary commands or inserting new environment variables. This issue is relatively minor because, in general, if an attacker can set arbitrary environment variables on a system, they have better attack vectors than making "go env" print them out.

Affected packages

Ecosystem Package Introduced Fixed
Go toolchain 0 1.21.0-0
Bitnami golang 0 1.21.0-0
Chainguard argo-workflow-cli 0 3.6.5-r2
Chainguard argo-workflow-controller 0 3.6.5-r2
Chainguard argo-workflow-controller-compat 0 3.6.5-r2
Chainguard argo-workflow-executor 0 3.6.5-r2
Chainguard argo-workflow-executor-compat 0 3.6.5-r2
Chainguard argo-workflows 0 3.6.5-r2
Chainguard argo-workflows-known-hosts 0 3.6.5-r2
Chainguard argo-workflows-ui 0 3.6.5-r2
Chainguard go-1.20-doc 0 1.20.14-r9
Chainguard newrelic-fluent-bit-output 0 2.4.0-r5
Chainguard newrelic-fluent-bit-output-compat 0 2.4.0-r5
Debian:11 golang-1.15 0 No fix
Debian:12 golang-1.19 0 No fix
Ubuntu:14.04:LTS golang-1.10 0 No fix
Ubuntu:16.04:LTS golang-1.10 0 No fix
Ubuntu:16.04:LTS golang-1.6 0 No fix
Ubuntu:18.04:LTS golang-1.10 0 No fix
Ubuntu:18.04:LTS golang-1.8 0 No fix
Ubuntu:18.04:LTS golang-1.9 0 No fix
Ubuntu:20.04:LTS golang-1.13 0 No fix
Ubuntu:20.04:LTS golang-1.14 0 No fix
Ubuntu:20.04:LTS golang-1.16 0 No fix
Ubuntu:20.04:LTS golang-1.18 0 No fix
Ubuntu:20.04:LTS golang-1.18 0 1.18.1-1ubuntu1~20.04.3
Ubuntu:20.04:LTS golang-1.20 0 No fix
Ubuntu:20.04:LTS golang-1.21 0 No fix
Ubuntu:20.04:LTS golang-1.22 0 1.22.2-2~20.04.1
Ubuntu:22.04:LTS golang-1.13 0 No fix
Ubuntu:22.04:LTS golang-1.17 0 No fix
Ubuntu:22.04:LTS golang-1.17 0 1.17.13-3ubuntu1.2
Ubuntu:22.04:LTS golang-1.18 0 No fix
Ubuntu:22.04:LTS golang-1.18 0 1.18.1-1ubuntu1.2
Ubuntu:22.04:LTS golang-1.20 0 No fix
Ubuntu:22.04:LTS golang-1.21 0 No fix
Ubuntu:22.04:LTS golang-1.22 0 No fix
Ubuntu:22.04:LTS golang-1.22 0 1.22.2-2~22.04
Ubuntu:24.04:LTS golang-1.21 0 No fix
Ubuntu:24.04:LTS golang-1.22 0 No fix
Ubuntu:24.04:LTS golang-1.22 0 1.22.2-2ubuntu0.1
Ubuntu:24.10 golang-1.22 0 1.22.8-1
Ubuntu:Pro:14.04:LTS golang-1.10 0 No fix
Ubuntu:Pro:16.04:LTS golang-1.10 0 No fix
Ubuntu:Pro:16.04:LTS golang-1.13 0 No fix
Ubuntu:Pro:16.04:LTS golang-1.18 0 No fix
Ubuntu:Pro:16.04:LTS golang-1.18 0 1.18.1-1ubuntu1~16.04.6+esm1
Ubuntu:Pro:16.04:LTS golang-1.6 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.10 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.13 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.16 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.18 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.18 0 1.18.1-1ubuntu1~18.04.4+esm1
Ubuntu:Pro:18.04:LTS golang-1.8 0 No fix
Ubuntu:Pro:18.04:LTS golang-1.9 0 No fix
Ubuntu:Pro:20.04:LTS golang-1.13 0 No fix
Ubuntu:Pro:20.04:LTS golang-1.14 0 No fix
Ubuntu:Pro:20.04:LTS golang-1.16 0 No fix
Ubuntu:Pro:20.04:LTS golang-1.20 0 No fix
Ubuntu:Pro:20.04:LTS golang-1.21 0 No fix
Ubuntu:Pro:22.04:LTS golang-1.13 0 No fix
Wolfi argo-workflow-cli 0 3.6.5-r2
Wolfi argo-workflow-controller 0 3.6.5-r2
Wolfi argo-workflow-controller-compat 0 3.6.5-r2
Wolfi argo-workflow-executor 0 3.6.5-r2
Wolfi argo-workflow-executor-compat 0 3.6.5-r2
Wolfi argo-workflows 0 3.6.5-r2
Wolfi argo-workflows-known-hosts 0 3.6.5-r2
Wolfi argo-workflows-ui 0 3.6.5-r2
Wolfi go-1.20-doc 0 1.20.14-r9
Wolfi newrelic-fluent-bit-output 0 2.4.0-r5
Wolfi newrelic-fluent-bit-output-compat 0 2.4.0-r5

Related vulnerabilities