Skip to content

fix(repo-page): stop exposing the private-repository token in URLs - #600

Open
carfeii wants to merge 1 commit into
AsyncFuncAI:mainfrom
carfeii:fix/scrub-repo-token-from-url
Open

carfeii wants to merge 1 commit into
AsyncFuncAI:mainfrom
carfeii:fix/scrub-repo-token-from-url

Conversation

@carfeii

@carfeii carfeii commented Oct 5, 2026

Copy link
Copy Markdown

The repo entry form appended the private-repository access token to the navigation URL's query string, and the Code Viewer forwarded it again to /codemap/file's query string, even though that endpoint never reads a token parameter at all. Either exposes the credential via browser history, shared/copied links, and same-origin script access to the URL, and the second also puts it in proxy/access logs for no functional benefit.

Captures the token once on first render (via useRef, so it survives what follows) and then scrubs it from the visible URL on mount with history.replaceState. Drops the token entirely from CodeViewer's props and its /codemap/file request, since the backend route never consumes it there.

Test plan

  • npx tsc --noEmit: passes.
  • npx next build: full production build passes.

The repo entry form appended the private-repository access token to
the navigation URL's query string, and the Code Viewer forwarded it
again to /codemap/file's query string, even though that endpoint never
reads a token parameter at all. Either exposes the credential via
browser history, shared/copied links, and same-origin script access
to the URL, and the second also puts it in proxy/access logs for no
functional benefit.

Capture the token once on first render (via useRef, so it survives
what follows) and then scrub it from the visible URL on mount with
history.replaceState. Drop the token entirely from CodeViewer's props
and its /codemap/file request, since the backend route never consumes
it there.

Validated with tsc --noEmit and a full next build.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant