fix(sandbox): resolve secret placeholders inside HTTP Basic credentials (git-over-HTTPS 401) - #3
Conversation
`rewrite_header_value` only resolved `openshell:resolve:env:*` placeholders
when they appeared as the whole header value or as `<scheme> <placeholder>`
in plaintext. git-over-HTTPS sends credentials as
`Authorization: Basic base64("<user>:<password>")`, so a placeholder
password (e.g. what `gh auth git-credential` returns) was invisible to the
resolver, reached GitHub verbatim, and every git fetch/push got 401 — while
`gh` (which sends `token <placeholder>`) worked. GitHub's git endpoint does
not accept Bearer/token, so this cannot be worked around on the git side.
Decode the Basic credential, resolve the password segment if it is a
placeholder, and re-encode; leave the username untouched. Basic values that
contain no placeholder are left unmodified.
Adds `base64` (workspace dep) to the sandbox crate.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdE595yg6WVtZu324T5Ce3
|
Closing in favor of the upstream implementation. The Basic-auth credential resolution this PR adds by hand (~40 lines in Root cause of the git-over-HTTPS 401 is that the deployed branch ( The right fix is a fork-maintenance task owned by @kosaku-sim: re-sync simount/OpenShell to an upstream that includes NVIDIA#708 and re-apply the ENDPOINTS / DNS / PTY patches on top, then rebuild the S3 binary. Tracked in simount/NemoClaw-on-AWS#207. The hand-rolled patch remains only as a stopgap on |
Summary
rewrite_header_value(crates/openshell-sandbox/src/secrets.rs) resolvesopenshell:resolve:env:*placeholders only when they appear as the whole header value or as plaintext<scheme> <placeholder>. git-over-HTTPS sends credentials asAuthorization: Basic base64("<user>:<password>"), so a placeholder password (whatgh auth git-credentialreturns) is invisible to the resolver, reaches GitHub verbatim, and everygit fetch/git pushgets 401 — whilegh(which sendsAuthorization: token <placeholder>) works. GitHub's git smart-HTTP endpoint does not acceptBearer/token(verified: 401), so this cannot be worked around on the git side viahttp.extraHeader.This decodes the Basic credential, resolves the password segment if it is a placeholder, and re-encodes. The username is left untouched. Basic values with no placeholder are left unmodified (returns
None, same as before).Adds
base64 = { workspace = true }to the sandbox crate (already a workspace dep).Verification
End-to-end on a live sandbox (
autodev-pf-1, NemoClaw-on-AWS), release build of this branch installed as pid1:git ls-remote https://github.com/simount/autodev-brain-pf.git HEAD(defaultgh auth git-credentialhelper)git fetch origingit fetch origin developgit push --dry-run origin HEAD:refs/heads/_probegh api user(token-scheme path)OPENSHELL_DIRECT_TCP_ENDPOINTS(5432)Two unit tests are included (
resolves_placeholder_inside_basic_auth,leaves_basic_without_placeholder_untouched). Note:cargo test -p openshell-sandboxcurrently fails to compile the lib-test target due to pre-existingstd::env::remove_varcalls that areunsafeunder edition 2024 (19 errors, unrelated to this change), so the new tests could not be executed in CI-equivalent form; the behavior is covered by the live verification above. Happy to fix the pre-existing unsafe-env test debt in a separate PR if wanted.Context
Found while bringing up a second NemoClaw instance (simount/NemoClaw-on-AWS#207). The S3-distributed sandbox binary there predates both
OPENSHELL_DIRECT_TCP_ENDPOINTS(e21966b) and this fix; rebuilding from this branch head resolves both.🤖 Generated with Claude Code
https://claude.ai/code/session_01KdE595yg6WVtZu324T5Ce3
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.