T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/build-gog-safe.sh:20
- Finding
- Mutable Source from an Undeclared Fork Is Retrieved and Executed<![CDATA[ ## Vulnerability Details **File Location**: `scripts/build-gog-safe.sh:20-21, 91-108` **Vulnerability Type**: Remote payload retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```bash UPSTREAM_BRANCH="feat/safety-profiles" UPSTREAM_REPO="https://github.com/drewburchfield/gogcli-safe.git" ``` ```bash # Step 1: Clone or update the PR branch if [[ -d "$BUILD_DIR/.git" ]]; then echo "Updating existing checkout..." cd "$BUILD_DIR" git fetch origin "$UPSTREAM_BRANCH" 2>/dev/null || true git checkout "$UPSTREAM_BRANCH" 2>/dev/null git pull origin "$UPSTREAM_BRANCH" 2>/dev/null || true else echo "Cloning gogcli PR #366 branch..." rm -rf "$BUILD_DIR" git clone --branch "$UPSTREAM_BRANCH" --depth 1 "$UPSTREAM_REPO" "$BUILD_DIR" cd "$BUILD_DIR" fi # Step 2: Copy our profile into the build tree cp "$PROFILE" "$BUILD_DIR/safety-profile.yaml" echo "Copied profile to build tree." # Step 3: Generate command structs (must run on host platform) echo "Generating command structs from profile..." rm -f internal/cmd/*_cmd_gen.go CGO_ENABLED=0 go run ./cmd/gen-safety --strict safety-profile.yaml ``` ### Technical Analysis The build script retrieves a mutable Git branch from `drewburchfield/gogcli-safe` and immediately executes repository-controlled Go code through `go run ./cmd/gen-safety`. It then builds the rest of the retrieved repository into the binary intended for deployment. The repository and branch differ from the source described in `SKILL.md:54` and `references/levels.md:40,45-46`, which identify `steipete/gogcli` PR 366. The build does not pin an immutable commit, verify a signed tag, check a known source hash, or validate the generated source. Consequently, the effective payload can change after this skill package has been reviewed. Suppressing fetch and pull errors with `|| true` also weakens reproducibility: a failed update can silently leave an unknown or locally modified checkout in use. ### Attack Path 1. An ...[truncated 1334 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the undeclared fork with the reviewed and documented upstream repository. 2. Pin the source to a specific, audited commit hash rather than a mutable branch. 3. Verify the checked-out commit before executing or compiling any repository code: ```bash EXPECTED_COMMIT="<audited-full-commit-hash>" git checkout --detach "$EXPECTED_COMMIT" [[ "$(git rev-parse HEAD)" == "$EXPECTED_COMMIT" ]] || exit 1 ``` 4. Verify signed commits or tags against an explicitly trusted maintainer key. 5. Vendor the generator into the reviewed skill package where practical, or separately review and hash its complete dependency closure. 6. Run source generation and compilation in an isolated, unprivileged container or sandbox with no developer credentials and minimal network access. 7. Remove `|| true` from security-relevant Git operations and fail closed when retrieval, checkout, or verification fails. 8. Generate a software bill of materials and record the repository URL, exact commit, profile hash, Go version, and artifact checksum for every build. 9. Verify the final artifact through reproducible builds or an independent trusted build pipeline before deployment. ]]>
