Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,484 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
730

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Agent-Field/CodeAF のほかの issue

Agent-Field/CodeAF の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。