fix(gitlab): pin pagination cursor to configured host + consolidate isSameOrigin#4873
Conversation
…g it The repository-tree keyset cursor stores GitLab's verbatim rel="next" URL and re-fetches it with an Authorization: Bearer header. Assert the cursor's origin matches the configured apiBase before following it, so a tampered or corrupted fileNextUrl cannot exfiltrate the access token to an attacker-controlled host. Fails closed on mismatch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nectors/tools Add an optional base argument to the shared isSameOrigin (defaulting to the app base URL) so callers can pin a URL to any trusted origin. The GitLab connector's cursor host-check and the tools self-origin check now consume the shared helper instead of their own URL-parsing.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Extends shared Reviewed by Cursor Bugbot for commit 6c7e41a. Configure here. |
Greptile SummaryThis PR closes an SSRF-adjacent token-leak vector: the GitLab connector was using the verbatim
Confidence Score: 5/5Safe to merge; the changes are a targeted security hardening of the GitLab connector's pagination path with no regressions introduced. All three files contain well-scoped, correct changes. The origin guard in No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant GitLabConnector
participant isSameOrigin
participant GitLabAPI
Caller->>GitLabConnector: listDocuments(cursor)
GitLabConnector->>GitLabConnector: decodeCursor(cursor) → state.fileNextUrl
alt state.fileNextUrl is set
GitLabConnector->>isSameOrigin: isSameOrigin(fileNextUrl, apiBase)
isSameOrigin-->>GitLabConnector: true / false
alt origin mismatch
GitLabConnector-->>Caller: throw Error("unexpected host")
end
end
GitLabConnector->>GitLabAPI: GET fileNextUrl ?? defaultUrl (+ Authorization header)
GitLabAPI-->>GitLabConnector: "200 OK + Link: rel="next""
GitLabConnector->>GitLabConnector: parseNextLink() → nextLink
GitLabConnector->>GitLabConnector: "encodeCursor({ fileNextUrl: nextLink })"
GitLabConnector-->>Caller: "{ documents, nextCursor, hasMore }"
Reviews (1): Last reviewed commit: "improvement(validation): generalize isSa..." | Re-trigger Greptile |
Summary
rel="next"URL and re-fetched it with anAuthorization: Bearerheader. A tampered or corruptedfileNextUrlcould have leaked the access token to an attacker-controlled host. The connector now asserts the cursor's origin matches the configuredapiBasebefore following it, failing closed on mismatch.isSameOriginutil (lib/core/utils/validation.ts) to accept an optionalbaseorigin (defaults to the app base URL, so existing callers are unchanged).Type of Change
Testing
Tested manually.
bun run lintand the API-validation contract check both pass.Checklist