Repository navigation
feat(mint)!: harden repos scope against cross-repo minting #5826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ifireball
merged 14 commits into
fullsend-ai:main
from
ifireball:harden-mint-repos-scope
Aug 3, 2026
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a95cef4
feat(mint): harden repos scope against cross-repo minting
ifireball 35b0226
fix(mint): resolve deploy commit from local source checkout
ifireball 17daebd
feat(mint): report per_org_foreign_compat in status
ifireball d7d444c
docs(adr): record mint repos scope hardening (ADR 0077)
ifireball 833d11f
fix(mint): address review findings for repos-scope PR
ifireball 366cfd3
merge: sync harden-mint-repos-scope with upstream/main
ifireball bdd3db7
test(mint): raise patch coverage for deploy commit helpers
ifireball 5a3fc08
merge: sync harden-mint-repos-scope with upstream/main
ifireball c8140fe
fix(mint): share EnvTruthy for per-org compat status label
ifireball da38882
merge: sync harden-mint-repos-scope with upstream/main
ifireball 5dedbb4
fix(mint): address rh-hemartin review on repos-scope naming
ifireball a29042c
Signed-off-by: Barak Korren <bkorren@redhat.com>
ifireball d21b4d9
fix(mint): log PER_ORG_FOREIGN_COMPAT repos scope shape
ifireball fb8dd18
Signed-off-by: Barak Korren <bkorren@redhat.com>
ifireball File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| title: "77. Mint repos scope hardening with PER_ORG_FOREIGN_COMPAT" | ||
| status: Accepted | ||
| relates_to: | ||
| - agent-infrastructure | ||
| - security-threat-model | ||
| topics: | ||
| - mint | ||
| - identity | ||
| - oidc | ||
| - least-privilege | ||
| - cross-org | ||
| --- | ||
|
|
||
| # 77. Mint repos scope hardening with PER_ORG_FOREIGN_COMPAT | ||
|
|
||
| Date: 2026-08-02 | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| ## Context | ||
|
|
||
| [ADR 0060](0060-cross-org-mint-authorization-via-org-variables.md) authorized cross-org minting via FOREIGN org variables and treated empty `repos` as installation-wide on both same-org and foreign paths. Same-org callers could also request arbitrary repo lists. That blast radius conflicts with least privilege in the [security threat model](../problems/security-threat-model.md): a compromised enrolled workflow could mint tokens for repos other than the one that authenticated. | ||
|
|
||
| Org-mode dispatch still needs limited exceptions — `.fullsend` callers minting across enrolled repos, and enrolled callers minting `{self,.fullsend}` — without restoring unrestricted same-org scope. | ||
|
|
||
| ## Options | ||
|
|
||
| 1. **Keep ADR 0060 defaults.** No code change; rely on WIF enrollment alone. Rejected: enrollment does not bound `repos` to the authenticating repository. | ||
| 2. **Strict requesting-repo only, no exceptions.** Simplest rule. Rejected: breaks established `.fullsend` / org-mode dispatch shapes. | ||
| 3. **Default-deny with an explicit compat flag.** Deny installation-wide and broad same-org lists by default; gate the known org-mode shapes behind `PER_ORG_FOREIGN_COMPAT`. | ||
|
|
||
| ## Decision | ||
|
|
||
| After OIDC verification, the mint enforces `repos` scope as follows: | ||
|
|
||
| 1. **Normalize** a sole `["*"]` entry to empty (alias for empty `repos` only). Mixed `*` lists remain invalid pattern input. | ||
| 2. **Foreign (cross-org)** requests require empty `repos`. Non-empty lists are denied. FOREIGN gating from ADR 0060 still applies. | ||
| 3. **Same-org** requests must list exactly the requesting repository's bare name. Empty `repos` (installation-wide) is always denied on the same-org path. | ||
| 4. **`PER_ORG_FOREIGN_COMPAT`** (env / worker config; truthy = `1`/`true`/`yes`) unlocks only these same-org exceptions: | ||
| - Caller repository `.fullsend`: any non-empty validated repo list | ||
| - Other enrolled callers: exactly `[.fullsend]` or `{requestingBare, .fullsend}` | ||
| 5. The effective flag is visible on `GET /v1/status` as `per_org_foreign_compat` and in `fullsend mint status` (from traffic env; absent = off). | ||
|
|
||
| This revises the installation-wide and unrestricted same-org `repos` consequences of ADR 0060; FOREIGN allowlists and `target_org` remain as decided there. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Same-org workflows that omitted `repos` or listed unrelated repos break until they request only the calling repo, or operators enable `PER_ORG_FOREIGN_COMPAT` for the documented org-mode shapes. | ||
| - Foreign mints cannot carry a non-empty `repos` list; installation-wide foreign tokens remain possible only with empty `repos` plus FOREIGN authorization. | ||
| - Hosted and standalone mints must set `PER_ORG_FOREIGN_COMPAT` explicitly where org-mode dispatch is required; the default is off. | ||
| - ADR 0060's earlier allowance of same-org installation-wide tokens is superseded for `repos` policy by this decision (FOREIGN mechanism unchanged). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package cli | ||
|
ifireball marked this conversation as resolved.
Resolved
|
||
|
|
||
| import ( | ||
| "bytes" | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| ) | ||
|
|
||
| // resolveMintDeployCommit returns the commit to stamp into a mint deploy. | ||
| // When commit is already set to something other than "dev"/empty, it is | ||
| // returned unchanged. When deploying from on-disk source (sourceDir exists) | ||
| // and commit is unset, it tries git -C sourceDir rev-parse HEAD. Embedded | ||
| // deploys (missing sourceDir) never invoke git. | ||
| func resolveMintDeployCommit(commit, sourceDir string) string { | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| if commit != "" && commit != "dev" { | ||
| return commit | ||
| } | ||
| if sourceDir == "" { | ||
| return commit | ||
| } | ||
| info, err := os.Stat(sourceDir) | ||
| if err != nil || !info.IsDir() { | ||
| return commit | ||
| } | ||
| sha, err := gitRevParse(sourceDir, "HEAD") | ||
| if err != nil || sha == "" { | ||
| return commit | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| return sha | ||
| } | ||
|
|
||
| func gitRevParse(dir string, args ...string) (string, error) { | ||
| cmdArgs := append([]string{"-C", dir, "rev-parse"}, args...) | ||
| cmd := exec.Command("git", cmdArgs...) | ||
| var stdout, stderr bytes.Buffer | ||
| cmd.Stdout = &stdout | ||
| cmd.Stderr = &stderr | ||
| if err := cmd.Run(); err != nil { | ||
| return "", err | ||
| } | ||
| return strings.TrimSpace(stdout.String()), nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "regexp" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestResolveMintDeployCommit_PreservesNonDev(t *testing.T) { | ||
| t.Parallel() | ||
| got := resolveMintDeployCommit("abc123def", "/nonexistent") | ||
| if got != "abc123def" { | ||
| t.Fatalf("got %q, want preserved commit", got) | ||
| } | ||
| } | ||
|
|
||
| func TestResolveMintDeployCommit_MissingSourceDir(t *testing.T) { | ||
| t.Parallel() | ||
| dir := filepath.Join(t.TempDir(), "no-such-dir") | ||
| got := resolveMintDeployCommit("dev", dir) | ||
| if got != "dev" { | ||
| t.Fatalf("got %q, want dev when source missing", got) | ||
| } | ||
| got = resolveMintDeployCommit("", "") | ||
| if got != "" { | ||
| t.Fatalf("got %q, want empty when sourceDir empty", got) | ||
| } | ||
| } | ||
|
|
||
| func TestResolveMintDeployCommit_NotAGitRepo(t *testing.T) { | ||
| t.Parallel() | ||
| dir := t.TempDir() | ||
| got := resolveMintDeployCommit("dev", dir) | ||
| if got != "dev" { | ||
| t.Fatalf("got %q, want dev when not a git work tree", got) | ||
| } | ||
| } | ||
|
|
||
| func TestResolveMintDeployCommit_FromCheckout(t *testing.T) { | ||
| t.Parallel() | ||
| dir := t.TempDir() | ||
| runGit := func(args ...string) { | ||
| t.Helper() | ||
| cmd := exec.Command("git", append([]string{"-C", dir}, args...)...) | ||
| cmd.Env = append(os.Environ(), | ||
| "GIT_CONFIG_COUNT=1", | ||
| "GIT_CONFIG_KEY_0=commit.gpgsign", | ||
| "GIT_CONFIG_VALUE_0=false", | ||
| ) | ||
| out, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| t.Fatalf("git %v: %v\n%s", args, err, out) | ||
| } | ||
| } | ||
| runGit("init") | ||
| runGit("config", "user.email", "test@example.com") | ||
| runGit("config", "user.name", "Test") | ||
| if err := os.WriteFile(filepath.Join(dir, "README"), []byte("x\n"), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| runGit("add", "README") | ||
| runGit("commit", "-m", "init") | ||
|
|
||
| wantCmd := exec.Command("git", "-C", dir, "rev-parse", "HEAD") | ||
| wantOut, err := wantCmd.Output() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| want := strings.TrimSpace(string(wantOut)) | ||
|
|
||
| got := resolveMintDeployCommit("dev", dir) | ||
| if got != want { | ||
| t.Fatalf("got %q, want %q", got, want) | ||
| } | ||
| if !regexp.MustCompile(`^[0-9a-f]{40}$`).MatchString(got) { | ||
| t.Fatalf("expected full SHA, got %q", got) | ||
| } | ||
|
|
||
| // Empty commit also resolves. | ||
| got = resolveMintDeployCommit("", dir) | ||
| if got != want { | ||
| t.Fatalf("empty commit: got %q, want %q", got, want) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.