From 07a6ec0f00848be78ca6d6f714070d306e790345 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Tue, 13 Oct 2026 17:57:35 -0400 Subject: [PATCH 1/8] test(#3373): add reproduction test for reservedSandboxKeys blocklist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduction test for https://github.com/fullsend-ai/fullsend/issues/3373 (reproduced). Evidence: TestReservedSandboxKeys_CoversReservedCredentialKeys: 25/32 subtests fail — reservedSandboxKeys omits HTTP_PROXY HTTPS_PROXY NODE_OPTIONS PYTHONPATH PROMPT_COMMAND IFS CDPATH LD_AUDIT DYLD_INSERT_LIBRARIES SSL_CERT_FILE/DIR CURL_CA_BUNDLE NODE_EXTRA_CA_CERTS HOSTALIASES GIT_SSH_COMMAND GIT_ASKPASS GIT_CONFIG_GLOBAL GIT_EXEC_PATH GIT_TEMPLATE_DIR JAVA_TOOL_OPTIONS RUBYOPT PERL5OPT PYTHONSTARTUP NO_PROXY ALL_PROXY; buildSandboxEnvLines emits e.g. export GIT_SSH_COMMAND='/tmp/evil'. 7 original infra keys (PATH HOME SHELL LD_PRELOAD LD_LIBRARY_PATH BASH_ENV ENV) pass. Signed-off-by: Tim Pouyer --- .../cli/run_reserved_credential_env_test.go | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 internal/cli/run_reserved_credential_env_test.go diff --git a/internal/cli/run_reserved_credential_env_test.go b/internal/cli/run_reserved_credential_env_test.go new file mode 100644 index 0000000000..349b4f9c81 --- /dev/null +++ b/internal/cli/run_reserved_credential_env_test.go @@ -0,0 +1,69 @@ +package cli + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/fullsend-ai/fullsend/internal/harness" +) + +// envSandboxSecurityKeys mirrors reservedCredentialKeys in +// internal/sandbox/sandbox.go, which is unexported and therefore unreadable +// from this package. +// +// This is deliberately a copy rather than a live probe. Probing the credential +// path (sandbox.EnsureProvider returns a reserved-key error before exec) would +// need the PATH guard its own test uses to keep a non-refused name from +// executing a real openshell, and t.Setenv in a sequential test leaks the +// mutated PATH to parallel tests elsewhere in this package. Reproducing the +// invariant without touching process state is the better trade here. +// +// The permanent fix is one shared list consumed by both doors; until then a +// name added to reservedCredentialKeys must be added here too. See +// internal/sandbox/reserved_env_drift_test.go, which guards the plugin-env +// door the same way. +var envSandboxSecurityKeys = []string{ + // Process loading / shell behavior — already reserved, kept to pin it. + "PATH", "HOME", "SHELL", "LD_PRELOAD", "LD_LIBRARY_PATH", "BASH_ENV", "ENV", + // Proxy — could redirect sandbox HTTP traffic + "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "ALL_PROXY", + // Subprocess-influencing runtime vars + "NODE_OPTIONS", "PYTHONPATH", "PROMPT_COMMAND", + // Word splitting / cd resolution + "IFS", "CDPATH", + // Language runtime injection — arbitrary code at process start + "JAVA_TOOL_OPTIONS", "RUBYOPT", "PERL5OPT", "PYTHONSTARTUP", + // Dynamic linker audit and macOS interpose — shared-object loading + "LD_AUDIT", "DYLD_INSERT_LIBRARIES", + // TLS trust chain — validation redirected to an attacker-controlled CA + "SSL_CERT_FILE", "SSL_CERT_DIR", "CURL_CA_BUNDLE", "NODE_EXTRA_CA_CERTS", + // Hostname resolution redirect + "HOSTALIASES", + // Git config — can inject hooks or redirect operations + "GIT_CONFIG_GLOBAL", "GIT_EXEC_PATH", "GIT_SSH_COMMAND", "GIT_TEMPLATE_DIR", "GIT_ASKPASS", +} + +// TestReservedSandboxKeys_CoversReservedCredentialKeys pins the invariant that +// a variable unsafe as a provider credential key is equally unsafe injected via +// env.sandbox: both paths end up as environment variables in the same sandbox +// child process, so a gap between the two blocklists is a bypass of the +// credential deny-list through harness YAML (#3373). +func TestReservedSandboxKeys_CoversReservedCredentialKeys(t *testing.T) { + t.Parallel() + for _, key := range envSandboxSecurityKeys { + t.Run(key, func(t *testing.T) { + t.Parallel() + + assert.Truef(t, reservedSandboxKeys[key], + "reservedSandboxKeys must include %s: env.sandbox can inject a variable the credential path refuses", key) + + lines := buildSandboxEnvLines(&harness.Harness{ + Env: &harness.EnvConfig{Sandbox: map[string]string{key: "/tmp/evil"}}, + }) + assert.NotContainsf(t, strings.Join(lines, "\n"), "export "+key+"=", + "buildSandboxEnvLines leaked %s into the sandbox environment", key) + }) + } +} From cfe894582f7da70fc8962d0b34dcf0db35f0a111 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Thu, 15 Oct 2026 17:53:23 -0400 Subject: [PATCH 2/8] fix(#3373)!: block credential-class env vars set via env.sandbox Fixes https://github.com/fullsend-ai/fullsend/issues/3373 Align env.sandbox filtering with the credential-key deny-list used for URL-sourced provider definitions. Of its 32 names, 25 were previously exportable through env.sandbox; the other seven were already reserved. The existing trusted-local-provider exception is unchanged. Expose a sorted copy through sandbox.ReservedCredentialKeys() and merge it into the CLI's existing blocklist at init, retaining the runner, OIDC and provider-only restrictions. Match reserved names case-insensitively so lowercase and mixed-case spellings cannot bypass the merged list. The export gate and diagnostics use the same reserved-name predicate and validate identifiers before matching them. Include load-time diagnostics with this behavior change so operators can identify settings that will no longer be exported. fullsend run and fullsend lock name reserved keys when they load the composed harness; the existing per-key stderr warnings remain at environment generation. Current lock entries still skip composition and dependency resolution. They report that diagnostics were skipped and point to --update, which re-resolves dependencies and may modify the lock file. Keep the runner-secret bundle check on its own name set. The merged credential names are dangerous inside the sandbox child but legitimate as host-side runner-secret keys (proxy, TLS trust and Git settings for pre_script and post_script), and reading the widened map at that door would refuse them and stop every run carrying such a bundle. The runner-secret refusal keeps the runner infrastructure names, the OIDC and provider-only keys and the runner-owned prefixes (now including DYLD_), and matches case-insensitively like the env.sandbox gate so a lowercase key such as path cannot slip past. Drift tests pin both doors: credential-only names stay allowed as runner-secret keys, and every non-credential sandbox-reserved name stays refused. Accepted ADR 0136 gains a clarifying note that its refused-name rule covers the runner-infrastructure names. The reproduction test follows the live accessor so additions remain covered. NotEmpty rejects an empty result; separate accessor-contract and explicit-name tests detect omissions and policy shrinkage. Tests also cover copy isolation, ordering, case variants, invalid identifiers, allowed exports and the real run/lock call sites. Cache-hit regressions cover single-agent and --all use without rewriting the lock, and an --update regression checks reserved keys from both a base and child. Later commits in #8496 check the deny-list beside the blocklist instead of merging it, let the runner-secret refusal read the blocklist again, drop the lock cache-hit notice, and record the name-set split in ADR 0145. Focused regressions passed with -race -count=1. Lint and commit hooks passed. Approximate patch coverage is 41/41 changed instrumented lines. BREAKING CHANGE: env.sandbox no longer exports the additional reserved proxy, TLS trust, Git, interpreter, loader and shell-behavior names. Matching is now case-insensitive for all reserved names. Audit harness YAML, shared bases and per-agent overrides before upgrading. Affected entries are skipped with warnings rather than rejecting the entire harness; tools may subsequently fail without the requested settings. Migrate proxy and certificate settings to the operator-managed OpenShell gateway configuration: the upstream proxy settings and proxy_ca_bundle. The migration guide's Migrating proxy and certificate settings section covers this. fullsend's own GitHub Action writes gateway.toml from a fixed template and has no proxy or CA input yet; #8505 tracks adding one. .env.d is not a migration path for proxy or certificate settings. For Git settings, use supported tool configuration or trusted host_files. Every launch and the runner's in-sandbox probes read .env.d as data: only assignment lines are taken, and LD_PRELOAD, LD_LIBRARY_PATH, LD_AUDIT, every PYTHON* variable, BASH_ENV, ENV and IFS are never taken from it, so moving a loader or shell export there does not preserve it. Direct/raw runner-credential exports remain restricted; supported provider-only GH_WORKFLOW_TOKEN use is unchanged and supplies a placeholder inside the sandbox. Runner-secret bundle keys and env.runner keys receiving a runner secret are now matched case-insensitively against the refused names and DYLD_* is a refused family, so a bundle key such as path or github_token now fails validation. Credential-class names such as HTTPS_PROXY stay accepted as runner-secret keys. The name-set split between the sandbox gate and the runner-secret refusal is recorded in ADR 0145, added later in #8496, which amends ADR 0136's refused-name rule. Signed-off-by: Tim Pouyer --- ...unner-secrets-through-one-stored-secret.md | 7 + docs/guides/user/customizing-agents.md | 58 ++++- docs/reference/harness-reference.md | 2 +- internal/cli/lock.go | 6 +- internal/cli/lock_reserved_env_cache_test.go | 103 ++++++++ internal/cli/run.go | 52 +++- .../cli/run_reserved_credential_env_test.go | 175 ++++++++++--- internal/cli/run_reserved_env_case_test.go | 66 +++++ internal/cli/run_reserved_env_lint.go | 66 +++++ internal/cli/run_reserved_env_lint_test.go | 234 ++++++++++++++++++ internal/cli/runner_secrets.go | 40 ++- internal/cli/runner_secrets_test.go | 114 +++++++++ .../sandbox/reserved_credential_keys_test.go | 77 ++++++ internal/sandbox/sandbox.go | 29 +++ 14 files changed, 974 insertions(+), 55 deletions(-) create mode 100644 internal/cli/lock_reserved_env_cache_test.go create mode 100644 internal/cli/run_reserved_env_case_test.go create mode 100644 internal/cli/run_reserved_env_lint.go create mode 100644 internal/cli/run_reserved_env_lint_test.go create mode 100644 internal/sandbox/reserved_credential_keys_test.go diff --git a/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md b/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md index 8ff63b0a0a..077449e0e7 100644 --- a/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md +++ b/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md @@ -76,6 +76,13 @@ These rules apply to names in the GitHub object: guarded only by `runtime.forge` and `config`, until ADR 0112's guarded-field check is implemented. +> **Note (2026-10, [#3373](https://github.com/fullsend-ai/fullsend/issues/3373)):** +> "Sandbox-reserved" in the refused-names rule above meant the +> runner-infrastructure names; "credential" meant the OIDC and provider-only +> keys, not the wider credential-class deny-list. The later merge of that +> deny-list into `reservedSandboxKeys` was decoupled from this refusal; see +> the harness reference for the current split. + GitLab is unchanged: a JSON bundle does not fit GitLab's per-variable masking, each secret stays its own masked CI/CD variable, and none of these rules apply there. Keeping fullsend's own credentials out of GitLab host-side scripts is diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index 075c12d0f3..9ba618e9d1 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -450,8 +450,62 @@ and other lines that are not plain assignments) are skipped with a warning. these files like `pre_script`. `host_files` can also place configuration that tools load, such as git config or shell rc files; that is trusted like `pre_script` too. -**Note**: `env.sandbox` cannot modify `PATH`, the harness ignores special -variables to protect sandbox operation. +**Note**: `env.sandbox` cannot modify runner infrastructure or security +settings. The runner drops these names before writing the sandbox +environment, case-insensitively: + +- **Runner infrastructure and process-loading safeguards:** `PATH`, `HOME`, + `SHELL`, `BASH_ENV`, `ENV`, `LD_PRELOAD`, `LD_LIBRARY_PATH`, `TRACEPARENT`, + and the `FULLSEND_*` variables it reserves for itself (output and fetch + plumbing, `FULLSEND_ROLE`, `FULLSEND_SLUG`, `FULLSEND_TIMEOUT_MINUTES`, + `FULLSEND_ITERATION_DEADLINE`, `FULLSEND_RUNNER_PATH`). +- **Credentials it mints or receives:** `FULLSEND_GCP_OIDC_AUTH_FILE`, + `FULLSEND_TRIGGER_TOKEN`, `FULLSEND_WEBHOOK_SECRET`, + `FULLSEND_INFERENCE_GATEWAY_API_KEY`, `FULLSEND_OPENAI_API_KEY`, + `OPENAI_API_KEY`, `GH_WORKFLOW_TOKEN`, and the GitHub Actions OIDC request + pair `ACTIONS_ID_TOKEN_REQUEST_URL` / `ACTIONS_ID_TOKEN_REQUEST_TOKEN`. +- **Non-secret, runner-only inputs that select those credentials:** + `FULLSEND_GCP_OIDC_URL`, `FULLSEND_GCP_PROJECT_ID`, + `FULLSEND_GCP_WIF_PROVIDER`, `FULLSEND_OPENAI_AUDIENCE`, + `FULLSEND_OPENAI_IDENTITY_PROVIDER_ID`, + `FULLSEND_OPENAI_SERVICE_ACCOUNT_ID`. +- **Security-sensitive names that fullsend also refuses as provider + credential keys:** proxy settings (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`, + `ALL_PROXY`), TLS trust-chain overrides (`SSL_CERT_FILE`, `SSL_CERT_DIR`, + `CURL_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`), git configuration + (`GIT_SSH_COMMAND`, `GIT_CONFIG_GLOBAL`, `GIT_EXEC_PATH`, `GIT_ASKPASS`, + `GIT_TEMPLATE_DIR`), interpreter injection (`NODE_OPTIONS`, `PYTHONPATH`, + `PYTHONSTARTUP`, `JAVA_TOOL_OPTIONS`, `RUBYOPT`, `PERL5OPT`), + dynamic-linker hooks (`LD_AUDIT`, `DYLD_INSERT_LIBRARIES`), shell behavior + (`IFS`, `CDPATH`, `PROMPT_COMMAND`) and the resolver alias file + (`HOSTALIASES`). + +The list is by name, not by namespace: harness-supplied hook inputs such as +`FULLSEND_CANARY_TOKEN` and `FULLSEND_TOOL_ALLOWLIST` are still delivered +through `env.sandbox` — see +[Runtime Implementation](../../contributing/runtime-implementation.md). +Matching is case-insensitive, so `https_proxy` is dropped exactly as +`HTTPS_PROXY` is. + +`fullsend run` warns when the harness loads, naming all reserved keys it will +drop, and warns again on stderr for each key as it writes the sandbox +environment. `fullsend lock` reports the same lint warning when it loads and +composes the harness. If its lock entry is already current, it skips that work +and prints a notice that diagnostics were not checked. Use +`fullsend lock --update` (or `fullsend lock --all --update`) to +check the composed harness; this also re-resolves its dependencies and may +update the lock file. No key-specific warning on a cache hit means the keys +were not checked, not that they are allowed. + +A key that is not a valid POSIX identifier is skipped with a stderr warning +from `fullsend run` only. If a proxy or certificate setting seems to be +ignored, look for those warnings. Dropping a key removes that one +`env.sandbox` export; it does not unset a value that reaches the sandbox +another way, as `host_files` `.env.d` does. + +This gate covers `env.sandbox` only: `host_files` `.env.d` content, discussed +above, is shell that the gate does not filter — it is sourced inside the sandbox +trusted like `pre_script`. ### Adding a skill diff --git a/docs/reference/harness-reference.md b/docs/reference/harness-reference.md index 2f5b83608f..d41c7c2f7d 100644 --- a/docs/reference/harness-reference.md +++ b/docs/reference/harness-reference.md @@ -171,7 +171,7 @@ breaks the hash-verified fetch cache. These rules make a run fail before `pre_script` starts: -- **Refused names.** A key in the object may not be a runner-owned name. That covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, `RUNNER_*`, `CI_*`, `LD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, and the sandbox-reserved names (`HOME`, `SHELL`, `TRACEPARENT`, …), and every name the reusable workflow sets on the `fullsend run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names may not receive a value from the object either. +- **Refused names.** A key in the object may not be a runner-owned name. That covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, `RUNNER_*`, `CI_*`, `LD_*`, `DYLD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, the runner-infrastructure names (`HOME`, `SHELL`, `BASH_ENV`, `ENV`, `TRACEPARENT`), and every name the reusable workflow sets on the `fullsend run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names may not receive a value from the object either. Credential-class names beyond the runner-infrastructure names, `PATH`, and the `LD_*`/`DYLD_*` families — proxy, TLS trust, Git, interpreter and shell-behavior variables such as `HTTPS_PROXY`, `SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and `HOSTALIASES` — are **not** refused here: runner secrets reach host-side scripts (`pre_script`, `post_script`, `validation_loop`) only as `env.runner` values, and the sandbox gate independently blocks them from `env.sandbox` exports. Names are matched case-insensitively, so `path` or `github_token` is refused like `PATH` or `GITHUB_TOKEN`. - **Host side only.** The object's names may be referenced only from `env.runner` values. A reference from `env.sandbox`, `runner_env`, a provider's `credentials` or `config`, a `host_files` `src`, the content of a `host_files` entry with `expand: true`, or a `validation_loop` field is a validation error. - **Overlays.** An overlay that references one of the object's names may be guarded only by `runtime.forge` and `config`. An overlay that reads `event` or any other `runtime` field is refused, even when it does not match. This rule is interim until [ADR 0112](../ADRs/0112-overlays-may-set-any-harness-field.md)'s guarded-field check is implemented; until then an event-guarded overlay can still swap `pre_script`, `post_script` or `validation_loop`, and so choose which script receives a referenced value. - **Shape.** The value must be a JSON object whose values are strings, with no duplicate keys and no `null` values. Each value must be at least as long as the redactor's minimum (currently 8 characters), so it can be redacted. Errors name the offending key, never its value. diff --git a/internal/cli/lock.go b/internal/cli/lock.go index 214eab50b5..48498999c3 100644 --- a/internal/cli/lock.go +++ b/internal/cli/lock.go @@ -198,6 +198,10 @@ func lockOneAgent(ctx context.Context, agentName, absFullsendDir, forgeFlag stri if !update && lf != nil { if entry := lf.Lookup(agentName); entry != nil && !entry.IsStale(harnessHash) { printer.StepDone(fmt.Sprintf("Lock entry for %s is up to date (%d dependencies)", agentName, len(entry.Dependencies))) + // A current dependency lock is not evidence that harness diagnostics + // ran under this CLI version. Keep the no-composition fast path, but + // make its reporting limit explicit instead of implying a clean lint. + printer.StepWarn(fmt.Sprintf("Harness diagnostics for %s were skipped because its lock entry is current; use --update to check reserved env.sandbox keys", agentName)) return nil, nil } } @@ -259,7 +263,7 @@ func lockOneAgent(ctx context.Context, agentName, absFullsendDir, forgeFlag stri } // Run lint diagnostics (non-fatal), deduplicating across forge variants - for _, diag := range h.Lint() { + for _, diag := range append(h.Lint(), reservedSandboxEnvDiagnostics(h)...) { key := diag.String() if !linted[key] { linted[key] = true diff --git a/internal/cli/lock_reserved_env_cache_test.go b/internal/cli/lock_reserved_env_cache_test.go new file mode 100644 index 0000000000..341648c549 --- /dev/null +++ b/internal/cli/lock_reserved_env_cache_test.go @@ -0,0 +1,103 @@ +package cli + +import ( + "bytes" + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/fullsend-ai/fullsend/internal/fetch" + "github.com/fullsend-ai/fullsend/internal/lock" + "github.com/fullsend-ai/fullsend/internal/ui" +) + +// A current lock entry skips composition as well as dependency resolution. +// Make that explicit rather than suggesting the absence of a warning means +// env.sandbox was checked. A missing base makes accidental composition fail; +// neither the single-harness nor --all path may rewrite the existing lock. +func TestLockCurrentEntry_ReportsSkippedDiagnostics(t *testing.T) { + t.Parallel() + + for _, all := range []bool{false, true} { + name := "single" + if all { + name = "all" + } + t.Run(name, func(t *testing.T) { + t.Parallel() + + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "harness"), 0o755)) + content := []byte("base: unavailable.yaml\nagent: https://example.invalid/agent.md\nrole: test\n" + + "env:\n sandbox:\n HTTPS_PROXY: http://proxy.example:8080\n") + require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "code.yaml"), content, 0o644)) + + lockPath := filepath.Join(dir, "lock.yaml") + lf := &lock.LockFile{Harnesses: map[string]lock.HarnessLock{ + "code": { + Source: "harness/code.yaml", SHA256: fetch.ComputeSHA256(content), + ResolvedAt: time.Unix(1, 0).UTC(), + Dependencies: []lock.DependencyEntry{{ + Field: "agent", URL: "https://example.invalid/agent.md", SHA256: "not-in-cache", + }}, + }, + }} + require.NoError(t, lock.Save(lockPath, lf)) + before, err := os.ReadFile(lockPath) + require.NoError(t, err) + stamp := time.Unix(1, 0) + require.NoError(t, os.Chtimes(lockPath, stamp, stamp)) + beforeInfo, err := os.Stat(lockPath) + require.NoError(t, err) + + var out bytes.Buffer + printer := ui.New(&out) + if all { + err = runLockAll(context.Background(), dir, "", false, resolveFlags{}, printer) + } else { + err = runLock(context.Background(), "code", dir, "", false, resolveFlags{}, printer) + } + require.NoError(t, err) + assert.Contains(t, out.String(), "up to date") + assert.Contains(t, out.String(), "Harness diagnostics for code were skipped") + assert.Contains(t, out.String(), "--update to check reserved env.sandbox keys") + assert.NotContains(t, out.String(), "HTTPS_PROXY", "no composed-key check was performed") + + after, err := os.ReadFile(lockPath) + require.NoError(t, err) + afterInfo, err := os.Stat(lockPath) + require.NoError(t, err) + assert.Equal(t, before, after, "a diagnostic notice must not refresh dependencies") + assert.Equal(t, beforeInfo.ModTime(), afterInfo.ModTime(), "the lock must not be rewritten") + _, err = os.Stat(filepath.Join(dir, ".fullsend-cache")) + assert.True(t, os.IsNotExist(err), "a cache hit must not compose or fetch resources") + }) + } +} + +func TestLockCurrentEntry_UpdateReportsReservedKeys(t *testing.T) { + t.Parallel() + + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "harness"), 0o755)) + content := []byte("base: base.yaml\nenv:\n sandbox:\n HTTPS_PROXY: http://proxy.example:8080\n") + require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "code.yaml"), content, 0o644)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "base.yaml"), + []byte("agent: agents/code.md\nrole: test\nenv:\n sandbox:\n PATH: /tmp/bin\n MY_TOOL_SETTING: keep-me\n"), 0o644)) + lf := &lock.LockFile{Harnesses: map[string]lock.HarnessLock{ + "code": {Source: "harness/code.yaml", SHA256: fetch.ComputeSHA256(content)}, + }} + + var out bytes.Buffer + _, err := lockOneAgent(context.Background(), "code", dir, "", true, lf, resolveFlags{}, ui.New(&out)) + require.NoError(t, err) + assert.Contains(t, out.String(), "2 env.sandbox key(s) are reserved") + assert.Contains(t, out.String(), "HTTPS_PROXY, PATH", "--update must check the composed base and child") + assert.NotContains(t, out.String(), "MY_TOOL_SETTING") + assert.NotContains(t, out.String(), "diagnostics for code were skipped") +} diff --git a/internal/cli/run.go b/internal/cli/run.go index b50e8227ee..f37ee48ed8 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -1170,7 +1170,9 @@ func runAgent(ctx context.Context, agentName, fullsendDir, outputBase, targetRep // Run lint checks before merging env.runner into RunnerEnv so that // Lint() sees the original YAML state and only warns when runner_env // was actually declared (not when env.runner entries are merged in). - for _, diag := range h.Lint() { + // reservedSandboxEnvDiagnostics rides along: it names the env.sandbox + // keys this run will drop instead of exporting them (#3373). + for _, diag := range append(h.Lint(), reservedSandboxEnvDiagnostics(h)...) { emitDiagnostic(printer, diag) } @@ -3289,8 +3291,14 @@ func harnessEnvLookup(key string) (string, bool) { // from harness YAML could break sandbox operation, or are security-sensitive // vars that could influence sandbox execution (e.g. shared library injection, // auto-sourced shell startup files). OIDC credential vars from oidcDenyKeys -// are merged in by init() to prevent re-injection into the sandbox (#5832). +// are merged in by init() to prevent re-injection into the sandbox (#5832), +// as is the sandbox credential deny-list (sandbox.ReservedCredentialKeys) so a +// name refused as a provider credential key cannot be injected here (#3373). +// Entries are matched case-insensitively; every name in the map is uppercase. // NOTE: keep in sync with bootstrapEnv exports below for FULLSEND_* keys. +// HOME, SHELL, BASH_ENV, ENV and TRACEPARENT are also literals in +// runnerSecretRefusedNames in runner_secrets.go; keep both sites in sync +// (see the NOTE there for which test pins each). var reservedSandboxKeys = map[string]bool{ "PATH": true, "HOME": true, @@ -3344,12 +3352,34 @@ func init() { // keys there; only credential values (child env) may expand them. sandbox.CredentialOnlyExpansionKeys(k) } + // The credential deny-list and env.sandbox reach child processes through + // different doors — a credential name lands in the host-side `openshell + // provider` environment, env.sandbox is exported inside the sandbox — but + // the risk a name carries is the same once it is in a child's + // environment. Merging rather than duplicating keeps one source of truth: + // a name added to the credential list is now blocked at both doors + // automatically (#3373). + for _, k := range sandbox.ReservedCredentialKeys() { + reservedSandboxKeys[k] = true + } +} + +// isReservedSandboxKey reports whether an env.sandbox key is blocked by name. +// Keys are case-folded because every entry in reservedSandboxKeys is stored +// uppercase, which TestReservedSandboxKeys_AreUppercase pins. The gate below +// and the lint diagnostics in reservedSandboxEnvDiagnostics both call this, so +// they cannot disagree about what a run drops (#3373). +func isReservedSandboxKey(k string) bool { + return reservedSandboxKeys[strings.ToUpper(k)] } // buildSandboxEnvLines generates export lines for env.sandbox values (ADR 0055). // Values have already been expanded by the caller. Each value is single-quoted -// with internal single quotes escaped. Keys that are not valid shell identifiers -// are silently skipped. +// with internal single quotes escaped. Keys that are not valid POSIX +// identifiers, and keys that isReservedSandboxKey rejects, are skipped with a +// warning on stderr; reservedSandboxEnvDiagnostics reports the reserved ones +// again as a lint diagnostic, so they also surface with the other harness +// warnings when the harness loads (#3373). func buildSandboxEnvLines(h *harness.Harness) []string { if h.Env == nil || len(h.Env.Sandbox) == 0 { return nil @@ -3360,8 +3390,18 @@ func buildSandboxEnvLines(h *harness.Harness) []string { fmt.Fprintf(os.Stderr, "WARNING: env.sandbox key %q is not a valid POSIX identifier; skipping\n", k) continue } - if reservedSandboxKeys[k] { - fmt.Fprintf(os.Stderr, "WARNING: env.sandbox key %q is reserved for runner infrastructure; skipping\n", k) + // Case-folded, like the credential and plugin doors. The two spellings + // are not interchangeable for the tools that read them: libcurl + // documents http_proxy as lowercase-only while other scheme proxies + // are also checked uppercase, and which of https_proxy and HTTPS_PROXY + // wins is upstream curl behavior, not something this repo controls. + // OpenShell also injects HTTPS_PROXY itself — see the 0.84.4 floor + // remark in the PI_VERSION comment in images/sandbox/Containerfile + // ("which the OpenShell sandbox always does"). Blocking one spelling + // while exporting the other would make the strength of this blocklist + // depend on tool internals (#3373). + if isReservedSandboxKey(k) { + fmt.Fprintf(os.Stderr, "WARNING: env.sandbox key %q is reserved (runner infrastructure or security deny-list); skipping\n", k) continue } keys = append(keys, k) diff --git a/internal/cli/run_reserved_credential_env_test.go b/internal/cli/run_reserved_credential_env_test.go index 349b4f9c81..516a6831e3 100644 --- a/internal/cli/run_reserved_credential_env_test.go +++ b/internal/cli/run_reserved_credential_env_test.go @@ -1,69 +1,166 @@ package cli import ( + "os" + "path/filepath" + "regexp" "strings" "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/fullsend-ai/fullsend/internal/harness" + "github.com/fullsend-ai/fullsend/internal/sandbox" ) -// envSandboxSecurityKeys mirrors reservedCredentialKeys in -// internal/sandbox/sandbox.go, which is unexported and therefore unreadable -// from this package. -// -// This is deliberately a copy rather than a live probe. Probing the credential -// path (sandbox.EnsureProvider returns a reserved-key error before exec) would -// need the PATH guard its own test uses to keep a non-refused name from -// executing a real openshell, and t.Setenv in a sequential test leaks the -// mutated PATH to parallel tests elsewhere in this package. Reproducing the -// invariant without touching process state is the better trade here. -// -// The permanent fix is one shared list consumed by both doors; until then a -// name added to reservedCredentialKeys must be added here too. See -// internal/sandbox/reserved_env_drift_test.go, which guards the plugin-env -// door the same way. -var envSandboxSecurityKeys = []string{ - // Process loading / shell behavior — already reserved, kept to pin it. +// reservedInfraSandboxKeys are the seven process-loading names env.sandbox has +// rejected since before #3373 widened the blocklist to the credential +// deny-list. All seven are also members of reservedCredentialKeys, under its +// Process loading / shell behavior group, so the loop below asserts them twice +// — deliberately: keeping them here means the sandbox door still pins them if +// a name is ever dropped from the credential door. Some of the other +// infrastructure names are pinned elsewhere — TRACEPARENT in run_test.go, the +// runner PATH variable in run_env_path_test.go, and FULLSEND_FETCH_TOKEN and +// FULLSEND_OUTPUT_DIR in TestBuildSandboxEnvLines_SkipsReservedKeys. +var reservedInfraSandboxKeys = []string{ "PATH", "HOME", "SHELL", "LD_PRELOAD", "LD_LIBRARY_PATH", "BASH_ENV", "ENV", - // Proxy — could redirect sandbox HTTP traffic - "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "ALL_PROXY", - // Subprocess-influencing runtime vars - "NODE_OPTIONS", "PYTHONPATH", "PROMPT_COMMAND", - // Word splitting / cd resolution - "IFS", "CDPATH", - // Language runtime injection — arbitrary code at process start - "JAVA_TOOL_OPTIONS", "RUBYOPT", "PERL5OPT", "PYTHONSTARTUP", - // Dynamic linker audit and macOS interpose — shared-object loading - "LD_AUDIT", "DYLD_INSERT_LIBRARIES", - // TLS trust chain — validation redirected to an attacker-controlled CA - "SSL_CERT_FILE", "SSL_CERT_DIR", "CURL_CA_BUNDLE", "NODE_EXTRA_CA_CERTS", - // Hostname resolution redirect - "HOSTALIASES", - // Git config — can inject hooks or redirect operations - "GIT_CONFIG_GLOBAL", "GIT_EXEC_PATH", "GIT_SSH_COMMAND", "GIT_TEMPLATE_DIR", "GIT_ASKPASS", } // TestReservedSandboxKeys_CoversReservedCredentialKeys pins the invariant that // a variable unsafe as a provider credential key is equally unsafe injected via -// env.sandbox: both paths end up as environment variables in the same sandbox -// child process, so a gap between the two blocklists is a bypass of the -// credential deny-list through harness YAML (#3373). +// env.sandbox. The doors write different environments — a credential lands in +// the host-side `openshell provider` process, env.sandbox is exported inside +// the sandbox — but the exposure a name creates is the same once it is set in +// a child's environment, so a gap between the two blocklists is a way to set +// that name from harness YAML (#3373). +// +// The credential half is read live from sandbox.ReservedCredentialKeys instead +// of being copied, so a name added to the credential door is asserted here the +// moment it is added there. The accessor test in internal/sandbox pins that the +// list it returns is complete; the guard below keeps a hollowed-out accessor +// from quietly reducing this test to the infrastructure names alone. func TestReservedSandboxKeys_CoversReservedCredentialKeys(t *testing.T) { t.Parallel() - for _, key := range envSandboxSecurityKeys { + + credentialKeys := sandbox.ReservedCredentialKeys() + require.NotEmpty(t, credentialKeys, + "sandbox.ReservedCredentialKeys returned no names; this test would silently stop covering the credential door") + + for _, key := range append(credentialKeys, reservedInfraSandboxKeys...) { t.Run(key, func(t *testing.T) { t.Parallel() - assert.Truef(t, reservedSandboxKeys[key], + assert.True(t, reservedSandboxKeys[key], "reservedSandboxKeys must include %s: env.sandbox can inject a variable the credential path refuses", key) lines := buildSandboxEnvLines(&harness.Harness{ Env: &harness.EnvConfig{Sandbox: map[string]string{key: "/tmp/evil"}}, }) - assert.NotContainsf(t, strings.Join(lines, "\n"), "export "+key+"=", + assert.NotContains(t, strings.Join(lines, "\n"), "export "+key+"=", "buildSandboxEnvLines leaked %s into the sandbox environment", key) }) } } + +// guideEnvNameRe matches a backticked, all-uppercase environment variable name +// as the user guide writes them. It deliberately will not match a partial +// family like `FULLSEND_OPENAI_*`, since that is prose about a family rather +// than a name the gate can be checked against. +var guideEnvNameRe = regexp.MustCompile("`([A-Z][A-Z0-9_]{2,})`") + +// documentedPassthroughNames are the names the guide's env.sandbox note says +// are still delivered through env.sandbox. They are the carve-out, so they are +// asserted in the opposite direction from everything else in that paragraph. +var documentedPassthroughNames = map[string]bool{ + "FULLSEND_CANARY_TOKEN": true, + "FULLSEND_TOOL_ALLOWLIST": true, +} + +// TestGuideNamesMatchTheGate reads the user guide itself rather than a copy of +// its list, in both directions: every name the note claims is dropped must +// really be blocked by the gate, and every name the note promises is delivered +// must really get through. A hand-copied list could only ever agree with +// itself, so a name added to the guide without a matching gate change — the +// same drift #3373 is about, one level up — would pass unnoticed. The count +// guard keeps this test from going quietly vacuous if the prose is reworded. +func TestGuideNamesMatchTheGate(t *testing.T) { + t.Parallel() + + const marker = "**Note**: `env.sandbox` cannot modify runner infrastructure" + + data, err := os.ReadFile(filepath.Join("..", "..", "docs", "guides", "user", "customizing-agents.md")) + require.NoError(t, err) + + start := strings.Index(string(data), marker) + require.Greater(t, start, 0, + "the env.sandbox note was renamed or moved; update this test along with the guide") + note := string(data)[start:] + // The note is a lead-in plus a bulleted enumeration, so it spans several + // markdown blocks. Stop at the sentence that closes it: a missing + // terminator would silently widen the scan into the reporting paragraphs, + // which name nothing the gate is being asked about. + end := strings.Index(note, "Matching is case-insensitive") + require.Greater(t, end, 0, + "the env.sandbox note no longer ends at that sentence; update this terminator along with the prose") + note = note[:end] + + matches := guideEnvNameRe.FindAllStringSubmatch(note, -1) + // The floor is what keeps this test from failing silently: a reworded + // paragraph the pattern no longer matches would otherwise scan zero names + // and pass. The note enumerates in the low fifties today, including the + // two pass-through names in the carve-out sentence, so a floor in the + // fifties also catches a whole bullet being dropped from the prose. + require.GreaterOrEqual(t, len(matches), 50, + "the note enumerates in the low fifties but only %d matched, so either the pattern no longer fits the prose or names were dropped from it — this test proves nothing until one of those is fixed", + len(matches)) + + // The pass-through set is a second copy of what the prose promises, so pin + // that the prose still promises it. Without this, rewording the carve-out + // sentence so it stops backticking these names would leave the branch + // below running over a set nothing supplies, and the test would quietly + // check one direction instead of two. + for name := range documentedPassthroughNames { + assert.Contains(t, note, "`"+name+"`", + "the guide no longer documents %s as delivered through env.sandbox; either restore it or drop it from documentedPassthroughNames", + name) + } + + for _, m := range matches { + name := m[1] + t.Run(name, func(t *testing.T) { + t.Parallel() + + if documentedPassthroughNames[name] { + assert.False(t, isReservedSandboxKey(name), + "the guide says %s is still delivered through env.sandbox, but the gate now drops it", name) + return + } + assert.True(t, isReservedSandboxKey(name), + "the guide names %s as dropped from env.sandbox, but the gate accepts it", name) + }) + } +} + +// TestDocumentedPassthroughNames_StayDelivered pins the other half of the same +// paragraph, which promises that hook inputs the harness supplies deliberately +// still arrive. Blocking them would break the SSRF and allowlist hooks, so the +// guide's carve-out is worth a test as much as the blocklist is. +func TestDocumentedPassthroughNames_StayDelivered(t *testing.T) { + t.Parallel() + + for _, key := range []string{"FULLSEND_CANARY_TOKEN", "FULLSEND_TOOL_ALLOWLIST"} { + t.Run(key, func(t *testing.T) { + t.Parallel() + + require.False(t, reservedSandboxKeys[key], + "the guide says %s is still delivered through env.sandbox", key) + + lines := buildSandboxEnvLines(&harness.Harness{ + Env: &harness.EnvConfig{Sandbox: map[string]string{key: "value"}}, + }) + assert.Contains(t, strings.Join(lines, "\n"), "export "+key+"=", + "the guide promises %s reaches the sandbox, but the gate dropped it", key) + }) + } +} diff --git a/internal/cli/run_reserved_env_case_test.go b/internal/cli/run_reserved_env_case_test.go new file mode 100644 index 0000000000..ebea9b40c4 --- /dev/null +++ b/internal/cli/run_reserved_env_case_test.go @@ -0,0 +1,66 @@ +package cli + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/fullsend-ai/fullsend/internal/harness" +) + +// TestBuildSandboxEnvLines_ReservesCaseInsensitively pins that the env.sandbox +// gate matches reserved names the way the provider-credential and plugin-env +// doors already do. Every name in reservedSandboxKeys is stored uppercase, so +// before the fold the proxy names merged in from reservedCredentialKeys were +// reachable through their lowercase spelling — and libcurl documents +// http_proxy as lowercase-only, so an exact-case gate blocks a spelling tools +// may not read while exporting the one they do. The comment on +// buildSandboxEnvLines carries the full rationale (#3373). +func TestBuildSandboxEnvLines_ReservesCaseInsensitively(t *testing.T) { + t.Parallel() + + cases := []struct { + key string + why string + }{ + {"HTTPS_PROXY", "uppercase, the spelling stored in the blocklist"}, + {"https_proxy", "lowercase spelling of a reserved proxy name"}, + {"HtTp_PrOxY", "mixed case"}, + {"NO_PROXY", "uppercase no_proxy bypass"}, + {"no_proxy", "lowercase no_proxy bypass"}, + {"GIT_SSH_COMMAND", "uppercase git command injection"}, + {"git_ssh_command", "lowercase git command injection"}, + {"Node_OPTIONS", "mixed-case interpreter injection"}, + } + + for _, tc := range cases { + t.Run(tc.key, func(t *testing.T) { + t.Parallel() + + assert.True(t, reservedSandboxKeys[strings.ToUpper(tc.key)], + "reservedSandboxKeys must cover %s through its uppercase form (%s)", tc.key, tc.why) + + lines := buildSandboxEnvLines(&harness.Harness{ + Env: &harness.EnvConfig{Sandbox: map[string]string{tc.key: "http://evil.example:8080"}}, + }) + assert.Empty(t, lines, + "buildSandboxEnvLines leaked %s into the sandbox environment (%s): %v", tc.key, tc.why, lines) + }) + } +} + +// TestReservedSandboxKeys_AreUppercase pins the invariant the case-folded gate +// is built on. The gate looks keys up as +// reservedSandboxKeys[strings.ToUpper(k)], which only works because every +// entry is stored uppercase — a name added later in mixed or lower case would +// be unmatchable and therefore silently unenforceable, with no other test +// catching it. +func TestReservedSandboxKeys_AreUppercase(t *testing.T) { + t.Parallel() + + for key := range reservedSandboxKeys { + assert.Equal(t, strings.ToUpper(key), key, + "reservedSandboxKeys entry %q is not uppercase, so the case-folded env.sandbox gate can never match it", key) + } +} diff --git a/internal/cli/run_reserved_env_lint.go b/internal/cli/run_reserved_env_lint.go new file mode 100644 index 0000000000..8f806e6282 --- /dev/null +++ b/internal/cli/run_reserved_env_lint.go @@ -0,0 +1,66 @@ +package cli + +import ( + "fmt" + "sort" + "strings" + + "github.com/fullsend-ai/fullsend/internal/harness" +) + +// reservedSandboxEnvDiagnostics reports the env.sandbox keys that +// buildSandboxEnvLines will drop because they are reserved. +// +// The gate itself only warns on stderr while .env is being written, deep inside +// a run. Surfacing the same keys as lint diagnostics puts them next to the +// rest of the harness warnings, right after the harness loads and in +// `fullsend lock`, so a harness that quietly lost a proxy or CA setting is +// visible before a sandbox ever starts. #3373 widened the dropped set from the +// runner-infrastructure names to the full credential deny-list, which made +// silent removal a breaking change worth reporting rather than logging. +// +// It asks isReservedSandboxKey, the predicate the gate itself applies, and it +// skips keys the gate rejects as invalid identifiers before that, so it cannot +// report a key the gate dropped for some other reason. Both callers pass the +// harness before env.runner is merged into RunnerEnv, so the warning reflects +// what the user wrote; base, overlay and forge merging has already happened +// inside the loader by then, and nothing rewrites env.sandbox keys after it. +func reservedSandboxEnvDiagnostics(h *harness.Harness) []harness.Diagnostic { + if h == nil || h.Env == nil || len(h.Env.Sandbox) == 0 { + return nil + } + + var dropped []string + for k := range h.Env.Sandbox { + // The gate rejects invalid identifiers before it consults the + // blocklist, and case folding alone does not keep the two lists + // identical: strings.ToUpper folds non-ASCII lookalikes onto reserved + // names, so "ſHELL" would read here as PATH's blocked sibling while + // the gate drops it as not a POSIX identifier. Reporting that as + // reserved would name the key twice under a false heading. + if !validEnvKeyRe.MatchString(k) { + continue + } + if isReservedSandboxKey(k) { + dropped = append(dropped, k) + } + } + if len(dropped) == 0 { + return nil + } + // Map iteration order is random. The sort keeps the message stable, which + // is what lets lock's cross-variant de-duplication recognise a repeat of + // this diagnostic as the same one. + sort.Strings(dropped) + + return []harness.Diagnostic{{ + Severity: harness.SeverityWarning, + Field: "env.sandbox", + Message: fmt.Sprintf("%d env.sandbox key(s) are reserved and will be dropped instead of exported "+ + "into the sandbox: %s. Matching is case-insensitive. Proxy and certificate settings can move to "+ + "host_files .env.d or to a named configuration field; runner credentials and runner-owned "+ + "infrastructure names are not deliverable to the sandbox by design. "+ + "See docs/guides/user/customizing-agents.md.", + len(dropped), strings.Join(dropped, ", ")), + }} +} diff --git a/internal/cli/run_reserved_env_lint_test.go b/internal/cli/run_reserved_env_lint_test.go new file mode 100644 index 0000000000..adfaa492ce --- /dev/null +++ b/internal/cli/run_reserved_env_lint_test.go @@ -0,0 +1,234 @@ +package cli + +import ( + "bytes" + "context" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/fullsend-ai/fullsend/internal/harness" + "github.com/fullsend-ai/fullsend/internal/ui" +) + +func TestReservedSandboxEnvDiagnostics_ReportsDroppedKeys(t *testing.T) { + t.Parallel() + + h := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{ + "PATH": "/tmp/bin", + "HTTPS_PROXY": "http://evil.example:8080", + "CUSTOM_VAR": "fine", + "FULLSEND_ROLE": "coder", + "GH_WORKFLOW_TOKEN": "ghp_x", + }}} + + diags := reservedSandboxEnvDiagnostics(h) + require.Len(t, diags, 1, "the reserved keys collapse into one warning") + assert.Equal(t, harness.SeverityWarning, diags[0].Severity) + assert.Equal(t, "env.sandbox", diags[0].Field) + + // Every key the gate will drop is named, and only those keys. + for _, key := range []string{"PATH", "HTTPS_PROXY", "FULLSEND_ROLE", "GH_WORKFLOW_TOKEN"} { + assert.Contains(t, diags[0].Message, key, + "the warning must name %s, which buildSandboxEnvLines will drop", key) + } + assert.NotContains(t, diags[0].Message, "CUSTOM_VAR", + "a key that survives must not be reported") + + // GH_WORKFLOW_TOKEN arrives through the providerOnlyKeys merge and + // FULLSEND_ROLE is a runner-infrastructure name, so a warning that names + // both proves this reads the merged gate list, not one hand-written set. + assert.True(t, reservedSandboxKeys["GH_WORKFLOW_TOKEN"], "precondition: merged into the gate") + // Four keys dropped, so the count in the message is the count that was cut. + assert.Contains(t, diags[0].Message, "4 env.sandbox key(s) are reserved") + + // The guidance is load-bearing for a breaking change: a warning that names + // the keys but not the case rule or where to read about it leaves the user + // to guess. Pin the parts that matter rather than the whole sentence. + assert.Contains(t, diags[0].Message, "Matching is case-insensitive") + assert.Contains(t, diags[0].Message, "docs/guides/user/customizing-agents.md") +} + +func TestReservedSandboxEnvDiagnostics_MatchesGateCaseFolding(t *testing.T) { + t.Parallel() + + h := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{ + "https_proxy": "http://evil.example:8080", + "HtTp_PrOxY": "http://evil.example:8081", + }}} + + diags := reservedSandboxEnvDiagnostics(h) + require.Len(t, diags, 1) + assert.Contains(t, diags[0].Message, "https_proxy") + assert.Contains(t, diags[0].Message, "HtTp_PrOxY") + + // The point of the case fold: the gate really does drop both spellings, so + // the warning is not overstating what a run loses. + lines := buildSandboxEnvLines(h) + for _, line := range lines { + assert.NotContains(t, line, "evil.example", "nothing reserved may be exported") + } + assert.Empty(t, lines) +} + +func TestReservedSandboxEnvDiagnostics_CleanHarness(t *testing.T) { + t.Parallel() + + for name, env := range map[string]*harness.EnvConfig{ + "nil harness env": nil, + "empty sandbox map": {Sandbox: map[string]string{}}, + "only allowed values": {Sandbox: map[string]string{"PIP_INDEX_URL": "https://pypi.example/simple"}}, + } { + t.Run(name, func(t *testing.T) { + t.Parallel() + + h := &harness.Harness{Env: env} + assert.Nil(t, reservedSandboxEnvDiagnostics(h), + "a harness the gate drops nothing from must produce no warning") + }) + } + + assert.Nil(t, reservedSandboxEnvDiagnostics(nil), "a nil harness must not panic") +} + +// TestReservedSandboxEnvDiagnostics_AgreesWithTheGate is the drift guard: it +// feeds every reserved name back through both the diagnostic and the gate, so +// the warning cannot start lying about what a run drops. It reads the same map +// the gate consults, so a name added to any merged list is covered here the +// moment it is added. +func TestReservedSandboxEnvDiagnostics_AgreesWithTheGate(t *testing.T) { + t.Parallel() + + for key := range reservedSandboxKeys { + t.Run(key, func(t *testing.T) { + t.Parallel() + + h := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{key: "x"}}} + diags := reservedSandboxEnvDiagnostics(h) + require.Len(t, diags, 1, "%s is reserved, so it must be reported", key) + assert.True(t, strings.Contains(diags[0].Message, key)) + assert.Empty(t, buildSandboxEnvLines(h), "%s must not reach the sandbox", key) + }) + } +} + +// TestReservedSandboxEnvDiagnostics_ReportsInSortedOrder pins the exact list +// text rather than membership. lock de-duplicates diagnostics across forge +// variants by diag.String(), and the keys arrive from map iteration, so +// without the sort one harness can produce two differently ordered strings and +// print the same warning once per variant. +func TestReservedSandboxEnvDiagnostics_ReportsInSortedOrder(t *testing.T) { + t.Parallel() + + h := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{ + "PATH": "/tmp/bin", "HTTPS_PROXY": "http://evil:8080", + "GH_WORKFLOW_TOKEN": "ghp_x", "FULLSEND_ROLE": "coder", + }}} + + diags := reservedSandboxEnvDiagnostics(h) + require.Len(t, diags, 1) + assert.Contains(t, diags[0].Message, "FULLSEND_ROLE, GH_WORKFLOW_TOKEN, HTTPS_PROXY, PATH", + "the list must be byte-sorted, not in random map order") + + // A dropped sort would eventually reorder; one sample would not catch it. + seen := map[string]bool{} + for range 50 { + seen[reservedSandboxEnvDiagnostics(h)[0].Message] = true + } + assert.Len(t, seen, 1, "the message must be byte-identical across runs") +} + +// TestReservedSandboxEnvDiagnostics_SkipsInvalidIdentifiers covers what case +// folding does not: strings.ToUpper folds non-ASCII lookalikes onto reserved +// names, so a key the gate rejects as "not a valid POSIX identifier" must not +// be reported to the user as a reserved-name drop. +func TestReservedSandboxEnvDiagnostics_SkipsInvalidIdentifiers(t *testing.T) { + t.Parallel() + + require.Equal(t, "SHELL", strings.ToUpper("ſHELL"), "precondition: case folding collides with a reserved name") + require.Equal(t, "IFS", strings.ToUpper("ıFS"), "precondition: case folding collides with a reserved name") + + invalid := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{ + "ſHELL": "/tmp/sh", + "ıFS": " ", + }}} + assert.Nil(t, reservedSandboxEnvDiagnostics(invalid), + "invalid identifiers are the gate's other rejection, not a reserved-name drop") + + mixed := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{ + "ſHELL": "/tmp/sh", + "HTTPS_PROXY": "http://evil:8080", + }}} + diags := reservedSandboxEnvDiagnostics(mixed) + require.Len(t, diags, 1) + assert.Contains(t, diags[0].Message, "1 env.sandbox key(s)", + "only the genuinely reserved key may be counted") + assert.NotContains(t, diags[0].Message, "ſHELL") +} + +// TestLockOneAgent_ReportsReservedSandboxEnvKeys pins the wiring, not the +// helper: every other test in this file calls reservedSandboxEnvDiagnostics +// directly, so deleting it from the append in lock.go would otherwise leave +// the suite green while the user stops hearing about dropped keys. +func TestLockOneAgent_ReportsReservedSandboxEnvKeys(t *testing.T) { + t.Parallel() + + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "harness"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "code.yaml"), + []byte("agent: agents/code.md\nrole: test\n"+ + "env:\n sandbox:\n HTTPS_PROXY: http://proxy.example:8080\n"+ + " MY_TOOL_SETTING: keep-me\n"), 0o644)) + + var out bytes.Buffer + _, err := lockOneAgent(context.Background(), "code", dir, "", false, nil, resolveFlags{}, ui.New(&out)) + require.NoError(t, err) + + assert.Contains(t, out.String(), "HTTPS_PROXY", + "lock must warn about the key the run will drop") + assert.NotContains(t, out.String(), "MY_TOOL_SETTING", + "a key that survives must not be named") +} + +// TestRunAgent_ReportsReservedSandboxEnvKeys pins the same wiring on the run +// side, which is where the key is actually lost. The lint loop sits well above +// the pre-script block, so a harness whose pre-script requests a skip returns +// before any sandbox exists while still having passed through the loop — the +// cheapest way to drive it. Deleting reservedSandboxEnvDiagnostics from that +// append would otherwise leave the suite green and reduce `fullsend run` to +// the stderr warning that only appears while the sandbox environment is +// written. +func TestRunAgent_ReportsReservedSandboxEnvKeys(t *testing.T) { + usePreScriptStub(t) + + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "harness"), 0o755)) + require.NoError(t, os.MkdirAll(filepath.Join(dir, "agents"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "agents", "code.md"), + []byte("You are a coding agent."), 0o644)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "config.yaml"), + []byte("agents:\n - harness/code.yaml\n"), 0o644)) + writePolicyFixture(t, dir) + + skip := writePreScript(t, `echo "skipped=true" >> "${FULLSEND_PRESCRIPT_OUTPUT}"`+"\n") + require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "code.yaml"), + []byte("agent: agents/code.md\nrole: test\npolicy: policies/base.yaml\n"+ + "pre_script: "+skip+"\n"+ + "env:\n sandbox:\n HTTPS_PROXY: http://proxy.example:8080\n"+ + " MY_TOOL_SETTING: keep-me\n"), 0o644)) + + var out bytes.Buffer + err := runAgent(context.Background(), "code", dir, "", t.TempDir(), "", nil, false, + "", "", "", resolveFlags{maxDepth: 10, maxResources: 50}, statusOpts{}, + ui.New(&out), false, runOverrideFlags{}) + require.NoError(t, err) + + assert.Contains(t, out.String(), "HTTPS_PROXY", + "run must warn about the key it is about to drop, before the sandbox exists") + assert.NotContains(t, out.String(), "MY_TOOL_SETTING", + "a key that survives must not be named") +} diff --git a/internal/cli/runner_secrets.go b/internal/cli/runner_secrets.go index 40bdf60a23..7921525466 100644 --- a/internal/cli/runner_secrets.go +++ b/internal/cli/runner_secrets.go @@ -37,6 +37,9 @@ var runnerSecretRefusedPrefixes = []string{ "RUNNER_", "CI_", "LD_", + // macOS dynamic-linker injection (#3373). The plugin door refuses the + // whole prefix; the env.sandbox gate refuses only DYLD_INSERT_LIBRARIES. + "DYLD_", "OTEL_", // google-github-actions/auth exports these for the job. "GOOGLE_", @@ -66,14 +69,35 @@ var workflowSetEnvNames = []string{ // runnerSecretRefusedNames are minted role tokens and other runner-owned // names outside the refused families: GH_TOKEN, every role token in -// roleTokenVars, GITLAB_TOKEN, PATH and workflowSetEnvNames. oidcDenyKeys, providerOnlyKeys and -// reservedSandboxKeys are refused as well (runnerSecretNameRefused), which -// keeps GH_WORKFLOW_TOKEN (ADR 0114) unforgeable. +// roleTokenVars, GITLAB_TOKEN, PATH and workflowSetEnvNames. oidcDenyKeys and +// providerOnlyKeys are refused as well via harnessExpansionDenied +// (runnerSecretNameRefused), which keeps GH_WORKFLOW_TOKEN (ADR 0114) +// unforgeable. The runner infrastructure names HOME, SHELL, BASH_ENV, ENV and +// TRACEPARENT are listed here rather than read from reservedSandboxKeys: +// #3373 widened that map with credential-class names (proxy, TLS trust, git, +// interpreter, loader and shell-behavior) that are dangerous inside the +// sandbox child but not as host-side runner-secret keys for host-side +// scripts. Sharing the map made every credential name also fail the +// runner-secret bundle check after the merge, breaking legitimate host-side +// proxy and CA configuration. The two doors keep separate name sets on +// purpose. +// +// NOTE: HOME, SHELL, BASH_ENV, ENV and TRACEPARENT are also literals in +// reservedSandboxKeys in run.go; keep both sites in sync. The four +// process-loading names (HOME, SHELL, BASH_ENV, ENV) are pinned at this +// door by TestRunnerSecretNameRefused_AllowsCredentialClassNames (the +// dualClass set); TRACEPARENT is pinned by +// TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames. var runnerSecretRefusedNames = func() map[string]bool { names := map[string]bool{ "GH_TOKEN": true, "GITLAB_TOKEN": true, "PATH": true, + "HOME": true, + "SHELL": true, + "BASH_ENV": true, + "ENV": true, + "TRACEPARENT": true, } for _, n := range workflowSetEnvNames { names[n] = true @@ -98,13 +122,17 @@ func runnerSecretDisplayName(name string) string { // runnerSecretNameRefused reports whether name is runner-owned and so may // neither be a key in FULLSEND_GITHUB_RUNNER_SECRETS nor receive a runner secret -// value as an env.runner key. +// value as an env.runner key. Matched case-insensitively, consistent with +// the env.sandbox gate (isReservedSandboxKey), so "path" is refused like +// "PATH" (zsh ties a few lowercase arrays such as path to their uppercase +// scalars). func runnerSecretNameRefused(name string) bool { - if harnessExpansionDenied(name) || reservedSandboxKeys[name] || runnerSecretRefusedNames[name] { + upper := strings.ToUpper(name) + if harnessExpansionDenied(upper) || runnerSecretRefusedNames[upper] { return true } for _, p := range runnerSecretRefusedPrefixes { - if strings.HasPrefix(name, p) { + if strings.HasPrefix(upper, p) { return true } } diff --git a/internal/cli/runner_secrets_test.go b/internal/cli/runner_secrets_test.go index 1046e33a99..f363d0a558 100644 --- a/internal/cli/runner_secrets_test.go +++ b/internal/cli/runner_secrets_test.go @@ -14,6 +14,7 @@ import ( "github.com/fullsend-ai/fullsend/internal/harness" "github.com/fullsend-ai/fullsend/internal/prescript" + "github.com/fullsend-ai/fullsend/internal/sandbox" "github.com/fullsend-ai/fullsend/internal/security" "github.com/fullsend-ai/fullsend/internal/ui" "gopkg.in/yaml.v3" @@ -409,6 +410,119 @@ func TestRunnerSecretNameRefused_AllowsOrdinaryNames(t *testing.T) { } } +// TestRunnerSecretNameRefused_AllowsCredentialClassNames pins the two-door +// split introduced with #3373: credential-class names are refused by the +// env.sandbox gate (isReservedSandboxKey) because they are dangerous inside +// the sandbox child, but they are accepted as runner-secret keys because +// runner secrets stay on the host side for host-side scripts. Before this +// split, runnerSecretNameRefused read reservedSandboxKeys directly, so the +// #3373 merge made every credential name also fail the runner-secret bundle +// check, breaking legitimate host-side proxy and CA configuration. +// +// The credential half reads sandbox.ReservedCredentialKeys() live rather +// than copying names, following the package's drift-guard convention: a +// name added to the credential list is pinned for both doors the moment +// it is added. Names that are dual-class — both credential-list entries +// and runner infrastructure — are asserted as refused at both doors, not +// skipped. The dual-class set comes from reservedInfraSandboxKeys +// (run_reserved_credential_env_test.go), which is maintained by hand: a +// name later added to both the credential list and the infrastructure +// literals fails this test until that slice is updated. LD_- and +// DYLD_-prefixed credential names are refused at the runner-secret door by +// the matching prefixes in runnerSecretRefusedPrefixes, because the dynamic +// loader reads them on the host side too. +func TestRunnerSecretNameRefused_AllowsCredentialClassNames(t *testing.T) { + t.Parallel() + + credentialKeys := sandbox.ReservedCredentialKeys() + require.NotEmpty(t, credentialKeys, "no credential names to probe; this test is vacuous") + + // Dual-class names: in the credential list AND the runner infrastructure + // literals, taken from the hand-maintained reservedInfraSandboxKeys. + dualClass := make(map[string]bool, len(reservedInfraSandboxKeys)) + for _, name := range reservedInfraSandboxKeys { + dualClass[name] = true + } + + for _, name := range credentialKeys { + t.Run(name, func(t *testing.T) { + t.Parallel() + + assert.True(t, isReservedSandboxKey(name), + "%s must be refused by the env.sandbox gate", name) + + if dualClass[name] || strings.HasPrefix(name, "LD_") || strings.HasPrefix(name, "DYLD_") { + // Also refused as a runner-secret key: runner infrastructure + // (PATH, HOME, SHELL, BASH_ENV, ENV) or dynamic-loader names. + assert.True(t, runnerSecretNameRefused(name), + "%s is dual-class (credential and infrastructure) and must stay refused at both doors", name) + } else { + assert.False(t, runnerSecretNameRefused(name), + "%s is credential-class only: refused in env.sandbox, not as a runner-secret key for host-side scripts", name) + } + }) + } + + // Runner-only infrastructure names (not in the credential list) stay + // refused at both doors. + t.Run("TRACEPARENT", func(t *testing.T) { + t.Parallel() + + assert.True(t, runnerSecretNameRefused("TRACEPARENT"), + "TRACEPARENT is runner infrastructure and must stay refused as a runner-secret key") + assert.True(t, isReservedSandboxKey("TRACEPARENT"), + "TRACEPARENT must also stay refused by the env.sandbox gate") + }) +} + +// TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames is the drift +// guard for the two-door split: every name in reservedSandboxKeys that does +// not come from sandbox.ReservedCredentialKeys() must still be refused as a +// runner-secret key. Before the split, reading reservedSandboxKeys directly +// provided this coverage for free. Now that runnerSecretNameRefused uses its +// own set, a non-prefixed infrastructure name added to the sandbox map +// without a corresponding runnerSecretRefusedNames entry would silently +// stop being refused here. This test catches that divergence the same way +// TestReservedSandboxKeys_CoversReservedCredentialKeys pins the credential +// merge and internal/sandbox/reserved_env_drift_test.go pins the +// plugin-superset invariant. +func TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames(t *testing.T) { + t.Parallel() + + keys := sandbox.ReservedCredentialKeys() + credentialNames := make(map[string]bool, len(keys)) + for _, k := range keys { + credentialNames[k] = true + } + require.NotEmpty(t, credentialNames, "no credential names to exclude; the drift check is vacuous") + + for name := range reservedSandboxKeys { + if credentialNames[name] { + // Dual-class names (PATH, HOME, SHELL, LD_PRELOAD, etc.) are + // pinned in AllowsCredentialClassNames above; names that are + // credential-only are deliberately allowed at this door. This + // test covers the non-credential infrastructure half only. + continue + } + assert.True(t, runnerSecretNameRefused(name), + "%s is in reservedSandboxKeys but not from the credential list; it must stay refused as a runner-secret key. Add it to runnerSecretRefusedNames or a refused prefix.", name) + } +} + +// TestRunnerSecretNameRefused_CaseInsensitive pins the case fold: a +// lowercase or mixed-case key is refused exactly when its uppercase form +// is, and credential-class names stay allowed in any case. +func TestRunnerSecretNameRefused_CaseInsensitive(t *testing.T) { + t.Parallel() + + for _, name := range []string{"path", "Home", "github_x", "ld_preload", "dyld_library_path", "fullsend_x", "jira_token"} { + assert.True(t, runnerSecretNameRefused(name), "%s must be refused regardless of case", name) + } + for _, name := range []string{"https_proxy", "ssl_cert_file", "my_secret"} { + assert.False(t, runnerSecretNameRefused(name), "%s must stay allowed", name) + } +} + func TestValidateRunnerSecretRefs(t *testing.T) { secrets := map[string]string{"X": "value-123456"} diff --git a/internal/sandbox/reserved_credential_keys_test.go b/internal/sandbox/reserved_credential_keys_test.go new file mode 100644 index 0000000000..514dd49e9c --- /dev/null +++ b/internal/sandbox/reserved_credential_keys_test.go @@ -0,0 +1,77 @@ +package sandbox + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestReservedCredentialKeys pins the accessor that internal/cli merges into +// its own sandbox env blocklist (#3373). It must expose the complete reserved +// set — a silently narrowed list would reopen the drift this exists to close — +// in a stable order, and hand back a copy callers cannot use to mutate package +// state. +func TestReservedCredentialKeys(t *testing.T) { + t.Parallel() + + keys := ReservedCredentialKeys() + require.Len(t, keys, len(reservedCredentialKeys), + "accessor must expose every reserved credential key") + + returned := make(map[string]bool, len(keys)) + for _, k := range keys { + require.True(t, reservedCredentialKeys[k], + "accessor returned %s, which is not a reserved credential key", k) + returned[k] = true + } + for k := range reservedCredentialKeys { + assert.True(t, returned[k], "accessor omitted reserved credential key %s", k) + } + + assert.True(t, sort.StringsAreSorted(keys), + "accessor must return a deterministic order; its contract is exported") + + // The slice is the caller's to corrupt — and a later caller must still get + // a clean list, which is what fails if the accessor ever memoizes and + // hands out one shared slice. + want := append([]string(nil), keys...) + require.NotEmpty(t, keys, "no reserved credential keys to probe; the blocklist would be empty") + first := keys[0] + keys[0] = "FULLSEND_ACCESSOR_MUTATION_PROBE" + + assert.False(t, reservedCredentialKeys["FULLSEND_ACCESSOR_MUTATION_PROBE"], + "mutating the returned slice must not add to the blocklist") + assert.True(t, reservedCredentialKeys[first], + "mutating the returned slice must not remove from the blocklist") + assert.Equal(t, want, ReservedCredentialKeys(), + "a later caller must receive an untouched list") +} + +// reservedCredentialKeysUnpinnedFloor holds the entries of +// reservedCredentialKeys that no other test pins against that map. +// TestReservedCredentialKeys proves the accessor mirrors the map but cannot +// notice the map shrinking, because then both sides shrink together. SHELL, +// ENV and LD_LIBRARY_PATH are listed here even though the cli blocklist names +// them too, because that pin is satisfied by cli's own map and would stay +// green if the credential map alone dropped the name. Dropping any entry here +// has to be a deliberate edit in two files, not a silent policy change +// (#3373). +var reservedCredentialKeysUnpinnedFloor = []string{ + "ALL_PROXY", "IFS", "CDPATH", "PYTHONPATH", "JAVA_TOOL_OPTIONS", "RUBYOPT", + "PERL5OPT", "DYLD_INSERT_LIBRARIES", "GIT_TEMPLATE_DIR", "GIT_ASKPASS", + "SHELL", "ENV", "LD_LIBRARY_PATH", +} + +// TestReservedCredentialKeys_RetainUnpinnedNames keeps the credential +// deny-list from losing an entry that nothing else would notice. +func TestReservedCredentialKeys_RetainUnpinnedNames(t *testing.T) { + t.Parallel() + + keys := ReservedCredentialKeys() + for _, want := range reservedCredentialKeysUnpinnedFloor { + assert.Contains(t, keys, want, + "reservedCredentialKeys must retain %s; no other test pins it against this map", want) + } +} diff --git a/internal/sandbox/sandbox.go b/internal/sandbox/sandbox.go index 3d7dd566d3..f72da38196 100644 --- a/internal/sandbox/sandbox.go +++ b/internal/sandbox/sandbox.go @@ -627,6 +627,35 @@ var reservedCredentialKeys = map[string]bool{ "GIT_ASKPASS": true, } +// ReservedCredentialKeys returns the names reservedCredentialKeys refuses as +// provider credential keys, for consumers that gate a different input to a +// child process. +// +// A name is on this list because letting harness-supplied configuration set it +// in a child process could change process loading, shell behavior, TLS trust +// or git behavior. The doors differ: a credential name reaches the host-side +// `openshell provider` environment, while harness `env.sandbox` is exported +// inside the sandbox. The exposure is the same once the name is in a child's +// environment, so every name here is blocked on both sides — internal/cli +// merges this list into its sandbox env blocklist at init so the two cannot +// drift apart again (#3373). Absence from this list is not a statement that a +// name is safe — the plugin-env deny-list is deliberately broader, in the +// direction reserved_env_drift_test.go pins: every credential name is also a +// plugin-env name, not the converse. The cross-door invariant added here is +// pinned by TestReservedSandboxKeys_CoversReservedCredentialKeys in +// internal/cli. +// +// The result is a copy in deterministic order: callers must not be able to edit +// the blocklist, and the order is part of this function's contract. +func ReservedCredentialKeys() []string { + keys := make([]string, 0, len(reservedCredentialKeys)) + for k := range reservedCredentialKeys { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} + // EnsureProvider creates or updates a provider on the gateway. Credential // values may contain ${VAR} references which are expanded from the host // environment before being passed to openshell. From 170f8484d551bb3707b267e94ab8acdf0366dff5 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Fri, 16 Oct 2026 14:07:15 -0400 Subject: [PATCH 3/8] fix(#3373): correct OpenShell environment migration guidance Address review comments on PR #8496 without changing the deny-list or export-filtering behavior. Remove the stale claim that OpenShell injects HTTPS_PROXY and retain only the conditional pi compatibility warning. The pinned OpenShell version strips ambient proxy variables before child execution. Replace the generic .env.d and nonexistent-field migration advice with a link to deployment-aware guidance. Corporate proxy settings belong with the OpenShell gateway operator; the documented chaining covers policy-approved TLS CONNECT, not every application proxy use. Extra CA configuration must preserve OpenShell trust and account for the supervisor's separate upstream verification. Define OIDC and TLS, explain the ASCII identifier rule, number the conditional lock-check steps, and qualify the guide as selected-name filtering rather than complete protection against every equivalent. Add regression assertions for the migration warning. Focused CLI and sandbox tests pass with -race -count=1, staged lint passes, and approximate branch patch coverage is 40/40 changed instrumented lines. This validates the code and source-backed guidance, not live gateway connectivity. Signed-off-by: Tim Pouyer --- docs/guides/user/customizing-agents.md | 84 +++++++++++++++------- images/sandbox/Containerfile | 3 +- internal/cli/run.go | 7 +- internal/cli/run_reserved_env_lint.go | 5 +- internal/cli/run_reserved_env_lint_test.go | 3 + 5 files changed, 67 insertions(+), 35 deletions(-) diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index 9ba618e9d1..12f0c4b858 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -451,8 +451,8 @@ these files like `pre_script`. `host_files` can also place configuration that to as git config or shell rc files; that is trusted like `pre_script` too. **Note**: `env.sandbox` cannot modify runner infrastructure or security -settings. The runner drops these names before writing the sandbox -environment, case-insensitively: +settings through the reserved names below. The runner drops these names +before writing the sandbox environment, case-insensitively: - **Runner infrastructure and process-loading safeguards:** `PATH`, `HOME`, `SHELL`, `BASH_ENV`, `ENV`, `LD_PRELOAD`, `LD_LIBRARY_PATH`, `TRACEPARENT`, @@ -462,17 +462,20 @@ environment, case-insensitively: - **Credentials it mints or receives:** `FULLSEND_GCP_OIDC_AUTH_FILE`, `FULLSEND_TRIGGER_TOKEN`, `FULLSEND_WEBHOOK_SECRET`, `FULLSEND_INFERENCE_GATEWAY_API_KEY`, `FULLSEND_OPENAI_API_KEY`, - `OPENAI_API_KEY`, `GH_WORKFLOW_TOKEN`, and the GitHub Actions OIDC request - pair `ACTIONS_ID_TOKEN_REQUEST_URL` / `ACTIONS_ID_TOKEN_REQUEST_TOKEN`. + `OPENAI_API_KEY`, `GH_WORKFLOW_TOKEN`, and the GitHub Actions OpenID Connect + (OIDC) request pair `ACTIONS_ID_TOKEN_REQUEST_URL` / + `ACTIONS_ID_TOKEN_REQUEST_TOKEN`. The runner uses this pair to request a + token proving the job's identity. - **Non-secret, runner-only inputs that select those credentials:** `FULLSEND_GCP_OIDC_URL`, `FULLSEND_GCP_PROJECT_ID`, `FULLSEND_GCP_WIF_PROVIDER`, `FULLSEND_OPENAI_AUDIENCE`, `FULLSEND_OPENAI_IDENTITY_PROVIDER_ID`, `FULLSEND_OPENAI_SERVICE_ACCOUNT_ID`. -- **Security-sensitive names that fullsend also refuses as provider - credential keys:** proxy settings (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`, - `ALL_PROXY`), TLS trust-chain overrides (`SSL_CERT_FILE`, `SSL_CERT_DIR`, - `CURL_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`), git configuration +- **Security-sensitive names also refused in URL-sourced provider credential + definitions:** proxy settings (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`, + `ALL_PROXY`), Transport Layer Security (TLS) trust settings that select + certificates for verifying encrypted connections (`SSL_CERT_FILE`, + `SSL_CERT_DIR`, `CURL_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`), git configuration (`GIT_SSH_COMMAND`, `GIT_CONFIG_GLOBAL`, `GIT_EXEC_PATH`, `GIT_ASKPASS`, `GIT_TEMPLATE_DIR`), interpreter injection (`NODE_OPTIONS`, `PYTHONPATH`, `PYTHONSTARTUP`, `JAVA_TOOL_OPTIONS`, `RUBYOPT`, `PERL5OPT`), @@ -487,25 +490,56 @@ through `env.sandbox` — see Matching is case-insensitive, so `https_proxy` is dropped exactly as `HTTPS_PROXY` is. +This deny-list covers selected names, not every variable that can affect +network routing, certificate trust, Git or interpreter behavior. An unlisted +name is not necessarily safe. + `fullsend run` warns when the harness loads, naming all reserved keys it will drop, and warns again on stderr for each key as it writes the sandbox -environment. `fullsend lock` reports the same lint warning when it loads and -composes the harness. If its lock entry is already current, it skips that work -and prints a notice that diagnostics were not checked. Use -`fullsend lock --update` (or `fullsend lock --all --update`) to -check the composed harness; this also re-resolves its dependencies and may -update the lock file. No key-specific warning on a cache hit means the keys -were not checked, not that they are allowed. - -A key that is not a valid POSIX identifier is skipped with a stderr warning -from `fullsend run` only. If a proxy or certificate setting seems to be -ignored, look for those warnings. Dropping a key removes that one -`env.sandbox` export; it does not unset a value that reaches the sandbox -another way, as `host_files` `.env.d` does. - -This gate covers `env.sandbox` only: `host_files` `.env.d` content, discussed -above, is shell that the gate does not filter — it is sourced inside the sandbox -trusted like `pre_script`. +environment. To check the harness without starting an agent: + +1. Run `fullsend lock `. It reports the same lint warning when it + loads and composes the harness. Locking may fetch dependencies and write the + lock file. If the entry is already current, it skips composition and reports + that diagnostics were not checked. +2. Run `fullsend lock --update` (or + `fullsend lock --all --update`) if diagnostics were skipped and you want to + check the composed harness. This forces dependency re-resolution and may + change the lock file; it is not a diagnostics-only operation. + +No key-specific warning on a cache hit means the keys were not checked, not +that they are allowed. + +A key must start with an ASCII letter or underscore, followed only by ASCII +letters, digits or underscores. `fullsend run` skips invalid names and warns +on stderr; this separate identifier check is not reported by `fullsend lock`. +Dropping a key removes that one `env.sandbox` export; it does not unset a value +that reaches the sandbox another way, as `host_files` `.env.d` does. + +This gate covers `env.sandbox` only. `host_files` `.env.d` content is sourced +as shell inside the sandbox and is trusted like `pre_script`, but it is not a +general migration path for blocked proxy or certificate settings. + +#### Migrating proxy and certificate settings + +Coordinate these changes with the operator of your OpenShell gateway: + +- **Corporate proxies:** use the operator-managed outbound-network settings + for the OpenShell version and compute driver you deploy. The + [OpenShell v0.1.2 gateway configuration reference](https://github.com/NVIDIA/OpenShell/blob/v0.1.2/docs/how-it-works/gateways/configuration.mdx) + describes proxy chaining for policy-approved TLS connections using the HTTP + CONNECT method to establish a tunnel. Plain-HTTP destination traffic remains + direct. These are not fullsend harness fields or a general replacement for + every `HTTP_PROXY` or `ALL_PROXY` use. Do not reintroduce application proxy + exports through `.env.d` as a workaround. +- **Additional certificate authorities (CAs):** preserve the active sandbox's + OpenShell CA certificate and other required roots in application trust. + OpenShell's supervisor also verifies upstream TLS separately. Follow the + selected driver's certificate-provisioning instructions, including + `proxy_ca_bundle` where supported and applicable. Do not assume that replacing + a generated bundle with a custom-only file, or changing only the agent image's + trust store, configures both trust paths. Have the gateway operator validate + the required application and supervisor connections before deployment. ### Adding a skill diff --git a/images/sandbox/Containerfile b/images/sandbox/Containerfile index 0e619e5395..27e166d6f2 100644 --- a/images/sandbox/Containerfile +++ b/images/sandbox/Containerfile @@ -95,8 +95,7 @@ RUN NPM_CLAUDE="$(npm prefix -g)/bin/claude" \ # 0.84.4 is the FLOOR for Gemini on Vertex (the pin is above it): 0.84.3 # bundles https-proxy-agent without its named export, so every google-vertex # request fails with "HttpsProxyAgent is not a constructor" whenever -# HTTPS_PROXY is set — which the OpenShell sandbox always does -# (earendil-works/pi#8610, fixed in 0.84.4). +# HTTPS_PROXY is set (earendil-works/pi#8610, fixed in 0.84.4). # To update: bump PI_VERSION; renovate tracks this ARG via a customManagers # regex entry in renovate.json. pi releases ~weekly minors and has changed # its --mode json wire shape within a minor before (0.84.0) — the pi stream diff --git a/internal/cli/run.go b/internal/cli/run.go index f37ee48ed8..bf5691972f 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -3395,11 +3395,8 @@ func buildSandboxEnvLines(h *harness.Harness) []string { // documents http_proxy as lowercase-only while other scheme proxies // are also checked uppercase, and which of https_proxy and HTTPS_PROXY // wins is upstream curl behavior, not something this repo controls. - // OpenShell also injects HTTPS_PROXY itself — see the 0.84.4 floor - // remark in the PI_VERSION comment in images/sandbox/Containerfile - // ("which the OpenShell sandbox always does"). Blocking one spelling - // while exporting the other would make the strength of this blocklist - // depend on tool internals (#3373). + // Blocking one spelling while exporting the other would make the + // strength of this blocklist depend on tool internals (#3373). if isReservedSandboxKey(k) { fmt.Fprintf(os.Stderr, "WARNING: env.sandbox key %q is reserved (runner infrastructure or security deny-list); skipping\n", k) continue diff --git a/internal/cli/run_reserved_env_lint.go b/internal/cli/run_reserved_env_lint.go index 8f806e6282..e09c1bfc53 100644 --- a/internal/cli/run_reserved_env_lint.go +++ b/internal/cli/run_reserved_env_lint.go @@ -57,9 +57,8 @@ func reservedSandboxEnvDiagnostics(h *harness.Harness) []harness.Diagnostic { Severity: harness.SeverityWarning, Field: "env.sandbox", Message: fmt.Sprintf("%d env.sandbox key(s) are reserved and will be dropped instead of exported "+ - "into the sandbox: %s. Matching is case-insensitive. Proxy and certificate settings can move to "+ - "host_files .env.d or to a named configuration field; runner credentials and runner-owned "+ - "infrastructure names are not deliverable to the sandbox by design. "+ + "into the sandbox: %s. Matching is case-insensitive. Review the migration guidance before "+ + "changing proxy or certificate settings; preserve OpenShell's network mediation and certificate trust. "+ "See docs/guides/user/customizing-agents.md.", len(dropped), strings.Join(dropped, ", ")), }} diff --git a/internal/cli/run_reserved_env_lint_test.go b/internal/cli/run_reserved_env_lint_test.go index adfaa492ce..79b8f4a34b 100644 --- a/internal/cli/run_reserved_env_lint_test.go +++ b/internal/cli/run_reserved_env_lint_test.go @@ -50,7 +50,10 @@ func TestReservedSandboxEnvDiagnostics_ReportsDroppedKeys(t *testing.T) { // the keys but not the case rule or where to read about it leaves the user // to guess. Pin the parts that matter rather than the whole sentence. assert.Contains(t, diags[0].Message, "Matching is case-insensitive") + assert.Contains(t, diags[0].Message, "Review the migration guidance") assert.Contains(t, diags[0].Message, "docs/guides/user/customizing-agents.md") + assert.NotContains(t, diags[0].Message, ".env.d", "do not recommend reinjecting proxy or CA settings") + assert.NotContains(t, diags[0].Message, "named configuration field", "no such fullsend field exists") } func TestReservedSandboxEnvDiagnostics_MatchesGateCaseFolding(t *testing.T) { From 4270ae182f820bd47ac51411e2690a6b71b5e6e0 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Fri, 16 Oct 2026 14:56:05 -0400 Subject: [PATCH 4/8] docs(#3373): note GitHub Action proxy migration gap Address the review finding that the GitHub Action writes its gateway config from a fixed template with no proxy or CA input. Add the limitation to the guide's migration section so Actions users behind a corporate proxy know there is no configuration step available yet. The GitLab VM executor preserves an operator-configured gateway.toml and is not affected the same way. The follow-up for an Action proxy input is tracked in #8505. Signed-off-by: Tim Pouyer --- docs/guides/user/customizing-agents.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index 12f0c4b858..e74f3bba8d 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -532,6 +532,12 @@ Coordinate these changes with the operator of your OpenShell gateway: direct. These are not fullsend harness fields or a general replacement for every `HTTP_PROXY` or `ALL_PROXY` use. Do not reintroduce application proxy exports through `.env.d` as a workaround. + **GitHub Action limitation:** fullsend's own GitHub Action writes + `gateway.toml` with a fixed template and has no input for upstream proxy or + CA settings. Self-hosted Actions runners behind a corporate proxy that relied + on `HTTPS_PROXY` in `env.sandbox` have no configuration step available yet. + This is tracked as a follow-up for an Action proxy input + ([#8505](https://github.com/fullsend-ai/fullsend/issues/8505)). - **Additional certificate authorities (CAs):** preserve the active sandbox's OpenShell CA certificate and other required roots in application trust. OpenShell's supervisor also verifies upstream TLS separately. Follow the From 2ce0966af46db99aac134f8e6843f1eb79ea1a13 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Mon, 19 Oct 2026 12:04:58 -0400 Subject: [PATCH 5/8] docs(#3373): make the OpenShell migration link version-independent Address the review finding that the migration guide linked the OpenShell v0.1.2 gateway configuration reference while the branch pins 0.1.4. The two releases differ on the exact field the guide sends readers to look up: the Docker driver section documents only `https_proxy` at v0.1.2 and carries `proxy_ca_bundle` and `proxy_connect_by_hostname` from v0.1.3 on, so a Docker reader following the v0.1.2 link to check where that field was supported was told it does not exist. Retarget the link at `main` and link the script that records the pinned version, instead of writing a version into the URL, the link text and the prose. A version tag in a doc is a third copy of the pin and nothing keeps it in step: the Renovate rule that bumps `OPENSHELL_VERSION` is fileFiltered to the script, and the guide copy manager from #4808 covers only `running-agents-locally.md`. Repinning here would have left the next routine dependency bump red rather than updating the link. This follows how `running-agents-locally.md` already refers to the pin. Replace the "where supported" hedge, written for the release where Docker was the one driver missing the field, with the `https_proxy` requirement the reference carries. Correct the bundle's placement for Kubernetes: there the reference documents it as a path in the gateway Pod that Helm mounts from a ConfigMap, not a host path, so a host-path instruction would send a Kubernetes operator to a hostPath. Verified against the upstream reference at `main`. Link this section from `harness-reference.md` and the operations guide, which state the block but had no route to where the settings go instead. No guard test is added. A doc tag compared with `OPENSHELL_VERSION` would alarm on every bump without any way to fix itself, and with no version in the doc the drift class is gone. Focused CLI regressions pass with -race -count=1, including TestGuideNamesMatchTheGate over the edited note, and the doc lint hooks pass on the delta. Signed-off-by: Tim Pouyer --- docs/guides/getting-started/operations.md | 2 +- docs/guides/user/customizing-agents.md | 20 +++++++++++++------- docs/reference/harness-reference.md | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index b4f8f4a565..0de7b9c193 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -299,7 +299,7 @@ Local `fullsend poll` / `fullsend run --forge gitlab` against a private-CA insta ### Sandbox hosts -OpenShell sandboxes do **not** inherit `CI_SERVER_TLS_CA_FILE`. That path is job-local and must not be treated as available inside the sandbox or on a remote gateway host. Agent-controlled TLS environment overrides (`SSL_CERT_FILE`, `SSL_CERT_DIR`, `CURL_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`) stay blocked. +OpenShell sandboxes do **not** inherit `CI_SERVER_TLS_CA_FILE`. That path is job-local and must not be treated as available inside the sandbox or on a remote gateway host. Agent-controlled TLS environment overrides (`SSL_CERT_FILE`, `SSL_CERT_DIR`, `CURL_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`) stay blocked; see [Migrating proxy and certificate settings](../user/customizing-agents.md#migrating-proxy-and-certificate-settings) for where those settings go instead. The OpenShell supervisor reads a fixed list of system CA paths in the sandbox container to build upstream trust (GitLab, registries, inference) and the bundle handed to sandboxed processes. Administrators provision that trust on the **sandbox host**, independently of the job container: diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index e74f3bba8d..05616c10df 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -525,8 +525,11 @@ general migration path for blocked proxy or certificate settings. Coordinate these changes with the operator of your OpenShell gateway: - **Corporate proxies:** use the operator-managed outbound-network settings - for the OpenShell version and compute driver you deploy. The - [OpenShell v0.1.2 gateway configuration reference](https://github.com/NVIDIA/OpenShell/blob/v0.1.2/docs/how-it-works/gateways/configuration.mdx) + for the OpenShell version and compute driver you deploy; fullsend records + the version it pins in + [`.github/scripts/openshell-version.sh`](https://github.com/fullsend-ai/fullsend/blob/main/.github/scripts/openshell-version.sh) + at your release tag. + The [OpenShell gateway configuration reference](https://github.com/NVIDIA/OpenShell/blob/main/docs/how-it-works/gateways/configuration.mdx) describes proxy chaining for policy-approved TLS connections using the HTTP CONNECT method to establish a tunnel. Plain-HTTP destination traffic remains direct. These are not fullsend harness fields or a general replacement for @@ -541,11 +544,14 @@ Coordinate these changes with the operator of your OpenShell gateway: - **Additional certificate authorities (CAs):** preserve the active sandbox's OpenShell CA certificate and other required roots in application trust. OpenShell's supervisor also verifies upstream TLS separately. Follow the - selected driver's certificate-provisioning instructions, including - `proxy_ca_bundle` where supported and applicable. Do not assume that replacing - a generated bundle with a custom-only file, or changing only the agent image's - trust store, configures both trust paths. Have the gateway operator validate - the required application and supervisor connections before deployment. + selected driver's certificate-provisioning instructions in that reference, + which documents `proxy_ca_bundle` for a corporate proxy. It requires + `https_proxy`, and on Kubernetes it is a path in the gateway Pod mounted + from a ConfigMap, not a host path. Do not assume that replacing a + generated bundle with a custom-only file, or changing only the agent + image's trust store, configures both trust paths. Have the gateway operator + validate the required application and supervisor connections before + deployment. ### Adding a skill diff --git a/docs/reference/harness-reference.md b/docs/reference/harness-reference.md index d41c7c2f7d..09e2ca9da9 100644 --- a/docs/reference/harness-reference.md +++ b/docs/reference/harness-reference.md @@ -171,7 +171,7 @@ breaks the hash-verified fetch cache. These rules make a run fail before `pre_script` starts: -- **Refused names.** A key in the object may not be a runner-owned name. That covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, `RUNNER_*`, `CI_*`, `LD_*`, `DYLD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, the runner-infrastructure names (`HOME`, `SHELL`, `BASH_ENV`, `ENV`, `TRACEPARENT`), and every name the reusable workflow sets on the `fullsend run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names may not receive a value from the object either. Credential-class names beyond the runner-infrastructure names, `PATH`, and the `LD_*`/`DYLD_*` families — proxy, TLS trust, Git, interpreter and shell-behavior variables such as `HTTPS_PROXY`, `SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and `HOSTALIASES` — are **not** refused here: runner secrets reach host-side scripts (`pre_script`, `post_script`, `validation_loop`) only as `env.runner` values, and the sandbox gate independently blocks them from `env.sandbox` exports. Names are matched case-insensitively, so `path` or `github_token` is refused like `PATH` or `GITHUB_TOKEN`. +- **Refused names.** A key in the object may not be a runner-owned name. That covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, `RUNNER_*`, `CI_*`, `LD_*`, `DYLD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, the runner-infrastructure names (`HOME`, `SHELL`, `BASH_ENV`, `ENV`, `TRACEPARENT`), and every name the reusable workflow sets on the `fullsend run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names may not receive a value from the object either. Credential-class names beyond the runner-infrastructure names, `PATH`, and the `LD_*`/`DYLD_*` families — proxy, TLS trust, Git, interpreter and shell-behavior variables such as `HTTPS_PROXY`, `SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and `HOSTALIASES` — are **not** refused here: runner secrets reach host-side scripts (`pre_script`, `post_script`, `validation_loop`) only as `env.runner` values, and the sandbox gate independently blocks them from `env.sandbox` exports; see [Migrating proxy and certificate settings](../guides/user/customizing-agents.md#migrating-proxy-and-certificate-settings) for where the proxy and TLS-trust settings go instead. Names are matched case-insensitively, so `path` or `github_token` is refused like `PATH` or `GITHUB_TOKEN`. - **Host side only.** The object's names may be referenced only from `env.runner` values. A reference from `env.sandbox`, `runner_env`, a provider's `credentials` or `config`, a `host_files` `src`, the content of a `host_files` entry with `expand: true`, or a `validation_loop` field is a validation error. - **Overlays.** An overlay that references one of the object's names may be guarded only by `runtime.forge` and `config`. An overlay that reads `event` or any other `runtime` field is refused, even when it does not match. This rule is interim until [ADR 0112](../ADRs/0112-overlays-may-set-any-harness-field.md)'s guarded-field check is implemented; until then an event-guarded overlay can still swap `pre_script`, `post_script` or `validation_loop`, and so choose which script receives a referenced value. - **Shape.** The value must be a JSON object whose values are strings, with no duplicate keys and no `null` values. Each value must be at least as long as the redactor's minimum (currently 8 characters), so it can be redacted. Errors name the offending key, never its value. From 2200cdec0e5e11e627ce96aaac539dfb829237e2 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Mon, 19 Oct 2026 23:16:58 -0400 Subject: [PATCH 6/8] refactor(#3373): check the credential deny-list in the env.sandbox gate Fold the review follow-ups on PR #8496 into one commit. Check the credential deny-list in isReservedSandboxKey through a new sandbox.IsReservedCredentialKey instead of merging it into reservedSandboxKeys at init. The merge had forced runnerSecretNameRefused onto its own copy of the runner-infrastructure names, with keep-in-sync notes in two files and a drift test guarding the copy. With the merge gone, runnerSecretNameRefused reads reservedSandboxKeys again, as on main; relative to main its refused set still gains only the case fold and the DYLD_ family. Tests that read the merged map now call isReservedSandboxKey or enumerate both lists, and the per-name sweep that re-proved the shared predicate is dropped. Drop the lock cache-hit diagnostics notice. It printed a warning for every up-to-date agent on every `fullsend lock` run, whether or not the harness had an env.sandbox block, which made the normal result of `lock --all` on a current repo a list of warnings. `fullsend run` reports reserved keys when the harness loads, and `lock --update` composes the harness and reports them; the guide says a current entry is not composed and points to --update. Because `lock` composes without event context, the guide, the CLI reference and the command table now say that a key added by an event-guarded overlay is reported only by `fullsend run`. Record the decision in a new ADR 0145 instead of a note on accepted ADR 0136: the credential deny-list stays out of the runner-secret refusal, which keeps reading the sandbox environment blocklist, matches case-insensitively and refuses the DYLD_ family. The ADR carries an Amends line for 0136, ADR 0136 gets the italic Amended-by paragraph under its Status that every other amended ADR carries, and docs/architecture.md lists the decision next to the 0136 paragraph. Drop the guide's claim that .env.d is sourced as shell. Since main's #8498 and #8574, every launch and the runner's in-sandbox probes read .env.d as data and take only assignment lines; .env itself stays valid shell an agent may source. The guide says so and links the harness reference entry that carries the per-runtime rules. Document the load-time and per-key warnings in docs/cli/run.md and note the lock behavior in docs/cli/README.md; the CLI reference pages are maintained by hand and mentioned none of it. Give the harness reference an env.sandbox field-details entry beside env.runner's, cross-link the local-run guide's Lock files section to the reserved-keys section, and extend the migration section with the Git and interpreter-name classes the deny-list also drops. Fold the pass-through delivery check into TestGuideNamesMatchTheGate's carve-out branch, so every name the guide promises is delivered is also exported in practice, and drop the separate test that repeated it. Use sandbox.IsReservedCredentialKey in the provider doors instead of their inline copies of its body, and drop the zsh rationale for the runner-secret case fold: zsh does not import a lowercase path from the environment, so consistency with the env.sandbox gate is the reason. Name the runner-secret bundle, its staging path and the GitLab trigger account token in the guide's reserved-name note; they were reserved but unlisted. Give that note its own heading so the CLI reference and the harness reference link to the list rather than to the PATH section, and say in the accessor's doc comment that it exists for cross-package tests. Describe the runner's own FULLSEND_* exports in the guide's reserved-name note as a family instead of listing them, and send its .env.d sentence to the harness reference's entry instead of repeating the dropped names, so the note does not go stale when the runner gains an export or the loader's drop set changes; the guide test's floor follows the shorter list. Signed-off-by: Tim Pouyer --- ...unner-secrets-through-one-stored-secret.md | 12 ++- ...-deny-list-out-of-runner-secret-refusal.md | 69 ++++++++++++++++++ docs/architecture.md | 3 + docs/cli/README.md | 2 +- docs/cli/run.md | 23 +++++- docs/guides/user/customizing-agents.md | 58 +++++++++++---- docs/guides/user/running-agents-locally.md | 3 + docs/reference/harness-reference.md | 44 ++++++++++- internal/cli/lock.go | 4 - internal/cli/lock_reserved_env_cache_test.go | 68 +---------------- internal/cli/run.go | 32 +++----- .../cli/run_reserved_credential_env_test.go | 52 +++++-------- internal/cli/run_reserved_env_case_test.go | 23 +++--- internal/cli/run_reserved_env_lint_test.go | 21 ------ internal/cli/runner_secrets.go | 33 ++------- internal/cli/runner_secrets_test.go | 73 +++---------------- .../sandbox/reserved_credential_keys_test.go | 36 ++++----- internal/sandbox/sandbox.go | 35 +++++---- 18 files changed, 286 insertions(+), 305 deletions(-) create mode 100644 docs/ADRs/0145-keep-credential-deny-list-out-of-runner-secret-refusal.md diff --git a/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md b/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md index 077449e0e7..e9724998a8 100644 --- a/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md +++ b/docs/ADRs/0136-runner-secrets-through-one-stored-secret.md @@ -18,6 +18,11 @@ Date: 2026-10-07 Accepted +*Amended by [ADR 0145](0145-keep-credential-deny-list-out-of-runner-secret-refusal.md), +which keeps the credential deny-list that #3373 adds to the `env.sandbox` gate +out of the refused-names rule below, matches that rule case-insensitively, and +adds the `DYLD_*` family to the refused prefixes.* + ## Context A custom harness's `pre_script`, `post_script` and `validation_loop` read @@ -76,13 +81,6 @@ These rules apply to names in the GitHub object: guarded only by `runtime.forge` and `config`, until ADR 0112's guarded-field check is implemented. -> **Note (2026-10, [#3373](https://github.com/fullsend-ai/fullsend/issues/3373)):** -> "Sandbox-reserved" in the refused-names rule above meant the -> runner-infrastructure names; "credential" meant the OIDC and provider-only -> keys, not the wider credential-class deny-list. The later merge of that -> deny-list into `reservedSandboxKeys` was decoupled from this refusal; see -> the harness reference for the current split. - GitLab is unchanged: a JSON bundle does not fit GitLab's per-variable masking, each secret stays its own masked CI/CD variable, and none of these rules apply there. Keeping fullsend's own credentials out of GitLab host-side scripts is diff --git a/docs/ADRs/0145-keep-credential-deny-list-out-of-runner-secret-refusal.md b/docs/ADRs/0145-keep-credential-deny-list-out-of-runner-secret-refusal.md new file mode 100644 index 0000000000..adc5496012 --- /dev/null +++ b/docs/ADRs/0145-keep-credential-deny-list-out-of-runner-secret-refusal.md @@ -0,0 +1,69 @@ +--- +title: "145. Keep the credential deny-list out of the runner-secret refusal" +status: Accepted +relates_to: + - agent-infrastructure + - security-threat-model +topics: + - harness + - secrets + - github-actions +--- + +# 145. Keep the credential deny-list out of the runner-secret refusal + +Date: 2026-10-19 + +Amends: [ADR 0136](0136-runner-secrets-through-one-stored-secret.md) + +## Status + +Accepted + +## Context + +[ADR 0136](0136-runner-secrets-through-one-stored-secret.md) refuses some +names as runner-secret bundle keys, and its refusal reads the sandbox +reserved set (`reservedSandboxKeys`). #3373 makes `env.sandbox` also refuse +the credential-class deny-list: proxy, TLS-trust, Git, interpreter, loader +and shell-behavior names. + +Those names are legitimate host-side. `pre_script` and `post_script` need +proxy and TLS settings to reach internal networks, and the sandbox child +never sees a runner-secret value. If the deny-list were merged into +`reservedSandboxKeys`, a bundle carrying, for example, `HTTPS_PROXY` would +fail validation and stop every run that uses it. + +The refusal also has two gaps. It matched exact case, so a lowercase key +such as `path` passed, although the `env.sandbox` gate matches +case-insensitively. It refused `LD_*` but not the macOS dynamic-linker family +`DYLD_*`, which the plugin-env door already refuses. + +## Decision + +This ADR settles the runner-secret refusal's name set once `env.sandbox` +refuses the credential deny-list: it does not read the deny-list, it matches +case-insensitively, and it refuses the `DYLD_*` family. The second and third +close gaps in that set rather than open a separate decision. + +The `env.sandbox` gate checks the credential deny-list beside +`reservedSandboxKeys`; the deny-list is not merged into that map. The +runner-secret refusal keeps reading `reservedSandboxKeys` and does not +consult the deny-list. It also refuses the OIDC and provider-only keys, the +minted role tokens and workflow-set names refused since ADR 0136, and the +runner-owned prefixes, now including `DYLD_*`. Both doors match +case-insensitively. A credential-class name that is not also in +`reservedSandboxKeys` or under a refused prefix is refused at the +`env.sandbox` door and accepted as a runner-secret key. + +## Consequences + +- The deny-list can widen without breaking runs whose bundles carry + host-side settings. +- Both doors read `reservedSandboxKeys`, so a runner-infrastructure name + added there is refused at both with no second list to keep in sync. +- Proxy, TLS-trust and Git settings stay available to host-side scripts + through runner secrets. +- ADR 0136's refused names stay refused, now with their case variants and + the `DYLD_*` family, so a bundle key such as `path` or `github_token` fails + validation. diff --git a/docs/architecture.md b/docs/architecture.md index 3771badef3..6385073a0b 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -149,6 +149,9 @@ repo baseline and overrides) `runtime.forge` or `config` (interim until ADR 0112's guarded-field check). GitLab is unchanged: one masked CI/CD variable per secret, none of these rules ([ADR 0136](ADRs/0136-runner-secrets-through-one-stored-secret.md)). + The refusal does not consult the credential deny-list that the + `env.sandbox` gate also checks + ([ADR 0145](ADRs/0145-keep-credential-deny-list-out-of-runner-secret-refusal.md)). - Agent configuration env vars: behavioral knobs use `{AGENT}_{SETTING_NAME}` naming (e.g., `REVIEW_SEVERITY_THRESHOLD`), delivered via `env.runner` and `env.sandbox` in the harness YAML. Each agent documents its config vars in diff --git a/docs/cli/README.md b/docs/cli/README.md index 1ebee635e8..f2fcd89adb 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -26,7 +26,7 @@ Download the latest binary from [GitHub Releases](https://github.com/fullsend-ai |---------|-------------| | [`fullsend run`](run.md) | Execute an agent locally in a sandbox. See [running agents locally](../guides/user/running-agents-locally.md). | | `fullsend poll` | Discover forge events and dispatch agent pipelines. `--forge gitlab` runs the cron poller ([ADR 0067](../ADRs/0067-gitlab-cron-polling-event-dispatch.md)); events-mode polling also recovers issue opens whose webhook delivery was missed. `--input-driver jira-poll` polls Jira (see [Jira integration](../guides/user/jira-integration.md)). `--input-driver gitlab-webhook` is the GitLab dispatcher job's webhook fast-path ([ADR 0125](../ADRs/0125-gitlab-hybrid-webhook-poller-dispatch.md)). It reads the native webhook body from the file-type `TRIGGER_PAYLOAD` variable, re-validates it against the GitLab API, and creates each routed stage's pipeline (typed inputs, `FULLSEND_DISPATCH_SECRET` HMAC) with the poller-role credential (the `api` route, the default). Scheduled cron polling and the webhook fast path run as the trigger-only service account: once its dispatch activation is recorded, the managed webhook carries the account's pipeline trigger token ([#8509](https://github.com/fullsend-ai/fullsend/issues/8509)), the scaffold sets `FULLSEND_GITLAB_DISPATCH_ROUTE=child-pipeline`, and the command instead starts each pipeline with the job's own `CI_JOB_TOKEN` through the pipeline trigger API (`source=pipeline`); an unknown route, or `child-pipeline` without `CI_JOB_TOKEN`, fails closed. `fullsend poll --forge gitlab --print-dispatch-routes` prints the routes the CLI supports (`api` and `child-pipeline`) and exits; the scaffold runs it before selecting `child-pipeline`, and a CLI that predates the route rejects the flag, so the job stops before any dispatch. It requires `--project`, which has no `CI_PROJECT_PATH` fallback. It deduplicates against the poller's per-mode state on the `fullsend-poll-state-slash` and `fullsend-poll-state-events` branches, so an event the webhook dispatched is not dispatched again by the poller, and the reverse. Shared poller state is occurrence-aware (label additions are keyed on the resource label event ID, dispatched keys are retained for the webhook freshness window, and a failed label dispatch is handed back to the poller as a pending retry); legacy persisted keys keep working. Older pollers do not recognise the new label keys, so before a rollback or mixed-version run, follow the [ADR 0132](../ADRs/0132-occurrence-aware-shared-poller-state.md) guidance to drain in-flight poll jobs or pin every poller to one version. | -| `fullsend lock [agent-name]` | Pin remote dependencies to `lock.yaml` | +| `fullsend lock [agent-name]` | Pin remote dependencies to `lock.yaml`. When it composes a harness (a new or stale entry, or `--update`), it also prints the harness diagnostics, including [reserved `env.sandbox` keys](run.md#reserved-envsandbox-keys). A current entry is not composed, so its keys are not checked, and `lock` composes without event context, so keys from event-guarded overlays are reported only by `fullsend run`. | | `fullsend scan` | Run security scanners on agent input/output | | `fullsend eval-measure` | Score wild-run traces into `eval-measurements.jsonl`. See [Eval measurements](../guides/infrastructure/eval-measurements.md). | diff --git a/docs/cli/run.md b/docs/cli/run.md index e37edf757f..163a4c8ce2 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -293,7 +293,8 @@ For comparison: - Child processes inherit both variables. In a pi sub-agent read the deadline, not the budget: the deadline is the same wall-clock limit the parent has, while `FULLSEND_TIMEOUT_MINUTES` is the parent iteration's whole budget, not the time the child has left. -- Both names are reserved: an `env.sandbox` entry with either name is dropped. Pre-, post- and +- Both names are reserved: an `env.sandbox` entry with either name is dropped + (see [Reserved `env.sandbox` keys](#reserved-envsandbox-keys)). Pre-, post- and validation scripts run on the host and do not see them. **Pacing from a skill.** Read the deadline, not the budget, and keep the arithmetic in two steps — @@ -454,6 +455,26 @@ receives one only when the harness declares it under `env.runner`; see Repo-level setup (provider, profile, `~/.npmrc`, code/fix overlays): [Private registries and GitHub Packages](../guides/user/customizing-agents.md#private-registries-and-github-packages). +## Reserved `env.sandbox` keys + +`fullsend run` drops reserved names from `env.sandbox` instead of exporting +them into the sandbox. Matching is case-insensitive. It warns twice: + +- When the harness loads, one warning names every reserved key: + `N env.sandbox key(s) are reserved and will be dropped instead of exported into the sandbox: ...` +- As it writes the sandbox environment, one stderr line per key: + `WARNING: env.sandbox key "NAME" is reserved (runner infrastructure or security deny-list); skipping` + +`fullsend lock` prints the load-time warning when it composes a harness. A +current lock entry is not composed; run `fullsend lock --update` to check its +keys. `lock` composes without event context, so a key added by an overlay +guarded on `event` is reported only by `fullsend run`. The reserved names are +listed in the `env.sandbox` note in [Customizing +agents](../guides/user/customizing-agents.md#reserved-envsandbox-names); +where blocked proxy and certificate settings go instead is in [Migrating proxy +and certificate +settings](../guides/user/customizing-agents.md#migrating-proxy-and-certificate-settings). + ## Runner secrets `fullsend run` reads a JSON object of name → value for host-side scripts diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index 05616c10df..39e0a7b9d2 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -450,19 +450,25 @@ and other lines that are not plain assignments) are skipped with a warning. these files like `pre_script`. `host_files` can also place configuration that tools load, such as git config or shell rc files; that is trusted like `pre_script` too. +#### Reserved `env.sandbox` names + **Note**: `env.sandbox` cannot modify runner infrastructure or security settings through the reserved names below. The runner drops these names before writing the sandbox environment, case-insensitively: - **Runner infrastructure and process-loading safeguards:** `PATH`, `HOME`, `SHELL`, `BASH_ENV`, `ENV`, `LD_PRELOAD`, `LD_LIBRARY_PATH`, `TRACEPARENT`, - and the `FULLSEND_*` variables it reserves for itself (output and fetch - plumbing, `FULLSEND_ROLE`, `FULLSEND_SLUG`, `FULLSEND_TIMEOUT_MINUTES`, - `FULLSEND_ITERATION_DEADLINE`, `FULLSEND_RUNNER_PATH`). + and every `FULLSEND_*` variable the runner itself exports into the sandbox + (its output and fetch plumbing, the repository path, role and slug, the + iteration budget and deadline, and its own `PATH` entry). The set grows + with the runner; the warnings described below name any such key a harness + sets. - **Credentials it mints or receives:** `FULLSEND_GCP_OIDC_AUTH_FILE`, - `FULLSEND_TRIGGER_TOKEN`, `FULLSEND_WEBHOOK_SECRET`, - `FULLSEND_INFERENCE_GATEWAY_API_KEY`, `FULLSEND_OPENAI_API_KEY`, - `OPENAI_API_KEY`, `GH_WORKFLOW_TOKEN`, and the GitHub Actions OpenID Connect + `FULLSEND_TRIGGER_TOKEN`, `FULLSEND_GITLAB_TRIGGER_ACCOUNT_TOKEN`, + `FULLSEND_WEBHOOK_SECRET`, `FULLSEND_INFERENCE_GATEWAY_API_KEY`, + `FULLSEND_OPENAI_API_KEY`, `OPENAI_API_KEY`, `GH_WORKFLOW_TOKEN`, the + runner-secret bundle and its staging path (`FULLSEND_GITHUB_RUNNER_SECRETS`, + `FULLSEND_GITHUB_RUNNER_SECRETS_FILE`), and the GitHub Actions OpenID Connect (OIDC) request pair `ACTIONS_ID_TOKEN_REQUEST_URL` / `ACTIONS_ID_TOKEN_REQUEST_TOKEN`. The runner uses this pair to request a token proving the job's identity. @@ -500,12 +506,13 @@ environment. To check the harness without starting an agent: 1. Run `fullsend lock `. It reports the same lint warning when it loads and composes the harness. Locking may fetch dependencies and write the - lock file. If the entry is already current, it skips composition and reports - that diagnostics were not checked. + lock file. If the entry is already current, it skips composition and does + not check the keys. `lock` composes without event context, so a key added + by an overlay guarded on `event` is reported only by `fullsend run`. 2. Run `fullsend lock --update` (or - `fullsend lock --all --update`) if diagnostics were skipped and you want to - check the composed harness. This forces dependency re-resolution and may - change the lock file; it is not a diagnostics-only operation. + `fullsend lock --all --update`) to check the composed harness when the entry + is current. This forces dependency re-resolution and may change the lock + file; it is not a diagnostics-only operation. No key-specific warning on a cache hit means the keys were not checked, not that they are allowed. @@ -516,9 +523,16 @@ on stderr; this separate identifier check is not reported by `fullsend lock`. Dropping a key removes that one `env.sandbox` export; it does not unset a value that reaches the sandbox another way, as `host_files` `.env.d` does. -This gate covers `env.sandbox` only. `host_files` `.env.d` content is sourced -as shell inside the sandbox and is trusted like `pre_script`, but it is not a -general migration path for blocked proxy or certificate settings. +This gate covers `env.sandbox` only. `host_files` `.env.d` files are read +before the runtime starts: every launch and the runner's in-sandbox probes +read them as data and take only assignment lines, and never take the +dynamic-loader, interpreter and shell-startup variables that the +[`.env.d` host files](../../reference/harness-reference.md#field-details) +entry in the harness reference lists. `.env` itself is still valid shell that +an agent may source, so keep treating these files like `pre_script`. Either +way, `.env.d` is not a general migration path for blocked proxy or +certificate settings; the harness reference entry has the per-runtime +rules. #### Migrating proxy and certificate settings @@ -552,6 +566,22 @@ Coordinate these changes with the operator of your OpenShell gateway: image's trust store, configures both trust paths. Have the gateway operator validate the required application and supervisor connections before deployment. +- **Git settings:** place git configuration with `host_files` (a git config + file or shell rc file the tools load) or use the tool's own configuration, + instead of `GIT_SSH_COMMAND`, `GIT_CONFIG_GLOBAL`, `GIT_ASKPASS` and the + other blocked `GIT_*` names. `host_files` content is trusted like + `pre_script`. Git and TLS equivalents the list does not yet cover, such as + `GIT_SSH`, `GIT_CONFIG_*` and `REQUESTS_CA_BUNDLE`, are tracked in + [#8503](https://github.com/fullsend-ai/fullsend/issues/8503). +- **Interpreter, loader and shell names:** `NODE_OPTIONS`, `PYTHONPATH`, + `JAVA_TOOL_OPTIONS`, `LD_AUDIT`, `IFS` and the other blocked names of this + class have no supported replacement route into the sandbox. They are + blocked because they change how code is loaded or run. Which of them + `host_files` `.env.d` still delivers differs by runtime; the + [`.env.d` host files](../../reference/harness-reference.md#field-details) + entry lists what each runtime drops or unsets. Whatever it delivers, it + does so only because that file is trusted like `pre_script`, so it is not + a sanctioned way to restore them. ### Adding a skill diff --git a/docs/guides/user/running-agents-locally.md b/docs/guides/user/running-agents-locally.md index 7c41803b53..7bf409e683 100644 --- a/docs/guides/user/running-agents-locally.md +++ b/docs/guides/user/running-agents-locally.md @@ -386,6 +386,9 @@ or a cached artifact is missing, `fullsend run` falls back to normal network resolution and prints a warning suggesting you re-run `fullsend lock`. Use `--update` to force re-resolution even if the lock entry appears current. +A current entry is also not composed, so `fullsend lock` does not check it for +reserved `env.sandbox` keys; see +[Reserved `env.sandbox` keys](../../cli/run.md#reserved-envsandbox-keys). ### Status notification flags diff --git a/docs/reference/harness-reference.md b/docs/reference/harness-reference.md index 09e2ca9da9..772380a522 100644 --- a/docs/reference/harness-reference.md +++ b/docs/reference/harness-reference.md @@ -75,7 +75,7 @@ host_files: env: runner: # Available to pre/post scripts MY_VAR: "${MY_VAR}" - sandbox: # Available inside sandbox + sandbox: # Available inside sandbox; reserved names are dropped MY_SETTING: "value" runner_env: # ⚠ Deprecated: use env.runner instead MY_VAR: "${MY_VAR}" @@ -171,7 +171,28 @@ breaks the hash-verified fetch cache. These rules make a run fail before `pre_script` starts: -- **Refused names.** A key in the object may not be a runner-owned name. That covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, `RUNNER_*`, `CI_*`, `LD_*`, `DYLD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, the runner-infrastructure names (`HOME`, `SHELL`, `BASH_ENV`, `ENV`, `TRACEPARENT`), and every name the reusable workflow sets on the `fullsend run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names may not receive a value from the object either. Credential-class names beyond the runner-infrastructure names, `PATH`, and the `LD_*`/`DYLD_*` families — proxy, TLS trust, Git, interpreter and shell-behavior variables such as `HTTPS_PROXY`, `SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and `HOSTALIASES` — are **not** refused here: runner secrets reach host-side scripts (`pre_script`, `post_script`, `validation_loop`) only as `env.runner` values, and the sandbox gate independently blocks them from `env.sandbox` exports; see [Migrating proxy and certificate settings](../guides/user/customizing-agents.md#migrating-proxy-and-certificate-settings) for where the proxy and TLS-trust settings go instead. Names are matched case-insensitively, so `path` or `github_token` is refused like `PATH` or `GITHUB_TOKEN`. +- **Refused names.** A key in the object may not be a runner-owned name. That + covers `GH_WORKFLOW_TOKEN`, the OIDC request variables, provider-only keys + such as `OPENAI_API_KEY`, the `FULLSEND_*`, `GITHUB_*`, `ACTIONS_*`, + `RUNNER_*`, `CI_*`, `LD_*`, `DYLD_*`, `OTEL_*`, `GOOGLE_*` and `CLOUDSDK_*` + families, the minted role tokens (`GH_TOKEN`, `PUSH_TOKEN`, + `PUSH_TOKEN_SOURCE`, `REVIEW_TOKEN`, `GITLAB_TOKEN`), `PATH`, the + runner-infrastructure names (`HOME`, `SHELL`, `BASH_ENV`, `ENV`, + `TRACEPARENT`), and every name the reusable workflow sets on the `fullsend + run` step, such as the named `JIRA_TOKEN`, `JIRA_USER_EMAIL` and + `JIRA_BASE_URL` on `harness-run`. An `env.runner` key with one of those names + may not receive a value from the object either. Credential-class names beyond + the runner-infrastructure names, `PATH`, and the `LD_*`/`DYLD_*` families — + proxy, TLS trust, Git, interpreter and shell-behavior variables such as + `HTTPS_PROXY`, `SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and + `HOSTALIASES` — are **not** refused here: runner secrets reach host-side + scripts (`pre_script`, `post_script`, `validation_loop`) only as `env.runner` + values, and the sandbox gate independently blocks them from `env.sandbox` + exports; see [Migrating proxy and certificate + settings](../guides/user/customizing-agents.md#migrating-proxy-and-certificate-settings) + for where the proxy and TLS-trust settings go instead. Names are matched + case-insensitively, so `path` or `github_token` is refused like `PATH` or + `GITHUB_TOKEN`. - **Host side only.** The object's names may be referenced only from `env.runner` values. A reference from `env.sandbox`, `runner_env`, a provider's `credentials` or `config`, a `host_files` `src`, the content of a `host_files` entry with `expand: true`, or a `validation_loop` field is a validation error. - **Overlays.** An overlay that references one of the object's names may be guarded only by `runtime.forge` and `config`. An overlay that reads `event` or any other `runtime` field is refused, even when it does not match. This rule is interim until [ADR 0112](../ADRs/0112-overlays-may-set-any-harness-field.md)'s guarded-field check is implemented; until then an event-guarded overlay can still swap `pre_script`, `post_script` or `validation_loop`, and so choose which script receives a referenced value. - **Shape.** The value must be a JSON object whose values are strings, with no duplicate keys and no `null` values. Each value must be at least as long as the redactor's minimum (currently 8 characters), so it can be redacted. Errors name the offending key, never its value. @@ -180,6 +201,25 @@ These rules make a run fail before `pre_script` starts: These rules cover names in the GitHub object only. GitLab is unchanged: each secret is its own masked CI/CD variable, `${NAME}` reads it directly, and no name is refused there (keeping fullsend's own credentials out of GitLab host-side scripts is tracked in [#8146](https://github.com/fullsend-ai/fullsend/issues/8146)). For setup, see [Building custom agents § Pass secrets to host-side scripts](../guides/user/building-custom-agents.md#pass-secrets-to-host-side-scripts-github). +**`env.sandbox`** — Variables exported into the sandbox environment. Reserved +names are dropped instead of exported, matched case-insensitively: the +runner-infrastructure names (`PATH`, `HOME`, `SHELL`, `BASH_ENV`, `ENV`, +`LD_PRELOAD`, `LD_LIBRARY_PATH`, `TRACEPARENT` and the `FULLSEND_*` names the +runner reserves), the credentials it mints or receives and the runner-only +inputs that select them, and the credential deny-list (proxy, TLS-trust, Git, +interpreter, loader and shell-behavior names such as `HTTPS_PROXY`, +`SSL_CERT_FILE`, `GIT_SSH_COMMAND`, `NODE_OPTIONS` and `IFS`). `fullsend run` +warns once when the harness loads, naming every dropped key, and once per key on +stderr as it writes the sandbox environment; `fullsend lock` prints the +load-time warning when it composes a harness. The full list is in the +`env.sandbox` note in [Customizing +agents](../guides/user/customizing-agents.md#reserved-envsandbox-names), +where blocked proxy and certificate settings go instead is in [Migrating proxy +and certificate +settings](../guides/user/customizing-agents.md#migrating-proxy-and-certificate-settings), +and the warnings are described in [`fullsend run` § Reserved `env.sandbox` +keys](../cli/run.md#reserved-envsandbox-keys). + **`agent_input`** — A local directory, not a file. When a URL `base:` harness declares it, the inherited value is cleared rather than fetched; supply the directory in the child harness if needed. See [Harness field semantic types](../contributing/harness-fields.md#semantic-types-adr-0127). **`host_files[].dest`** — An absolute path under `/sandbox/` or `/tmp/`. Paths the runner writes or puts on `PATH` ahead of the image are refused when the harness loads: `/sandbox/workspace/.env`, the runner and runtime binaries in `/sandbox/workspace/bin` (`claude`, `codex`, `pi`, `opencode`, `fullsend`, `fullsend-check-output`), and anything under `/sandbox/claude-config`, `/sandbox/codex-config`, `/sandbox/pi-config`, `/sandbox/workspace/.fullsend`, `/sandbox/workspace/.security`, `/sandbox/.venv` or `/sandbox/go/bin`. A `dest` containing a `..` path component is refused as well. The same rule applies to `host_files` under `overlays:`, `forge:` and inherited from `base:`. On Claude and pi runs `/sandbox/workspace/bin` is last on the agent's `PATH`, so a file there adds a command but does not replace one the image provides. Codex and OpenCode runs restore the `PATH` from before `.env`, so `/sandbox/workspace/bin` and `.env.d` additions are not on the codex or OpenCode agent's `PATH`. See [Adding executables](../guides/user/customizing-agents.md#adding-executables). diff --git a/internal/cli/lock.go b/internal/cli/lock.go index 48498999c3..d333aaa1b4 100644 --- a/internal/cli/lock.go +++ b/internal/cli/lock.go @@ -198,10 +198,6 @@ func lockOneAgent(ctx context.Context, agentName, absFullsendDir, forgeFlag stri if !update && lf != nil { if entry := lf.Lookup(agentName); entry != nil && !entry.IsStale(harnessHash) { printer.StepDone(fmt.Sprintf("Lock entry for %s is up to date (%d dependencies)", agentName, len(entry.Dependencies))) - // A current dependency lock is not evidence that harness diagnostics - // ran under this CLI version. Keep the no-composition fast path, but - // make its reporting limit explicit instead of implying a clean lint. - printer.StepWarn(fmt.Sprintf("Harness diagnostics for %s were skipped because its lock entry is current; use --update to check reserved env.sandbox keys", agentName)) return nil, nil } } diff --git a/internal/cli/lock_reserved_env_cache_test.go b/internal/cli/lock_reserved_env_cache_test.go index 341648c549..7236f1d17d 100644 --- a/internal/cli/lock_reserved_env_cache_test.go +++ b/internal/cli/lock_reserved_env_cache_test.go @@ -6,7 +6,6 @@ import ( "os" "path/filepath" "testing" - "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -16,70 +15,8 @@ import ( "github.com/fullsend-ai/fullsend/internal/ui" ) -// A current lock entry skips composition as well as dependency resolution. -// Make that explicit rather than suggesting the absence of a warning means -// env.sandbox was checked. A missing base makes accidental composition fail; -// neither the single-harness nor --all path may rewrite the existing lock. -func TestLockCurrentEntry_ReportsSkippedDiagnostics(t *testing.T) { - t.Parallel() - - for _, all := range []bool{false, true} { - name := "single" - if all { - name = "all" - } - t.Run(name, func(t *testing.T) { - t.Parallel() - - dir := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(dir, "harness"), 0o755)) - content := []byte("base: unavailable.yaml\nagent: https://example.invalid/agent.md\nrole: test\n" + - "env:\n sandbox:\n HTTPS_PROXY: http://proxy.example:8080\n") - require.NoError(t, os.WriteFile(filepath.Join(dir, "harness", "code.yaml"), content, 0o644)) - - lockPath := filepath.Join(dir, "lock.yaml") - lf := &lock.LockFile{Harnesses: map[string]lock.HarnessLock{ - "code": { - Source: "harness/code.yaml", SHA256: fetch.ComputeSHA256(content), - ResolvedAt: time.Unix(1, 0).UTC(), - Dependencies: []lock.DependencyEntry{{ - Field: "agent", URL: "https://example.invalid/agent.md", SHA256: "not-in-cache", - }}, - }, - }} - require.NoError(t, lock.Save(lockPath, lf)) - before, err := os.ReadFile(lockPath) - require.NoError(t, err) - stamp := time.Unix(1, 0) - require.NoError(t, os.Chtimes(lockPath, stamp, stamp)) - beforeInfo, err := os.Stat(lockPath) - require.NoError(t, err) - - var out bytes.Buffer - printer := ui.New(&out) - if all { - err = runLockAll(context.Background(), dir, "", false, resolveFlags{}, printer) - } else { - err = runLock(context.Background(), "code", dir, "", false, resolveFlags{}, printer) - } - require.NoError(t, err) - assert.Contains(t, out.String(), "up to date") - assert.Contains(t, out.String(), "Harness diagnostics for code were skipped") - assert.Contains(t, out.String(), "--update to check reserved env.sandbox keys") - assert.NotContains(t, out.String(), "HTTPS_PROXY", "no composed-key check was performed") - - after, err := os.ReadFile(lockPath) - require.NoError(t, err) - afterInfo, err := os.Stat(lockPath) - require.NoError(t, err) - assert.Equal(t, before, after, "a diagnostic notice must not refresh dependencies") - assert.Equal(t, beforeInfo.ModTime(), afterInfo.ModTime(), "the lock must not be rewritten") - _, err = os.Stat(filepath.Join(dir, ".fullsend-cache")) - assert.True(t, os.IsNotExist(err), "a cache hit must not compose or fetch resources") - }) - } -} - +// A current lock entry skips composition, so the guide sends users to +// --update to check reserved keys. --update must compose base and child. func TestLockCurrentEntry_UpdateReportsReservedKeys(t *testing.T) { t.Parallel() @@ -99,5 +36,4 @@ func TestLockCurrentEntry_UpdateReportsReservedKeys(t *testing.T) { assert.Contains(t, out.String(), "2 env.sandbox key(s) are reserved") assert.Contains(t, out.String(), "HTTPS_PROXY, PATH", "--update must check the composed base and child") assert.NotContains(t, out.String(), "MY_TOOL_SETTING") - assert.NotContains(t, out.String(), "diagnostics for code were skipped") } diff --git a/internal/cli/run.go b/internal/cli/run.go index bf5691972f..f77d43eb3f 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -3291,14 +3291,12 @@ func harnessEnvLookup(key string) (string, bool) { // from harness YAML could break sandbox operation, or are security-sensitive // vars that could influence sandbox execution (e.g. shared library injection, // auto-sourced shell startup files). OIDC credential vars from oidcDenyKeys -// are merged in by init() to prevent re-injection into the sandbox (#5832), -// as is the sandbox credential deny-list (sandbox.ReservedCredentialKeys) so a -// name refused as a provider credential key cannot be injected here (#3373). +// are merged in by init() to prevent re-injection into the sandbox (#5832). +// The sandbox credential deny-list is checked beside this map by +// isReservedSandboxKey, not merged into it, because runnerSecretNameRefused +// reads this map too and must accept those names (ADR 0145). // Entries are matched case-insensitively; every name in the map is uppercase. // NOTE: keep in sync with bootstrapEnv exports below for FULLSEND_* keys. -// HOME, SHELL, BASH_ENV, ENV and TRACEPARENT are also literals in -// runnerSecretRefusedNames in runner_secrets.go; keep both sites in sync -// (see the NOTE there for which test pins each). var reservedSandboxKeys = map[string]bool{ "PATH": true, "HOME": true, @@ -3352,25 +3350,15 @@ func init() { // keys there; only credential values (child env) may expand them. sandbox.CredentialOnlyExpansionKeys(k) } - // The credential deny-list and env.sandbox reach child processes through - // different doors — a credential name lands in the host-side `openshell - // provider` environment, env.sandbox is exported inside the sandbox — but - // the risk a name carries is the same once it is in a child's - // environment. Merging rather than duplicating keeps one source of truth: - // a name added to the credential list is now blocked at both doors - // automatically (#3373). - for _, k := range sandbox.ReservedCredentialKeys() { - reservedSandboxKeys[k] = true - } } -// isReservedSandboxKey reports whether an env.sandbox key is blocked by name. -// Keys are case-folded because every entry in reservedSandboxKeys is stored -// uppercase, which TestReservedSandboxKeys_AreUppercase pins. The gate below -// and the lint diagnostics in reservedSandboxEnvDiagnostics both call this, so -// they cannot disagree about what a run drops (#3373). +// isReservedSandboxKey reports whether an env.sandbox key is blocked by name: +// a runner-reserved name, or one the sandbox credential deny-list refuses, so +// a name unsafe as a provider credential is not exported here either (#3373). +// Matching is case-insensitive. The gate and reservedSandboxEnvDiagnostics +// both call this, so they cannot disagree about what a run drops. func isReservedSandboxKey(k string) bool { - return reservedSandboxKeys[strings.ToUpper(k)] + return reservedSandboxKeys[strings.ToUpper(k)] || sandbox.IsReservedCredentialKey(k) } // buildSandboxEnvLines generates export lines for env.sandbox values (ADR 0055). diff --git a/internal/cli/run_reserved_credential_env_test.go b/internal/cli/run_reserved_credential_env_test.go index 516a6831e3..a24f02e873 100644 --- a/internal/cli/run_reserved_credential_env_test.go +++ b/internal/cli/run_reserved_credential_env_test.go @@ -14,9 +14,9 @@ import ( "github.com/fullsend-ai/fullsend/internal/sandbox" ) -// reservedInfraSandboxKeys are the seven process-loading names env.sandbox has -// rejected since before #3373 widened the blocklist to the credential -// deny-list. All seven are also members of reservedCredentialKeys, under its +// reservedInfraSandboxKeys are the seven process-loading names env.sandbox +// rejected before #3373 widened the blocklist to the credential deny-list. +// All seven are also members of reservedCredentialKeys, under its // Process loading / shell behavior group, so the loop below asserts them twice // — deliberately: keeping them here means the sandbox door still pins them if // a name is ever dropped from the credential door. Some of the other @@ -51,8 +51,8 @@ func TestReservedSandboxKeys_CoversReservedCredentialKeys(t *testing.T) { t.Run(key, func(t *testing.T) { t.Parallel() - assert.True(t, reservedSandboxKeys[key], - "reservedSandboxKeys must include %s: env.sandbox can inject a variable the credential path refuses", key) + assert.True(t, isReservedSandboxKey(key), + "env.sandbox must refuse %s: it can inject a variable the credential path refuses", key) lines := buildSandboxEnvLines(&harness.Harness{ Env: &harness.EnvConfig{Sandbox: map[string]string{key: "/tmp/evil"}}, @@ -108,11 +108,13 @@ func TestGuideNamesMatchTheGate(t *testing.T) { matches := guideEnvNameRe.FindAllStringSubmatch(note, -1) // The floor is what keeps this test from failing silently: a reworded // paragraph the pattern no longer matches would otherwise scan zero names - // and pass. The note enumerates in the low fifties today, including the - // two pass-through names in the carve-out sentence, so a floor in the - // fifties also catches a whole bullet being dropped from the prose. + // and pass. The note enumerates about fifty-five names today, including + // the two pass-through names in the carve-out sentence (the runner's own + // FULLSEND_* exports are described as a family, not listed, so that a new + // runner export does not need a guide edit), so a floor just under that + // also catches a whole bullet being dropped from the prose. require.GreaterOrEqual(t, len(matches), 50, - "the note enumerates in the low fifties but only %d matched, so either the pattern no longer fits the prose or names were dropped from it — this test proves nothing until one of those is fixed", + "the note enumerates about fifty-five names but only %d matched, so either the pattern no longer fits the prose or names were dropped from it — this test proves nothing until one of those is fixed", len(matches)) // The pass-through set is a second copy of what the prose promises, so pin @@ -132,8 +134,15 @@ func TestGuideNamesMatchTheGate(t *testing.T) { t.Parallel() if documentedPassthroughNames[name] { - assert.False(t, isReservedSandboxKey(name), + // The carve-out is a promise that hook inputs still arrive, so + // check delivery itself, not only the predicate. + require.False(t, isReservedSandboxKey(name), "the guide says %s is still delivered through env.sandbox, but the gate now drops it", name) + lines := buildSandboxEnvLines(&harness.Harness{ + Env: &harness.EnvConfig{Sandbox: map[string]string{name: "value"}}, + }) + assert.Contains(t, strings.Join(lines, "\n"), "export "+name+"=", + "the guide promises %s reaches the sandbox, but the gate dropped it", name) return } assert.True(t, isReservedSandboxKey(name), @@ -141,26 +150,3 @@ func TestGuideNamesMatchTheGate(t *testing.T) { }) } } - -// TestDocumentedPassthroughNames_StayDelivered pins the other half of the same -// paragraph, which promises that hook inputs the harness supplies deliberately -// still arrive. Blocking them would break the SSRF and allowlist hooks, so the -// guide's carve-out is worth a test as much as the blocklist is. -func TestDocumentedPassthroughNames_StayDelivered(t *testing.T) { - t.Parallel() - - for _, key := range []string{"FULLSEND_CANARY_TOKEN", "FULLSEND_TOOL_ALLOWLIST"} { - t.Run(key, func(t *testing.T) { - t.Parallel() - - require.False(t, reservedSandboxKeys[key], - "the guide says %s is still delivered through env.sandbox", key) - - lines := buildSandboxEnvLines(&harness.Harness{ - Env: &harness.EnvConfig{Sandbox: map[string]string{key: "value"}}, - }) - assert.Contains(t, strings.Join(lines, "\n"), "export "+key+"=", - "the guide promises %s reaches the sandbox, but the gate dropped it", key) - }) - } -} diff --git a/internal/cli/run_reserved_env_case_test.go b/internal/cli/run_reserved_env_case_test.go index ebea9b40c4..fc6f74bcdf 100644 --- a/internal/cli/run_reserved_env_case_test.go +++ b/internal/cli/run_reserved_env_case_test.go @@ -7,13 +7,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/fullsend-ai/fullsend/internal/harness" + "github.com/fullsend-ai/fullsend/internal/sandbox" ) // TestBuildSandboxEnvLines_ReservesCaseInsensitively pins that the env.sandbox // gate matches reserved names the way the provider-credential and plugin-env -// doors already do. Every name in reservedSandboxKeys is stored uppercase, so -// before the fold the proxy names merged in from reservedCredentialKeys were -// reachable through their lowercase spelling — and libcurl documents +// doors already do. Every reserved name is stored uppercase, so before the +// fold the credential deny-list's proxy names were reachable through their +// lowercase spelling — and libcurl documents // http_proxy as lowercase-only, so an exact-case gate blocks a spelling tools // may not read while exporting the one they do. The comment on // buildSandboxEnvLines carries the full rationale (#3373). @@ -38,8 +39,8 @@ func TestBuildSandboxEnvLines_ReservesCaseInsensitively(t *testing.T) { t.Run(tc.key, func(t *testing.T) { t.Parallel() - assert.True(t, reservedSandboxKeys[strings.ToUpper(tc.key)], - "reservedSandboxKeys must cover %s through its uppercase form (%s)", tc.key, tc.why) + assert.True(t, isReservedSandboxKey(tc.key), + "the gate must refuse %s case-insensitively (%s)", tc.key, tc.why) lines := buildSandboxEnvLines(&harness.Harness{ Env: &harness.EnvConfig{Sandbox: map[string]string{tc.key: "http://evil.example:8080"}}, @@ -51,11 +52,9 @@ func TestBuildSandboxEnvLines_ReservesCaseInsensitively(t *testing.T) { } // TestReservedSandboxKeys_AreUppercase pins the invariant the case-folded gate -// is built on. The gate looks keys up as -// reservedSandboxKeys[strings.ToUpper(k)], which only works because every -// entry is stored uppercase — a name added later in mixed or lower case would -// be unmatchable and therefore silently unenforceable, with no other test -// catching it. +// is built on. The gate looks keys up by their uppercase form in both lists, +// which only works because every entry is stored uppercase — a name added +// later in mixed or lower case would be silently unenforceable. func TestReservedSandboxKeys_AreUppercase(t *testing.T) { t.Parallel() @@ -63,4 +62,8 @@ func TestReservedSandboxKeys_AreUppercase(t *testing.T) { assert.Equal(t, strings.ToUpper(key), key, "reservedSandboxKeys entry %q is not uppercase, so the case-folded env.sandbox gate can never match it", key) } + for _, key := range sandbox.ReservedCredentialKeys() { + assert.Equal(t, strings.ToUpper(key), key, + "credential deny-list entry %q is not uppercase, so the case-folded env.sandbox gate can never match it", key) + } } diff --git a/internal/cli/run_reserved_env_lint_test.go b/internal/cli/run_reserved_env_lint_test.go index 79b8f4a34b..01d409b4c2 100644 --- a/internal/cli/run_reserved_env_lint_test.go +++ b/internal/cli/run_reserved_env_lint_test.go @@ -98,27 +98,6 @@ func TestReservedSandboxEnvDiagnostics_CleanHarness(t *testing.T) { assert.Nil(t, reservedSandboxEnvDiagnostics(nil), "a nil harness must not panic") } -// TestReservedSandboxEnvDiagnostics_AgreesWithTheGate is the drift guard: it -// feeds every reserved name back through both the diagnostic and the gate, so -// the warning cannot start lying about what a run drops. It reads the same map -// the gate consults, so a name added to any merged list is covered here the -// moment it is added. -func TestReservedSandboxEnvDiagnostics_AgreesWithTheGate(t *testing.T) { - t.Parallel() - - for key := range reservedSandboxKeys { - t.Run(key, func(t *testing.T) { - t.Parallel() - - h := &harness.Harness{Env: &harness.EnvConfig{Sandbox: map[string]string{key: "x"}}} - diags := reservedSandboxEnvDiagnostics(h) - require.Len(t, diags, 1, "%s is reserved, so it must be reported", key) - assert.True(t, strings.Contains(diags[0].Message, key)) - assert.Empty(t, buildSandboxEnvLines(h), "%s must not reach the sandbox", key) - }) - } -} - // TestReservedSandboxEnvDiagnostics_ReportsInSortedOrder pins the exact list // text rather than membership. lock de-duplicates diagnostics across forge // variants by diag.String(), and the keys arrive from map iteration, so diff --git a/internal/cli/runner_secrets.go b/internal/cli/runner_secrets.go index 7921525466..cc8b325991 100644 --- a/internal/cli/runner_secrets.go +++ b/internal/cli/runner_secrets.go @@ -69,35 +69,15 @@ var workflowSetEnvNames = []string{ // runnerSecretRefusedNames are minted role tokens and other runner-owned // names outside the refused families: GH_TOKEN, every role token in -// roleTokenVars, GITLAB_TOKEN, PATH and workflowSetEnvNames. oidcDenyKeys and -// providerOnlyKeys are refused as well via harnessExpansionDenied +// roleTokenVars, GITLAB_TOKEN, PATH and workflowSetEnvNames. oidcDenyKeys, +// providerOnlyKeys and reservedSandboxKeys are refused as well // (runnerSecretNameRefused), which keeps GH_WORKFLOW_TOKEN (ADR 0114) -// unforgeable. The runner infrastructure names HOME, SHELL, BASH_ENV, ENV and -// TRACEPARENT are listed here rather than read from reservedSandboxKeys: -// #3373 widened that map with credential-class names (proxy, TLS trust, git, -// interpreter, loader and shell-behavior) that are dangerous inside the -// sandbox child but not as host-side runner-secret keys for host-side -// scripts. Sharing the map made every credential name also fail the -// runner-secret bundle check after the merge, breaking legitimate host-side -// proxy and CA configuration. The two doors keep separate name sets on -// purpose. -// -// NOTE: HOME, SHELL, BASH_ENV, ENV and TRACEPARENT are also literals in -// reservedSandboxKeys in run.go; keep both sites in sync. The four -// process-loading names (HOME, SHELL, BASH_ENV, ENV) are pinned at this -// door by TestRunnerSecretNameRefused_AllowsCredentialClassNames (the -// dualClass set); TRACEPARENT is pinned by -// TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames. +// unforgeable. var runnerSecretRefusedNames = func() map[string]bool { names := map[string]bool{ "GH_TOKEN": true, "GITLAB_TOKEN": true, "PATH": true, - "HOME": true, - "SHELL": true, - "BASH_ENV": true, - "ENV": true, - "TRACEPARENT": true, } for _, n := range workflowSetEnvNames { names[n] = true @@ -124,11 +104,12 @@ func runnerSecretDisplayName(name string) string { // neither be a key in FULLSEND_GITHUB_RUNNER_SECRETS nor receive a runner secret // value as an env.runner key. Matched case-insensitively, consistent with // the env.sandbox gate (isReservedSandboxKey), so "path" is refused like -// "PATH" (zsh ties a few lowercase arrays such as path to their uppercase -// scalars). +// "PATH". It reads reservedSandboxKeys but not the credential deny-list the +// env.sandbox gate also checks: proxy, TLS-trust and Git settings are +// legitimate host-side runner secrets (ADR 0145). func runnerSecretNameRefused(name string) bool { upper := strings.ToUpper(name) - if harnessExpansionDenied(upper) || runnerSecretRefusedNames[upper] { + if harnessExpansionDenied(upper) || reservedSandboxKeys[upper] || runnerSecretRefusedNames[upper] { return true } for _, p := range runnerSecretRefusedPrefixes { diff --git a/internal/cli/runner_secrets_test.go b/internal/cli/runner_secrets_test.go index f363d0a558..505fb9cab9 100644 --- a/internal/cli/runner_secrets_test.go +++ b/internal/cli/runner_secrets_test.go @@ -410,40 +410,19 @@ func TestRunnerSecretNameRefused_AllowsOrdinaryNames(t *testing.T) { } } -// TestRunnerSecretNameRefused_AllowsCredentialClassNames pins the two-door -// split introduced with #3373: credential-class names are refused by the -// env.sandbox gate (isReservedSandboxKey) because they are dangerous inside -// the sandbox child, but they are accepted as runner-secret keys because -// runner secrets stay on the host side for host-side scripts. Before this -// split, runnerSecretNameRefused read reservedSandboxKeys directly, so the -// #3373 merge made every credential name also fail the runner-secret bundle -// check, breaking legitimate host-side proxy and CA configuration. -// -// The credential half reads sandbox.ReservedCredentialKeys() live rather -// than copying names, following the package's drift-guard convention: a -// name added to the credential list is pinned for both doors the moment -// it is added. Names that are dual-class — both credential-list entries -// and runner infrastructure — are asserted as refused at both doors, not -// skipped. The dual-class set comes from reservedInfraSandboxKeys -// (run_reserved_credential_env_test.go), which is maintained by hand: a -// name later added to both the credential list and the infrastructure -// literals fails this test until that slice is updated. LD_- and -// DYLD_-prefixed credential names are refused at the runner-secret door by -// the matching prefixes in runnerSecretRefusedPrefixes, because the dynamic -// loader reads them on the host side too. +// TestRunnerSecretNameRefused_AllowsCredentialClassNames pins the two doors +// (ADR 0145): the env.sandbox gate refuses every credential-class name, and +// the runner-secret door accepts it, because runner secrets reach only +// host-side scripts. A name that is also in reservedSandboxKeys (PATH, HOME, +// SHELL, BASH_ENV, ENV, LD_PRELOAD, LD_LIBRARY_PATH) or under a refused +// loader prefix stays refused at both doors. Credential names are read live +// from sandbox.ReservedCredentialKeys, so a new one is covered at once. func TestRunnerSecretNameRefused_AllowsCredentialClassNames(t *testing.T) { t.Parallel() credentialKeys := sandbox.ReservedCredentialKeys() require.NotEmpty(t, credentialKeys, "no credential names to probe; this test is vacuous") - // Dual-class names: in the credential list AND the runner infrastructure - // literals, taken from the hand-maintained reservedInfraSandboxKeys. - dualClass := make(map[string]bool, len(reservedInfraSandboxKeys)) - for _, name := range reservedInfraSandboxKeys { - dualClass[name] = true - } - for _, name := range credentialKeys { t.Run(name, func(t *testing.T) { t.Parallel() @@ -451,9 +430,9 @@ func TestRunnerSecretNameRefused_AllowsCredentialClassNames(t *testing.T) { assert.True(t, isReservedSandboxKey(name), "%s must be refused by the env.sandbox gate", name) - if dualClass[name] || strings.HasPrefix(name, "LD_") || strings.HasPrefix(name, "DYLD_") { + if reservedSandboxKeys[name] || strings.HasPrefix(name, "LD_") || strings.HasPrefix(name, "DYLD_") { // Also refused as a runner-secret key: runner infrastructure - // (PATH, HOME, SHELL, BASH_ENV, ENV) or dynamic-loader names. + // or dynamic-loader names. assert.True(t, runnerSecretNameRefused(name), "%s is dual-class (credential and infrastructure) and must stay refused at both doors", name) } else { @@ -475,40 +454,6 @@ func TestRunnerSecretNameRefused_AllowsCredentialClassNames(t *testing.T) { }) } -// TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames is the drift -// guard for the two-door split: every name in reservedSandboxKeys that does -// not come from sandbox.ReservedCredentialKeys() must still be refused as a -// runner-secret key. Before the split, reading reservedSandboxKeys directly -// provided this coverage for free. Now that runnerSecretNameRefused uses its -// own set, a non-prefixed infrastructure name added to the sandbox map -// without a corresponding runnerSecretRefusedNames entry would silently -// stop being refused here. This test catches that divergence the same way -// TestReservedSandboxKeys_CoversReservedCredentialKeys pins the credential -// merge and internal/sandbox/reserved_env_drift_test.go pins the -// plugin-superset invariant. -func TestRunnerSecretNameRefused_CoversNonCredentialSandboxNames(t *testing.T) { - t.Parallel() - - keys := sandbox.ReservedCredentialKeys() - credentialNames := make(map[string]bool, len(keys)) - for _, k := range keys { - credentialNames[k] = true - } - require.NotEmpty(t, credentialNames, "no credential names to exclude; the drift check is vacuous") - - for name := range reservedSandboxKeys { - if credentialNames[name] { - // Dual-class names (PATH, HOME, SHELL, LD_PRELOAD, etc.) are - // pinned in AllowsCredentialClassNames above; names that are - // credential-only are deliberately allowed at this door. This - // test covers the non-credential infrastructure half only. - continue - } - assert.True(t, runnerSecretNameRefused(name), - "%s is in reservedSandboxKeys but not from the credential list; it must stay refused as a runner-secret key. Add it to runnerSecretRefusedNames or a refused prefix.", name) - } -} - // TestRunnerSecretNameRefused_CaseInsensitive pins the case fold: a // lowercase or mixed-case key is refused exactly when its uppercase form // is, and credential-class names stay allowed in any case. diff --git a/internal/sandbox/reserved_credential_keys_test.go b/internal/sandbox/reserved_credential_keys_test.go index 514dd49e9c..a057c72ad1 100644 --- a/internal/sandbox/reserved_credential_keys_test.go +++ b/internal/sandbox/reserved_credential_keys_test.go @@ -8,11 +8,10 @@ import ( "github.com/stretchr/testify/require" ) -// TestReservedCredentialKeys pins the accessor that internal/cli merges into -// its own sandbox env blocklist (#3373). It must expose the complete reserved -// set — a silently narrowed list would reopen the drift this exists to close — -// in a stable order, and hand back a copy callers cannot use to mutate package -// state. +// TestReservedCredentialKeys pins the accessor that internal/cli's tests +// enumerate to check its env.sandbox gate (#3373). It must expose the +// complete reserved set — a silently narrowed list would reopen the drift +// this exists to close — in a stable order. func TestReservedCredentialKeys(t *testing.T) { t.Parallel() @@ -32,21 +31,6 @@ func TestReservedCredentialKeys(t *testing.T) { assert.True(t, sort.StringsAreSorted(keys), "accessor must return a deterministic order; its contract is exported") - - // The slice is the caller's to corrupt — and a later caller must still get - // a clean list, which is what fails if the accessor ever memoizes and - // hands out one shared slice. - want := append([]string(nil), keys...) - require.NotEmpty(t, keys, "no reserved credential keys to probe; the blocklist would be empty") - first := keys[0] - keys[0] = "FULLSEND_ACCESSOR_MUTATION_PROBE" - - assert.False(t, reservedCredentialKeys["FULLSEND_ACCESSOR_MUTATION_PROBE"], - "mutating the returned slice must not add to the blocklist") - assert.True(t, reservedCredentialKeys[first], - "mutating the returned slice must not remove from the blocklist") - assert.Equal(t, want, ReservedCredentialKeys(), - "a later caller must receive an untouched list") } // reservedCredentialKeysUnpinnedFloor holds the entries of @@ -64,6 +48,18 @@ var reservedCredentialKeysUnpinnedFloor = []string{ "SHELL", "ENV", "LD_LIBRARY_PATH", } +// TestIsReservedCredentialKey pins the predicate internal/cli's env.sandbox +// gate calls: every listed name in any case, and nothing else. +func TestIsReservedCredentialKey(t *testing.T) { + t.Parallel() + + for _, k := range ReservedCredentialKeys() { + assert.True(t, IsReservedCredentialKey(k), "%s is on the list", k) + } + assert.True(t, IsReservedCredentialKey("https_proxy"), "matching is case-insensitive") + assert.False(t, IsReservedCredentialKey("MY_TOOL_SETTING"), "an unlisted name is not reserved") +} + // TestReservedCredentialKeys_RetainUnpinnedNames keeps the credential // deny-list from losing an entry that nothing else would notice. func TestReservedCredentialKeys_RetainUnpinnedNames(t *testing.T) { diff --git a/internal/sandbox/sandbox.go b/internal/sandbox/sandbox.go index f72da38196..b7c71f92de 100644 --- a/internal/sandbox/sandbox.go +++ b/internal/sandbox/sandbox.go @@ -581,7 +581,7 @@ func ImportProfileVerified(ctx context.Context, id, profilePath string) error { // credential keys. Credential keys become env vars in the openshell child // process; allowing security-sensitive names would let a URL-fetched provider // definition influence process loading or shell behavior. -// NOTE: see also reservedSandboxKeys in internal/cli/run.go for the sandbox env blocklist. +// NOTE: internal/cli's env.sandbox gate checks this list too (#3373). var reservedCredentialKeys = map[string]bool{ // Process loading / shell behavior "PATH": true, @@ -628,25 +628,26 @@ var reservedCredentialKeys = map[string]bool{ } // ReservedCredentialKeys returns the names reservedCredentialKeys refuses as -// provider credential keys, for consumers that gate a different input to a -// child process. +// provider credential keys. Production code checks membership through +// IsReservedCredentialKey; this accessor exists so tests in other packages +// (internal/cli's env.sandbox gate tests) can enumerate the live list +// instead of copying it. // // A name is on this list because letting harness-supplied configuration set it // in a child process could change process loading, shell behavior, TLS trust // or git behavior. The doors differ: a credential name reaches the host-side // `openshell provider` environment, while harness `env.sandbox` is exported // inside the sandbox. The exposure is the same once the name is in a child's -// environment, so every name here is blocked on both sides — internal/cli -// merges this list into its sandbox env blocklist at init so the two cannot -// drift apart again (#3373). Absence from this list is not a statement that a -// name is safe — the plugin-env deny-list is deliberately broader, in the +// environment, so every name here is blocked on both sides — internal/cli's +// env.sandbox gate checks it through IsReservedCredentialKey, so the two +// cannot drift apart (#3373). Absence from this list is not a statement that +// a name is safe — the plugin-env deny-list is deliberately broader, in the // direction reserved_env_drift_test.go pins: every credential name is also a -// plugin-env name, not the converse. The cross-door invariant added here is -// pinned by TestReservedSandboxKeys_CoversReservedCredentialKeys in -// internal/cli. +// plugin-env name, not the converse. The cross-door invariant is pinned by +// TestReservedSandboxKeys_CoversReservedCredentialKeys in internal/cli. // -// The result is a copy in deterministic order: callers must not be able to edit -// the blocklist, and the order is part of this function's contract. +// The result is a fresh sorted slice, so callers cannot edit the blocklist +// and subtests run in a stable order. func ReservedCredentialKeys() []string { keys := make([]string, 0, len(reservedCredentialKeys)) for k := range reservedCredentialKeys { @@ -656,6 +657,12 @@ func ReservedCredentialKeys() []string { return keys } +// IsReservedCredentialKey reports, case-insensitively, whether name is +// refused as a provider credential key. +func IsReservedCredentialKey(name string) bool { + return reservedCredentialKeys[strings.ToUpper(name)] +} + // EnsureProvider creates or updates a provider on the gateway. Credential // values may contain ${VAR} references which are expanded from the host // environment before being passed to openshell. @@ -674,7 +681,7 @@ func ReservedCredentialKeys() []string { func EnsureProvider(ctx context.Context, name, providerType string, credentials, config map[string]string, fromURL bool) error { if fromURL { for k := range credentials { - if reservedCredentialKeys[strings.ToUpper(k)] { + if IsReservedCredentialKey(k) { return fmt.Errorf("provider %q: credential key %q is a reserved environment variable name", name, k) } } @@ -694,7 +701,7 @@ func EnsureProvider(ctx context.Context, name, providerType string, credentials, // form in the child process environment, never on the command line. func EnsureProviderLiteral(ctx context.Context, name, providerType string, credentials map[string]string) error { for k := range credentials { - if reservedCredentialKeys[strings.ToUpper(k)] { + if IsReservedCredentialKey(k) { return fmt.Errorf("provider %q: credential key %q is a reserved environment variable name", name, k) } } From 0fb7589a803fca6bb670ac7881d62efb1ddb0903 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Tue, 20 Oct 2026 15:40:03 -0400 Subject: [PATCH 7/8] docs(#3373): link the OpenShell reference at the pinned gateway version The migration guide linked the OpenShell gateway configuration reference at main. fullsend pins OpenShell 0.1.4, and the reference at main already documents settings the pinned gateway lacks: additional_ca_bundle, which OpenShell 0.1.5 adds for Podman gateways, appears twice at main and not at v0.1.4. A reader migrating SSL_CERT_FILE or NODE_EXTRA_CA_CERTS would find that key and set it on a gateway that rejects it. Link the v0.1.4 tag, the version openshell-version.sh pins, so the reference matches the gateway fullsend ships; a Renovate manager in the next commit moves the tag with the pin. Say in the certificate bullet that the linked tag is what the pinned gateway supports, and that where that tag lacks additional_ca_bundle a private CA used without a corporate proxy has no gateway-level replacement for SSL_CERT_FILE or NODE_EXTRA_CA_CERTS. That sentence is written against the linked tag, so it stays true after the pin moves. Found in review of 08ada39cb by waynesun09. Signed-off-by: Tim Pouyer --- docs/guides/user/customizing-agents.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/guides/user/customizing-agents.md b/docs/guides/user/customizing-agents.md index 39e0a7b9d2..fbbfc08e80 100644 --- a/docs/guides/user/customizing-agents.md +++ b/docs/guides/user/customizing-agents.md @@ -543,12 +543,12 @@ Coordinate these changes with the operator of your OpenShell gateway: the version it pins in [`.github/scripts/openshell-version.sh`](https://github.com/fullsend-ai/fullsend/blob/main/.github/scripts/openshell-version.sh) at your release tag. - The [OpenShell gateway configuration reference](https://github.com/NVIDIA/OpenShell/blob/main/docs/how-it-works/gateways/configuration.mdx) - describes proxy chaining for policy-approved TLS connections using the HTTP - CONNECT method to establish a tunnel. Plain-HTTP destination traffic remains - direct. These are not fullsend harness fields or a general replacement for - every `HTTP_PROXY` or `ALL_PROXY` use. Do not reintroduce application proxy - exports through `.env.d` as a workaround. + The [OpenShell gateway configuration reference](https://github.com/NVIDIA/OpenShell/blob/v0.1.4/docs/how-it-works/gateways/configuration.mdx) + for that version describes proxy chaining for policy-approved TLS + connections using the HTTP CONNECT method to establish a tunnel. Plain-HTTP + destination traffic remains direct. These are not fullsend harness fields or + a general replacement for every `HTTP_PROXY` or `ALL_PROXY` use. Do not + reintroduce application proxy exports through `.env.d` as a workaround. **GitHub Action limitation:** fullsend's own GitHub Action writes `gateway.toml` with a fixed template and has no input for upstream proxy or CA settings. Self-hosted Actions runners behind a corporate proxy that relied @@ -565,7 +565,12 @@ Coordinate these changes with the operator of your OpenShell gateway: generated bundle with a custom-only file, or changing only the agent image's trust store, configures both trust paths. Have the gateway operator validate the required application and supervisor connections before - deployment. + deployment. The linked tag is what the pinned gateway supports; a setting + documented only at a later OpenShell tag is not available until fullsend + bumps the pin. If the linked tag does not document `additional_ca_bundle` + (added in OpenShell 0.1.5, for Podman gateways), a private CA used without + a corporate proxy has no gateway-level replacement for `SSL_CERT_FILE` or + `NODE_EXTRA_CA_CERTS` at that version. - **Git settings:** place git configuration with `host_files` (a git config file or shell rc file the tools load) or use the tool's own configuration, instead of `GIT_SSH_COMMAND`, `GIT_CONFIG_GLOBAL`, `GIT_ASKPASS` and the From c249eca4fbe8d52efe7c30a502cbbf858238449b Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Tue, 20 Oct 2026 15:40:13 -0400 Subject: [PATCH 8/8] chore(#3373): track the OpenShell tag in the customizing agents guide link The previous commit pins the OpenShell gateway configuration link in docs/guides/user/customizing-agents.md to the tag openshell-version.sh pins. Renovate updated that pin file and the two copies in running-agents-locally.md (#4808) but nothing rewrote a tag inside a link, so the next OpenShell bump would leave the link one version behind the gateway again. Add a regex customManager for the link with the same depName, datasource and extractVersionTemplate as the #4808 manager, so the tag moves in the same openshell group PR. Automerge and postUpgradeTasks are unchanged. Checked that the matchString finds exactly one value in the guide, the pinned 0.1.4, with both a JavaScript RegExp and Python re, and that the file pattern matches the guide path. Signed-off-by: Tim Pouyer --- renovate.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/renovate.json b/renovate.json index 1ed8a35a03..bba4858a4d 100644 --- a/renovate.json +++ b/renovate.json @@ -140,6 +140,17 @@ "datasourceTemplate": "github-releases", "extractVersionTemplate": "^v(?.*)$" }, + { + "customType": "regex", + "description": "Track the OpenShell tag in the gateway configuration link of the customizing agents guide (migrating proxy and certificate settings), so the link follows the pin in the same openshell group PR instead of pointing at a tag the pinned gateway does not match (#3373).", + "managerFilePatterns": ["/^docs/guides/user/customizing-agents\\.md$/"], + "matchStrings": [ + "github\\.com/NVIDIA/OpenShell/blob/v(?\\d+\\.\\d+\\.\\d+)/" + ], + "depNameTemplate": "NVIDIA/OpenShell", + "datasourceTemplate": "github-releases", + "extractVersionTemplate": "^v(?.*)$" + }, { "customType": "regex", "description": "Track the gcloud CLI version pin in the runner image. GCLOUD_SHA256_{AMD64,ARM64} must be refreshed manually from https://cloud.google.com/sdk/docs/install — the runner-image PR build fails on checksum mismatch until they are.",