{"thread":{"id":"66559","subject":"[BUG] http: push with token-only URL userinfo fails after libcurl strips creds from CURLINFO_EFFECTIVE_URL","startedAt":"2026-10-16T22:36:53Z","lastAt":"2026-10-21T11:23:54Z","messageCount":2,"participants":["Dan","Tuomas Ahola"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"555288","messageId":"CALGWHBdx0V95RoZJvyC7G4t4RpXpQm3ycv+huTQcPunOCm7hBw@mail.gmail.com","threadId":"66559","inReplyTo":null,"subject":"[BUG] http: push with token-only URL userinfo fails after libcurl strips creds from CURLINFO_EFFECTIVE_URL","fromName":"Dan","fromEmail":"timelord@gmail.com","sentAt":"2026-10-16T22:36:53Z","receivedAt":"2026-10-16T22:36:53Z","isPatch":false,"sender":{"key":"timelord@gmail.com","avatar":null},"body":"Hi,\n\n(Please note this was done with the assistance of Claude, I apologize\nif there are inaccuracies here, Ive tried to go over this and verify\nas much of it as I am capable of. I tried looking at the mailing list\narchives to see if this has already been reported and I didnt see\nanything that looked like it had yet. I can verify that the new\nlibcurl behavior absolutely seems to be causing issues from at least\nmy own limited vantage point. -Dan)\n\nSince libcurl stopped returning credentials in CURLINFO_EFFECTIVE_URL\n(curl 8.23.0, commit 7a6bd027d0de \"getinfo: make sure\nCURLINFO_EFFECTIVE_URL does not contain creds\", CVE-2026-94266; also\nbackported to Ubuntu 24.04 as curl 8.5.0-2ubuntu10.16, USN-8932-1),\npushing over smart HTTP fails when the remote URL carries a username\nbut no password, e.g.\n\n    https://<token>@forge.example/owner/repo.git\n\nwhich is a common way for CI tools to pass an access token (Renovate\ndoes this for Gitea/Forgejo). Fetch/clone keep working; push does not.\n\nVersions\n--------\n  git 2.55.0 (1:2.55.0-0ppa1~ubuntu24.04.2)\n  libcurl3t64-gnutls 8.5.0-2ubuntu10.16    -> fails\n  libcurl3t64-gnutls 8.5.0-2ubuntu10.15    -> works (same git build)\n  Server: Forgejo 16.0.6 (answers the first unauthenticated request\n          with 401 + \"WWW-Authenticate: Basic realm=...\")\n\nReproduce\n---------\n  git clone https://<token>@forge.example/owner/repo.git && cd repo\n  git commit --allow-empty -m test\n  GIT_TERMINAL_PROMPT=0 git push origin HEAD:refs/heads/test\n\nExpected: push succeeds (it did with the previous libcurl).\nActual:\n\n  Pushing to https://forge.example/owner/repo.git\n  warning: redirecting to https://forge.example/owner/repo.git/\n  POST git-receive-pack (815 bytes)\n  fatal: could not read Username for 'https://forge.example': No such\ndevice or address\n  send-pack: unexpected disconnect while reading sideband packet\n  fatal: the remote end hung up unexpectedly\n\nNo redirect happens on the server side; the server log shows\nGET info/refs 401 -> GET info/refs 200 -> POST git-receive-pack 401.\n\nGIT_TRACE_CURL (abridged, credentials redacted):\n\n  => Send header: GET /owner/repo.git/info/refs?service=git-receive-pack HTTP/2\n  <= Recv header: HTTP/2 401\n  <= Recv header: www-authenticate: Basic realm=\"Gitea\"\n  == Info: Issue another request to this URL:\n'https://<cred>@forge.example/owner/repo.git/info/refs?service=git-receive-pack'\n  == Info: Server auth using Basic with user '<redacted>'\n  => Send header: GET /owner/repo.git/info/refs?service=git-receive-pack HTTP/2\n  => Send header: Authorization: <redacted>\n  <= Recv header: HTTP/2 200\n  warning: redirecting to https://forge.example/owner/repo.git/\n  == Info: [HTTP/2] [5] OPENED stream for\nhttps://forge.example/owner/repo.git/git-receive-pack\n  => Send header: POST /owner/repo.git/git-receive-pack HTTP/2\n     (no Authorization header)\n  <= Recv header: HTTP/2 401\n\nAnalysis\n--------\nIn http.c, http_request_reauth() calls update_url_from_redirect() with\nthe URL git asked for and CURLINFO_EFFECTIVE_URL. The asked-for URL\nstill contains \"<token>@\", but libcurl now returns the effective URL\nwithout userinfo, so the strcmp() differs and git treats an ordinary\n200 as a redirect: it prints \"redirecting to ...\", rewrites base_url to\nthe credential-less URL and calls credential_from_url(&http_auth, ...)\non it, which credential_clear()s http_auth.\n\nWith a username-only URL, http_auth.password was never set, so\ninit_curl_http_auth() never put CURLOPT_USERNAME/PASSWORD on the handle;\nthe only auth curl had was the userinfo in the URL. Once the URL is\nrewritten, the POST goes out with no credentials, gets 401, and\ncredential_fill() has nothing to fill from (http_auth was cleared,\nno helper, no terminal), hence \"could not read Username\".\n\nWith \"user:password@\" in the URL the same false redirect happens, but\nthe push still succeeded in my test - presumably because\ninit_curl_http_auth() had already set CURLOPT_USERNAME/PASSWORD on the\nreused handle before http_auth was cleared.\n\nPossible fix\n------------\nCompare the URLs without userinfo in update_url_from_redirect() (strip\n\"user[:pass]@\" from the asked-for URL, or from both, before the\nstrcmp/skip_prefix), so a credential-free effective URL that is\notherwise identical is not treated as a redirect. For a real redirect\non the same origin, keeping the existing http_auth instead of\nre-parsing it from a credential-less URL would also avoid losing the\nusername. I haven't written or tested a patch.\n\nWorkaround for users: use \"user:token@\" instead of \"token@\" in the URL,\nor provide the token through a credential helper.\n\nThanks,\nDaniel Spisak\n\n"},{"id":"555722","messageId":"20261021112354.S3kbH%taahol@utu.fi","threadId":"66559","inReplyTo":"CALGWHBdx0V95RoZJvyC7G4t4RpXpQm3ycv+huTQcPunOCm7hBw@mail.gmail.com","subject":"Re: [BUG] http: push with token-only URL userinfo fails after libcurl strips creds from CURLINFO_EFFECTIVE_URL","fromName":"Tuomas Ahola","fromEmail":"taahol@utu.fi","sentAt":"2026-10-21T11:23:54Z","receivedAt":"2026-10-21T11:23:54Z","isPatch":false,"sender":{"key":"taahol@utu.fi","avatar":"https://avatars.githubusercontent.com/u/114303477?v=4"},"body":"Dan <timelord@gmail.com> wrote:\n\n> Hi,\n> \n> (Please note this was done with the assistance of Claude, I apologize\n> if there are inaccuracies here, Ive tried to go over this and verify\n> as much of it as I am capable of. I tried looking at the mailing list\n> archives to see if this has already been reported and I didnt see\n> anything that looked like it had yet. I can verify that the new\n> libcurl behavior absolutely seems to be causing issues from at least\n> my own limited vantage point. -Dan)\n> \n> Since libcurl stopped returning credentials in CURLINFO_EFFECTIVE_URL\n> (curl 8.23.0, commit 7a6bd027d0de \"getinfo: make sure\n> CURLINFO_EFFECTIVE_URL does not contain creds\", CVE-2026-94266; also\n> backported to Ubuntu 24.04 as curl 8.5.0-2ubuntu10.16, USN-8932-1),\n> pushing over smart HTTP fails when the remote URL carries a username\n> but no password, e.g.\n> \n>     https://<token>@forge.example/owner/repo.git\n> \n> which is a common way for CI tools to pass an access token (Renovate\n> does this for Gitea/Forgejo). Fetch/clone keep working; push does not.\n> \n\nThanks.  Please check if 76524c2604 (http: handle curl stripping creds from\neffective url, 2026-09-28) works for you.  The patch is already merged to\n'master', and is described in the release notes as:\n\n * The HTTP transport has been updated to handle changes in recent curl\n   versions that strip credentials from the effective URL, preventing\n   unnecessary credential prompts during redirects.\n\n\n"}]}