Skip to content

bug: fetchJson allows unbounded redirects due to post-increment operator #24893

@KevinZhao

Description

@KevinZhao

fetchJson in packages/cli/src/config/extensions/github_fetch.ts uses post-increment (redirectCount++) when passing the redirect count to the recursive call. Post-increment evaluates to the current value before incrementing, so every recursive call receives the original value (0). This means the redirect limit check (redirectCount >= 10) on line 28 never triggers, allowing unbounded redirects.

The sibling function downloadFile in github.ts:546 correctly uses redirectCount + 1.

Steps to reproduce

  1. Set up a server that returns infinite 301/302 redirects
  2. Call fetchJson with that URL
  3. Observe that the function follows redirects indefinitely instead of stopping at 10

Expected behavior

fetchJson should stop following redirects after 10 hops, consistent with downloadFile.

Actual behavior

fetchJson follows redirects indefinitely because the counter is never incremented in the recursive call.

Metadata

Metadata

Assignees

Labels

area/extensionsIssues related to Gemini CLI extensions capabilityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!priority/p3Backlog - a good idea but not currently a priority.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions