Restrict agent internet access on Refactoring (RF) tasks#16
Restrict agent internet access on Refactoring (RF) tasks#16mohit-raghavendra wants to merge 1 commit into
Conversation
- Add a network allowlist (package registries + language toolchains) to the agent phase of all RF task.toml files - Bake Go module/toolchain dependencies into Go task images so tests build offline under the allowlist - Allow git-over-https in renovate images so the codex installer can bootstrap Node - Update opus-4.6 run config to restrict internet access; add opus-4.8 run config
| FROM ghcr.io/scaleapi/swe-atlas:swe_atlas_RF_renovatebot_renovate_69d196f015a150488265afc2_1.0@sha256:e0f24e5f7e3b723b2589997316c6231c82e1aafc2c98a2653fe70a91ab218e0e | ||
|
|
||
| # Allow git-over-https so harbor's codex installer can bootstrap Node via nvm | ||
| # (image locks git to file-only by default). file:// still allowed -> verifier unaffected. |
There was a problem hiding this comment.
git: protocol unnecessarily included in GIT_ALLOW_PROTOCOL
The comment says this unblocks the harbor codex installer, which bootstraps Node via nvm over HTTPS. nvm only needs https: (and ssh: for SSH remotes); the git: entry enables the unauthenticated git:// protocol, which is broader than necessary. While the agent-phase network allowlist limits which hosts are reachable, dropping git: would narrow the attack surface with no functional cost. The same pattern appears in the other two renovate Dockerfiles (afc3, afc4). Consider using GIT_ALLOW_PROTOCOL=file:https:ssh instead.
Prompt To Fix With AI
This is a comment left during a code review.
Path: data/rf/task-69d196f015a150488265afc2/environment/Dockerfile
Line: 4
Comment:
**`git:` protocol unnecessarily included in GIT_ALLOW_PROTOCOL**
The comment says this unblocks the harbor codex installer, which bootstraps Node via nvm over HTTPS. nvm only needs `https:` (and `ssh:` for SSH remotes); the `git:` entry enables the unauthenticated `git://` protocol, which is broader than necessary. While the agent-phase network allowlist limits which hosts are reachable, dropping `git:` would narrow the attack surface with no functional cost. The same pattern appears in the other two renovate Dockerfiles (`afc3`, `afc4`). Consider using `GIT_ALLOW_PROTOCOL=file:https:ssh` instead.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| # No WORKDIR override: the base image's WORKDIR is the repo root (varies per repo). | ||
| RUN if [ -d vendor ]; then \ | ||
| GOTOOLCHAIN=auto go build -mod=vendor ./... 2>/dev/null || true; \ | ||
| else \ | ||
| GOTOOLCHAIN=auto go mod download all; \ | ||
| fi && \ |
There was a problem hiding this comment.
Silent failure masks toolchain-download errors for vendored repos
2>/dev/null || true ensures the Dockerfile layer never fails on compilation errors (intentional—the build may not compile cleanly), but it also hides toolchain-download failures. If GOTOOLCHAIN=auto fails to fetch the required toolchain (e.g., a transient network issue during image build), the TC glob finds nothing, the if [ -n "$TC" ] block is skipped, and the original /usr/local/go is kept intact. With GOTOOLCHAIN=local baked in by the subsequent ENV, the agent will then use the original (potentially incompatible) toolchain version and produce opaque build failures at run time. At minimum, keeping toolchain-download errors on stderr (omitting 2>/dev/null) would make image-build logs actionable. The same pattern is used across all ~25 Go task Dockerfiles.
Prompt To Fix With AI
This is a comment left during a code review.
Path: data/rf/task-69391d8d1ce51c407be1e531/environment/Dockerfile
Line: 10-15
Comment:
**Silent failure masks toolchain-download errors for vendored repos**
`2>/dev/null || true` ensures the Dockerfile layer never fails on compilation errors (intentional—the build may not compile cleanly), but it also hides toolchain-download failures. If `GOTOOLCHAIN=auto` fails to fetch the required toolchain (e.g., a transient network issue during image build), the `TC` glob finds nothing, the `if [ -n "$TC" ]` block is skipped, and the original `/usr/local/go` is kept intact. With `GOTOOLCHAIN=local` baked in by the subsequent `ENV`, the agent will then use the original (potentially incompatible) toolchain version and produce opaque build failures at run time. At minimum, keeping toolchain-download errors on stderr (omitting `2>/dev/null`) would make image-build logs actionable. The same pattern is used across all ~25 Go task Dockerfiles.
How can I resolve this? If you propose a fix, please make it concise.
Mirrors the Test Writing lockdown, for the Refactoring (RF) tasks.
task.tomlfiles, so reference solutions can't be looked up online.opus-4.6run config to restrict internet access and adds anopus-4.8run config.Greptile Summary
This PR restricts agent-phase internet access for all 70 RF (Refactoring) tasks, mirroring the lockdown previously applied to Test Writing tasks. The
[agent]section of everytask.tomlgains anetwork_mode = \"allowlist\"block covering common package registries (PyPI, Debian/Ubuntu/Alpine, Go, npm/yarn), while the[environment]build phase retainsallow_internet = true.GOTOOLCHAIN=auto, then setsGOPROXY=off,GOSUMDB=off, andGOTOOLCHAIN=localso agent-phase builds work fully offline.GIT_ALLOW_PROTOCOL=file:git:https:sshso the harbor/codex Node bootstrapper (nvm, which clones over HTTPS) can function under the locked-down image.opus-4p6is updated with--ak disallowed_tools=WebSearch,WebFetchand--allow-agent-host, concurrency bumped from 16→24; a newopus-4p8-xhighconfig is added with the same restrictions plus--max-retries 3.Confidence Score: 4/5
Safe to merge; the lockdown is consistent, mirrors a proven pattern from the TW tasks, and the two flagged items are minor hardening opportunities with no correctness impact.
The change is large in file count but highly repetitive and mechanical—the same allowlist block and the same Dockerfile layer are stamped across 70 tasks. The Go pre-baking logic is sound: toolchain download happens before compilation under GOTOOLCHAIN=auto, so
|| trueonly masks post-download build errors. The two concerns—overly broad GIT_ALLOW_PROTOCOL and silent stderr suppression in the vendored-build step—do not affect correctness under normal conditions, but they reduce observability and marginally widen the protocol surface in the renovate images.The three renovate Dockerfiles (afc2, afc3, afc4) deserve a second look on the GIT_ALLOW_PROTOCOL value. The shared Go Dockerfile pattern used across all ~25 Go tasks is worth confirming in one real image build to verify the toolchain copy lands at /usr/local/go correctly.
Important Files Changed
git:(unauthenticated) protocol alongside thehttps:actually needed by nvm.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[RF task.toml] --> B{Language?} B -->|Go - trufflehog / k6 / grafana-Go| C[New Dockerfile layer] B -->|Python / TypeScript / C++| D[Keep existing docker_image] B -->|renovatebot/renovate| E[Existing Dockerfile + GIT_ALLOW_PROTOCOL fix] C --> C1["GOTOOLCHAIN=auto go build -mod=vendor ./...\n(vendored) OR go mod download all\n(non-vendored)"] C1 --> C2[Copy resolved toolchain to /usr/local/go] C2 --> C3["ENV: GOPROXY=off, GOSUMDB=off, GOTOOLCHAIN=local"] D --> F[agent phase] C3 --> F E --> F F --> G["network_mode = allowlist\nallowed_hosts: PyPI, Debian/Ubuntu/Alpine,\ngo.dev, dl.google.com, npm/yarn, nodejs.org"] G --> H[Agent runs offline-capable build] I[run_config scripts] --> J["--ak disallowed_tools=WebSearch,WebFetch\n--allow-agent-host HARBOR_AGENT_ALLOWED_HOST"] J --> HPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "Restrict agent internet access on Refact..." | Re-trigger Greptile