feat(cloud-agent-next): contain managed SCM credentials#3665
Conversation
| const repository = parseGitLabCloneUrl(params.gitUrl, instanceOrigin); | ||
| if (!repository.success) return repository; | ||
| const identity = this.getGitLabSessionIdentity(integration); | ||
| if (!identity) return { success: false, reason: 'no_token' }; |
There was a problem hiding this comment.
WARNING: Misleading error code for missing identity
When getGitLabSessionIdentity returns null (both accountId and accountLogin are null on the integration row), the caller returns { success: false, reason: 'no_token' }. This conflates a missing-identity problem with a missing-token problem, which will produce a confusing error in logs and downstream handling. A more accurate reason would be something like 'no_integration_found' or a dedicated code to indicate the identity couldn't be established.
If this combination (accountId: null && accountLogin: null) genuinely cannot occur for a valid active integration in practice, a comment or runtime assertion would document that invariant.
| if (url.username || url.password) return 'invalid_upstream_url'; | ||
| const method = requestMethod.toUpperCase(); | ||
| if (url.hostname === 'api.github.com' && url.port === '') { | ||
| return ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'].includes(method) |
There was a problem hiding this comment.
WARNING: Installation-source capabilities allow unrestricted api.github.com access
validateGitHubCapabilityUpstream permits any GET/POST/PUT/PATCH/DELETE/HEAD to api.github.com without restricting to paths related to the bound owner/repo. For a user-source capability this is intentional (broad gh CLI compatibility). For an installation-source capability the issued token is scoped to a specific repository installation, but the redemption check does not enforce that api.github.com calls target that repository.
This means an attacker who obtains an installation-source capability for acme/repo can redeem it to call https://api.github.com/repos/acme/other-repo or enumerate all repositories for the installation. If installation tokens are intended to be repository-scoped at the API surface too, an additional path-prefix check against repos/${owner}/${repo} is needed for installation-source redemptions.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe core security design — encrypted short-lived capabilities bound to sandbox container ID, repository, and provider identity — is well-structured with comprehensive test coverage. Two issues warrant attention before merge. Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)
Files Reviewed (14 files)
Fix these issues in Kilo Cloud Reviewed by claude-4.6-sonnet-20260217 · 4,242,862 tokens Review guidance: REVIEW.md from base branch |
Summary
git-token-servicethrough sandbox outbound interception.Verification
Visual Changes
N/A
Reviewer Notes
git-token-service, then deploycloud-agent-next.kgh1.*/kgl1.*issuance and redemption support after the one-hour compatibility window./api/v4/**and/api/graphqlaccess forglab; Git smart HTTP and LFS control paths remain repository-bound.