Skip to content

bug(sdk/go): browser login callback binds 127.0.0.1 but redirect_uri uses localhost #4518

Open
ai-openshell/sdk-go
#97

Description

@CloneOfAlex

User Story

I use OpenShell and build automation against its SDKs. I found this while reviewing sdk/ on main; it is identified from the code paths cited below and has not yet been reproduced against a live gateway.

Problem Statement

startCallbackServer listens on 127.0.0.1:<port>, but loginBrowser sends redirect_uri=http://localhost:<port>/callback. The CLI uses 127.0.0.1 for both.

Impact / Why This Matters

On hosts or browsers where localhost resolves to ::1 first without IPv4 fallback, the IdP redirect fails to reach the callback and Login times out.

Acceptance Criteria

  • The redirect URI host matches the address the callback server listens on (or the server listens on both loopback families).

Reproduction Steps

Code reference: oidc/authcode.go net.Listen("tcp", "127.0.0.1:%d") vs oidc/oidc.go fmt.Sprintf("http://localhost:%d/callback", port). On a host where localhost maps only to ::1, run oidc.Login.

Suggested UX (if applicable)

No response

Environment

  • OpenShell: main @ 82977e2 (2026-10-13)
  • SDK: Go (sdk/go/openshell/v1/oidc)
  • Toolchain: Go 1.25.4 linux/amd64, Node 22

Logs

Activity

  1. added
    state:triage-needed
    on Oct 13, 2026
  2. rhuss commented on Oct 14, 2026

    @rhuss
    Contributor

    📋 triage-agent

    Thanks for the report.

    Confirmed by code inspection on main; not reproduced against a live identity provider. The browser flow's callback server listens on 127.0.0.1 (sdk/go/openshell/v1/oidc/authcode.go), but loginBrowser sends redirect_uri=http://localhost:<port>/callback (oidc.go). The CLI uses http://127.0.0.1:<port>/callback for both (crates/openshell-cli/src/oidc_auth.rs).

    In practice the mismatch only bites on hosts or browsers where localhost resolves to ::1 without falling back to IPv4, but the fix is a one-line change. Using the loopback IP literal for the redirect URI also follows RFC 8252 §8.3, which advises against localhost for native-app redirects. Switching shouldn't affect identity provider configuration: the CLI already requires 127.0.0.1 to be an allowed redirect, and the dev Keycloak realm allows both.

    The acceptance criterion is clear. Next step: maintainer acceptance decision.

  3. github-actions commented on Nov 12, 2026

    @github-actions

    This issue has had no activity for 28 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  4. added
    state:stale
    on Nov 12, 2026
  5. Shr3yash commented on Nov 27, 2026

    @Shr3yash
  6. removed
    state:stale
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-needed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions