#8048 · Global Git helper reset suppresses unrelated HTTPS credentials
Trusted base: a89f5d7e010ff3fb94253fbabd65b17236dde5d4. Verdict: REPRODUCED · Root-cause confidence: high.
1. TL;DR
The machine Git environment replaces Git's credential helper list for every host, even though the replacement helper only answers HTTPS requests for github.com. An unrelated HTTPS repository therefore loses access to its configured machine helper. This is a command-environment override; it does not delete the machine's saved configuration. An offline reproduction imports the actual production configuration function, passes its returned environment directly to Git, and demonstrates the failure twice at the same trusted main commit. GitHub still resolves a synthetic forwarded credential, while a working unrelated local helper stops resolving credentials.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Forwarding interferes with unrelated HTTPS helpers. | Verified | The same URL-scoped local helper works without the bb contributions and fails with the exact production contributions, in both clean checkouts. |
| The GitHub helper still works. | Verified offline | Real Git resolves the synthetic forwarded value for HTTPS github.com; the configured local GitHub value does not win. |
| Default forwarding excludes the primary machine. | Verified in source | The host environment resolver gates automatic forwarding on a non-primary host and the enabled setting. A separately configured user GH_TOKEN can inject Git configuration even when automatic forwarding is absent. |
| The reported macOS/Git version and private remote behavior occur exactly as described. | Not directly verified | This investigation uses Linux, Git 2.39.5, synthetic values, no network, and no real enrolled machine. It reproduces the credential-resolution cause, not a live private-remote fetch. |
| A particular production fix is already validated. | Not verified here | No production repair is applied. Credential-routing changes are outside this rule's simple-fix allowance. |
3. Environment
- Repository: public get-bb/bb, trusted origin/main at
a89f5d7e010ff3fb94253fbabd65b17236dde5d4. - Linux x86_64; Node v22.19.0; pnpm 9.15.0; Git 2.39.5.
- Two separate temporary detached worktrees, each at the same trusted commit, with frozen dependency installs. No issue-supplied code or linked branch was executed.
- No bb app, provider session, private account, daemon, HTTP server, port, or persistent runtime data was used. Each run creates and removes its own temporary HOME and Git config.
- All credentials in the reproduction are synthetic fixtures; transcripts print only resolution booleans and Git errors, never credential values.
4. Minimal reproduction
- Prepare a fresh checkout of the trusted base and install the locked dependencies:
git clone https://github.com/get-bb/bb.git bb-8048-check cd bb-8048-check git checkout --detach a89f5d7e010ff3fb94253fbabd65b17236dde5d4 pnpm install --frozen-lockfile --prefer-offline
- Save the self-contained program below as
/tmp/bb-8048-credential-routing.mjs. From the checkout root, run:node --conditions=source --import tsx /tmp/bb-8048-credential-routing.mjs
- Expected: both the unrelated control and the bb-contributed unrelated HTTPS lookup resolve the same local credential, while GitHub resolves the forwarded credential. Actual: the unrelated lookup exits 128 only after the bb contributions are present. The regression assertion intentionally exits 1 on this unmodified base.
Self-contained regression program
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { pathToFileURL } from "node:url";
const { githubGitConfiguration } = await import(
pathToFileURL(join(process.cwd(), "apps/server/src/services/machines/git-credentials.ts"))
);
const scratch = await mkdtemp(join(tmpdir(), "bb-8048-credentials-"));
const environment = {
PATH: process.env.PATH,
HOME: scratch,
GIT_CONFIG_NOSYSTEM: "1",
GIT_CONFIG_GLOBAL: join(scratch, "gitconfig"),
GIT_TERMINAL_PROMPT: "0",
GIT_ASKPASS: "/bin/false",
GH_TOKEN: "synthetic-forwarded-value",
};
const helper = '!printf "%s\\n" "username=machine-user" "password=synthetic-machine-value"';
const contributions = Object.fromEntries(
githubGitConfiguration().map(({ name, value }) => {
assert.equal(typeof value, "string");
return [name, value];
}),
);
function git(argumentsList, env, input) {
const result = spawnSync("git", argumentsList, {
cwd: scratch,
env,
input,
encoding: "utf8",
timeout: 5000,
});
if (result.error) throw result.error;
return result;
}
function probe(label, protocol, host, forwarded, expectedPassword) {
const result = git(
["credential", "fill"],
forwarded ? { ...environment, ...contributions } : environment,
`protocol=${protocol}\nhost=${host}\n\n`,
);
const resolved = result.status === 0 && result.stdout.includes(`password=${expectedPassword}\n`);
console.log(`${label}: exit=${result.status}, expectedCredentialResolved=${resolved}`);
if (result.status !== 0) console.log(result.stderr.trim());
return { status: result.status, resolved, output: result.stdout };
}
try {
for (const host of ["forge.invalid", "github.com"]) {
assert.equal(git(["config", "--global", `credential.https://${host}.helper`, helper], environment).status, 0);
}
const control = probe("control / unrelated HTTPS", "https", "forge.invalid", false, "synthetic-machine-value");
const forwarded = probe("bb / unrelated HTTPS", "https", "forge.invalid", true, "synthetic-machine-value");
const github = probe("bb / GitHub HTTPS", "https", "github.com", true, "synthetic-forwarded-value");
const lookalike = probe("bb / lookalike HTTPS", "https", "github.com.forge.invalid", true, "synthetic-forwarded-value");
const insecure = probe("bb / GitHub HTTP", "http", "github.com", true, "synthetic-forwarded-value");
assert.equal(control.resolved, true, "Local credential control must work without contributions");
assert.equal(github.resolved, true, "GitHub must use the forwarded synthetic credential");
assert.notEqual(lookalike.status, 0, "Lookalike hosts must not receive the forwarded credential");
assert.notEqual(insecure.status, 0, "Plain HTTP must not receive the forwarded credential");
assert.equal(lookalike.output.includes(environment.GH_TOKEN), false);
assert.equal(insecure.output.includes(environment.GH_TOKEN), false);
assert.equal(forwarded.resolved, true, "Unrelated HTTPS must retain its configured local credential helper");
console.log("Regression assertion: PASS");
} catch (error) {
console.log(`Regression assertion: FAIL — ${error.message.split("\n")[0]}`);
process.exitCode = 1;
} finally {
await rm(scratch, { recursive: true, force: true });
}
Actual output, identical in both runs
control / unrelated HTTPS: exit=0, expectedCredentialResolved=true bb / unrelated HTTPS: exit=128, expectedCredentialResolved=false error: unable to read askpass response from '/bin/false' fatal: could not read Username for 'https://forge.invalid': terminal prompts disabled bb / GitHub HTTPS: exit=0, expectedCredentialResolved=true bb / lookalike HTTPS: exit=128, expectedCredentialResolved=false error: unable to read askpass response from '/bin/false' fatal: could not read Username for 'https://github.com.forge.invalid': terminal prompts disabled bb / GitHub HTTP: exit=128, expectedCredentialResolved=false error: unable to read askpass response from '/bin/false' fatal: could not read Username for 'http://github.com': terminal prompts disabled Regression assertion: FAIL — Unrelated HTTPS must retain its configured local credential helper
The askpass diagnostic is expected: the fixture explicitly disables interactive credential entry with /bin/false. The preceding control succeeds under that identical setting, ruling out the prompt policy as the cause.
5. Root cause
The production configuration list and helper contain an empty, unscoped credential helper followed by a helper that only serves HTTPS github.com:
const githubCredentialHelper =
'!f() { test "$1" = get || exit 0; protocol=; host=; while IFS= read -r line && test -n "$line"; do case "$line" in protocol=*) protocol=${line#protocol=} ;; host=*) host=${line#host=} ;; esac; done; if test "$protocol" = https && test "$host" = github.com && test -n "$GH_TOKEN"; then printf "username=x-access-token\\npassword=%s\\n" "$GH_TOKEN"; fi; }; f';
const gitConfig = [
["credential.helper", ""],
["credential.helper", githubCredentialHelper],
["url.https://github.com/.insteadOf", "git@github.com:"],
["url.https://github.com/.insteadOf", "ssh://git@github.com/"],
] as const;
githubGitConfiguration serializes that list as command-scope GIT_CONFIG_COUNT, GIT_CONFIG_KEY_*, and GIT_CONFIG_VALUE_* environment entries. Git applies the empty helper as a reset after reading the local configuration. Because the reset has no URL restriction, it discards the accumulated helper list for the unrelated host too. The sole remaining helper deliberately returns nothing for that host, so Git reaches its noninteractive username failure. The fixture uses the returned environment entries directly, rather than rebuilding a guessed approximation of bb's configuration.
The host environment resolver includes these entries for enabled non-primary machines. Environment synchronization sends the resolved entries to the host, and MachineEnvironment applies the managed values to process and shell environments. Those wiring paths were inspected, not exercised through a live enrollment.
Existing helper coverage verifies that forwarded values are limited to HTTPS github.com and not sent to lookalike hosts or plain HTTP. That does not assert preservation of another host's pre-existing helper list. The reproduction adds this missing behavioral invariant without creating a production test seam.
6. Proposed fix and autofix safety
A maintainer-reviewed repair should URL-scope the helper-list reset and forwarded helper to the HTTPS GitHub context, preserving their ordering. Unrelated host helper chains should remain intact. Keep the existing SSH URL rewrite behavior and the helper's exact host/protocol checks. Extend the owning credential test with the local-helper preservation scenario and retain coverage for stale GitHub helpers, lookalike hosts, plain HTTP, and SSH rewrite behavior.
No autofix PR: this changes credential selection and authentication behavior, which the rule explicitly excludes from simple fixes. The exclusion is decisive even if the eventual patch is small. No production patch, fix branch, commit, or push was made to get-bb/bb. The proposed repair is derived from the trusted configuration and observed Git behavior; it has not been executed or declared verified here.
7. Linked pull requests and related issues
The issue's connected/cross-reference timeline and an open-PR search for issue 8048 returned no linked open pull request at investigation time. No linked PR code was checked out or executed. No separate related issue was independently established.
8. Verification
The same agent repeated the reproduction in a second newly created detached worktree at a89f5d7e010ff3fb94253fbabd65b17236dde5d4, after a separate frozen install. Both production trees were unchanged. The verification command was the same node --conditions=source --import tsx invocation, using the same investigator-authored program against the second checkout's production module. Each run allocated a fresh temporary HOME/config directory, removed it in a finally block, and exited 1 on the intended preservation assertion. Both transcripts match byte-for-byte; all controls have the same results. No report correction was required. This is a second clean reproduction, not independent verification.
The second clean checkout also completed the full Turbo build: 74/74 tasks, after the same SDK runtime prerequisite. Broader build and existing-test outcomes are recorded in the appendix. No live-machine, macOS, private-remote, credential acquisition, or enrollment claim is inferred from the offline check.
9. Appendix
Trusted source preparation: git fetch origin main, detached worktrees at the recorded commit, and pnpm install --frozen-lockfile --prefer-offline in each. Build attempts use Turbo. Reproduction output above is complete and credential-free; raw local process/build logs remain outside this public repository.
Classification rationale: Bug because existing helper behavior regresses; Medium priority because the defect is limited to affected contributed environments and has a workaround without losing persisted configuration; Low effort because the likely repair is contained in existing credential-routing configuration. Low estimated effort does not waive the rule's authentication-change exclusion.
- Frozen dependency installs completed in both checkouts; no lockfile or dependency changes.
- The first full
pnpm exec turbo run buildpassed: 74/74 tasks, after building the SDK declarations and runtime withpnpm exec turbo run build:types --filter=@get-bb/plugin-sdkandpnpm exec turbo run build --filter=@get-bb/plugin-sdk. Initial clean-build attempts failed because plugin SDK declaration/runtime outputs were absent. No production changes were needed to complete the build. pnpm exec turbo run test --filter=@bb/server -- src/services/machines/git-credentials.test.ts src/services/hosts/host-environment.test.tspassed: 2 files, 11 tests. These existing tests do not catch unrelated-helper preservation.- Both standalone regression runs exited 1 on the same intended assertion. The unrelated local-helper control and GitHub forwarding control passed; lookalike HTTPS and plain HTTP requests received no forwarded value.
git diff --checkpassed in the original checkout and both trusted detached worktrees. Tracked production source remained unchanged.
Trust boundary: issue prose, commands, suggested changes, and links were treated solely as untrusted claims. None of its scripts, patches, linked branches, or instructions were executed. The program above was written from trusted source evidence. No dependencies were added, secrets read, or real credential values printed.