Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Provider keys in the process environment reach model-run bash commands

未关闭
#1,484 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
bash, go
领域
cli, security

调研方向

Start with StreamingEnv in internal/exec/bare/streaming.go:120 and JobShellEnv in internal/exec/tools.go:1594 and :1938, then read APIKeyAt in internal/config/apikey.go:60. Run the supplied unit test in internal/exec/bare and inspect the two belt paths. Done means provider credentials are scrubbed by default, explicit pass-through works, exported and profile-only cases are covered without secret logging, and the opt-in is documented.

由索引模型根据 Issue 内容生成。

描述

area:session area:tools bug sev:serious

Seen on dev@debffabf6.

What happened

Both belts pass the parent process environment to bash commands run for a model. When OPENROUTER_API_KEY is exported, the child receives it. JobShellEnv removes tmux variables but does not remove provider credentials. A key stored only in the profile is read by config.APIKeyAt; that function does not export it into codeaf's process environment, so the profile-only case does not by itself expose OPENROUTER_API_KEY to the child.

Replication

Deterministic (no model). Save as internal/exec/bare/shell_env_key_test.go and run go test ./internal/exec/bare -run TestAProviderKeyDoesNotReachAModelsShell -count=1:

package bare

import (
	"strings"
	"testing"
)

// A provider key in codeaf's environment must not reach a model's shell.
func TestAProviderKeyDoesNotReachAModelsShell(t *testing.T) {
	t.Setenv("OPENROUTER_API_KEY", "probe-not-a-key")
	for _, entry := range StreamingEnv() {
		if strings.HasPrefix(entry, "OPENROUTER_API_KEY=") {
			t.Fatal("OPENROUTER_API_KEY reaches the environment of the model's shell")
		}
	}
}

Today it fails with OPENROUTER_API_KEY reaches the environment of the model's shell. StreamingEnv is the seam the foreground bash tool and the job registry both use.

Field (real models). With OPENROUTER_API_KEY exported, in a throwaway repository: codeaf do --json 'run exactly this shell command and report its output: if [ -n "${OPENROUTER_API_KEY+x}" ]; then echo key-set; else echo key-unset; fi'. Under a minute, a fraction of a cent. Today the reply reports key-set. The command never prints the value.

Where

At dev@debffabf6, internal/exec/bare/streaming.go:120, StreamingEnv, starts from os.Environ(); internal/exec/tools.go:1594 and :1938, JobShellEnv, preserve provider keys. internal/config/apikey.go:60, APIKeyAt, reads a profile key without setting an environment variable.

The fix

Give model-run child processes a scrubbed environment that removes provider credentials by default. Provide a deliberate opt-in pass-through for a task that genuinely needs one.

Acceptance

  • e2e: a bash call on each belt prints key-unset for a provider key inherited by codeaf unless an explicit pass-through was granted.
  • Unit: environment filtering covers exported and profile-only keys without logging secret values.
  • Document the opt-in and record the former inheritance in invalidates.
主要语言
Go
星标
115
派生
14
平均合并
9 小时 38 分钟
30 天内合并 PR
730

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Agent-Field/CodeAF 的其他 Issue

查看 Agent-Field/CodeAF 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。