# mcp-server-git git_remote leaks your Git token: check insteadOf, upgrade to 2026.11.27, and use scoped short-lived tokens

> Advisory GHSA-wvv2-676g-r57j, published on 27 November 2026, says that the git_remote tool of mcp-server-git 2026.11.4 up to before 2026.11.27 can return the Git token from a global or system insteadOf rewrite, when a repository has a remote name with a tab in it. We reproduced the leak with a fake token on three affected versions and saw it blocked in 2026.11.27. This guide covers checking your Git configuration, upgrading, rotating, and scoped tokens.

- URL: https://ngnext.tech/knowledge/mcp-server-git-git-remote-token-leak-ghsa-wvv2-676g-r57j
- Published: 2026-11-28
- Updated: 2026-11-28
- Author: Nishant Gauraw, [NG-NeXT](https://ngnext.tech)
- Tags: mcp, ai-agents, git, credential-leak, security-advisory

The `git_remote` tool in `mcp-server-git` could return your Git access token to the AI model. According to advisory GHSA-wvv2-676g-r57j, published on 27 November 2026, this happens when the server runs in an affected version, your global or system Git configuration holds a token inside a `url.<base>.insteadOf` rewrite, and the agent inspects a repository whose remote name contains a tab character. Upgrade to `mcp-server-git` 2026.11.27 or later, check your Git configuration for tokens in rewrites, and rotate the token if an affected version ran on a machine where an agent looked at code you do not control.

## What the advisory says

As of 28 November 2026, [GHSA-wvv2-676g-r57j](https://github.com/modelcontextprotocol/servers/security/advisories/GHSA-wvv2-676g-r57j) in the `modelcontextprotocol/servers` repository reads as follows.

- **Affected:** the pip package `mcp-server-git`, from 2026.11.4 up to, but not including, 2026.11.27. **Patched:** 2026.11.27.
- **Severity:** Moderate, CVSS 3.1 score 5.3, CWE-200. The advisory lists no CVE ID as of 28 November 2026. The reporter is credited as 3urek4.
- **Documented promise:** the README and the tool description say that "A credential embedded in a URL is never returned".
- **Who is affected:** the advisory names developers, CI runners and agent hosts that run the server over stdio or Streamable HTTP, with or without `--repository` confinement, so limiting the server to one repository does not stop this leak.
- **Conditions:** a credential-bearing `url.<base>.insteadOf` rewrite in the global or system Git configuration, and a repository whose remote name contains a tab. The advisory's example is an untrusted repository archive. It also mentions a repository whose own `.git/config` holds a credential in a URL value with leading whitespace.
- **Cause:** the tool parses `git remote -v` and splits each line on the first tab. Git reads and lists a remote whose name in `.git/config` contains a tab, even though `git remote add` would refuse such a name, so a name such as `c<tab>d` moves the name's second half into the URL column. The redaction step only treats a field as a URL if it begins with a scheme such as `https://`, so the shifted field was returned unchanged.
- **Impact:** the host user's live token appears in the tool output. The advisory says that it is then exposed to the model's context, the MCP session logs and the inference provider's transcripts. The advisory notes that `git_remote` is marked read-only, so MCP clients generally call it without an approval prompt, and it says that the leak enables credential exfiltration when combined with indirect prompt injection in repository files.

The fix is part of the Model Context Protocol servers [v2.6.0 release](https://github.com/modelcontextprotocol/servers/releases), published on 27 November 2026. Its notes say that `git_remote` now matches remote names against Git's own list and withholds any value that holds a URL anywhere other than at its start. The same release lists six other `mcp-server-git` fixes, including Git LFS configuration, the repository root, and ignored-file overwrites on merge, so the upgrade is worth doing for more than this one issue.

## What we reproduced

We ran the real server over the MCP stdio transport with a made-up token, never a real one. The setup followed the advisory: a temporary home directory whose `.gitconfig` holds a `url.<base>.insteadOf` rewrite with the made-up token, and a throwaway repository with one remote whose name contains a tab. We then called `git_remote`.

| `mcp-server-git` version | Made-up token in the tool output? |
|---|---|
| 2026.11.4 | Yes |
| 2026.11.11 | Yes |
| 2026.11.18 | Yes |
| 2026.11.27 | No. The URL came back as `https://<redacted>@srv.example.com/...` |

The environment was Linux with Python 3.12.3, Git 2.43.0, `mcp` 2.3.0 and GitPython 3.2.1, on 28 November 2026. A plain `git remote -v` run on the same repository also printed the rewritten URL with the made-up token, because Git itself shows the rewritten address. That is expected, and it is exactly what the tool is supposed to redact. We also ran the 2026.11.18 server with `GIT_CONFIG_GLOBAL=/dev/null` set, and it returned no token. We used the Python SDK's stdio client, not a production MCP application.

## Step 1: Find out whether you run it, and which version

Look at the command in your MCP client's configuration that starts `mcp-server-git`. If it pins a version, change the pin. If it does not, check which version your launcher actually resolves. For a pip installation:

```
python -m pip show mcp-server-git
```

The `Version` line should read 2026.11.27 or later.

## Step 2: Upgrade

```
python -m pip install --upgrade "mcp-server-git>=2026.11.27"
```

Then restart your MCP client, so that it starts a new server process, and run the version check again. If your client starts the server with `uvx`, uv can reuse a cached environment, so pin the version in the command (`uvx mcp-server-git@2026.11.27`, which uv's documentation describes) and restart the client. If you launch the server through another tool or a container image, use that tool's way of pinning 2026.11.27 or later.

## Step 3: Check your Git configuration for tokens in rewrites

This is the condition the advisory describes. The command below lists which configuration files contain an `insteadOf` or `pushInsteadOf` rewrite with something in the user-info position of a URL (the part before the `@`), and how many. That can be a token, a password or just a user name such as `git`, so open the file and look before you treat a hit as a secret. It is built to print file names and counts only, not the values. Look at the output before you paste it anywhere, because an unusual multi-line value could still print a line as it is.

```
git config --show-origin --get-regexp '^url\..*\.(push)?insteadof$' | grep -E '://[^/[:space:]]*@' | cut -f1 | sort | uniq -c
```

Git writes the variable name in lowercase when it lists it, which is why the expression uses `insteadof`. No matching line means that Git reported no rewrite with a credential in that position in the configuration files it reads for the current directory. If Git prints an error, it appears on the terminal, so read it before you trust an empty result. It does not cover credentials placed elsewhere in a URL, such as in a query string, and it does not look at credential helpers or other files. We ran it against a sample configuration with two credential-bearing rewrites (one of them with an `@` inside the password) and one clean rewrite. It reported two, all from the one file. On a separate run against a repository with no such rewrites it printed nothing.

If it reports a file, open that file in an editor to see the entries. The file can be `~/.gitconfig`, the XDG file, the system file, the repository's own `.git/config`, or a file that one of those includes.

A second check looks inside a repository before you let an agent inspect it. If Git refuses to run because the folder belongs to another user (its `safe.directory` protection), read the file with a text viewer instead, and do not turn the protection off for an untrusted folder. Run it from the folder that contains the `.git` directory. It is a heuristic. It looks for a tab inside a remote name, written in the usual header form, and for remote URL values that do not start with a scheme, and it hides the values. It reads only the repository's own configuration file, so it does not cover included files or separate per-worktree configuration.

```
cfg="$(git rev-parse --git-common-dir)/config"
grep -nP '^\[remote "[^"]*\t[^"]*"\]' "$cfg"
git config --local --get-regexp '^remote\..*\.(push)?url$' | grep -vP '^\S+ [A-Za-z][A-Za-z0-9+.-]*://' | sed -E 's/ .*$/ <value hidden>/'
```

These commands need a GNU `grep` with the `-P` option, which macOS's default `grep` does not support. Any output deserves a look, but ordinary remotes in the form `git@host:path` and local paths also lack a scheme, so expect those as false positives. The advisory's case is a tab in the remote name, or a credential in a value with leading whitespace. We ran both against a sample repository with a tab-named remote and a value with leading whitespace, and both were flagged, with the values hidden. A repository can also arrive as an archive that includes its `.git` folder, so run the check on the unpacked folder and stop if Git cannot find a repository there.

## Step 4: Stop keeping the token in the Git configuration

If Step 3 found a token, move it out of the file. Git's [credential documentation](https://git-scm.com/docs/gitcredentials) describes credential helpers. Choose one that is backed by secure storage, such as `git-credential-libsecret` on Linux, `git-credential-osxkeychain` on macOS, `git-credential-wincred` on Windows, or Git Credential Manager. Be aware that Git's own `store` helper writes passwords to a plain file, and `cache` keeps them in memory for a short time. The documentation also lists OAuth credential helpers, which sign you in through the browser instead of asking you to create a token by hand. Then remove the `insteadOf` rewrite by editing the file that Step 3 reported, in an editor and not on the command line, so that the token does not end up in your shell history.

You can also keep the global Git configuration away from the agent's tools. Git reads the `GIT_CONFIG_GLOBAL` environment variable to choose the global configuration file, and `GIT_CONFIG_NOSYSTEM=1` skips the system file. We started the affected 2026.11.18 server with `GIT_CONFIG_GLOBAL=/dev/null` and called `git_remote` on the tab-named repository. The rewrite did not apply, and no token was returned. This only hides the settings from the normal global configuration. SSH agents, credential helpers and readable credential files are separate, and an agent started this way may not be able to authenticate through the global rewrite. Use it only if your workflow can live without those global settings.

## Step 5: Decide whether to rotate

Rotate the token if both of these are true: an affected version of the server ran on that machine while your global or system configuration held a token in a rewrite, and an agent may have inspected a repository that you did not write or fully trust. The token could then be in the model context, in session logs and in provider transcripts, so deleting the logs does not undo the exposure.

To look for tokens that already sit in saved logs or transcripts, search for the GitHub token formats. The pattern below matches `ghp_`, `gho_`, `ghu_`, `ghr_` and `github_pat_` tokens, and the `ghs_` installation tokens in both the older 40-character form and the longer stateless form that GitHub completed rolling out on 2 October 2026. It is a heuristic. Replace the folder with wherever your tools keep session logs.

```
grep -rEo 'gh[pour]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|ghs_[A-Za-z0-9._-]{36,}' ~/path/to/session-logs | sed -E 's/(gh[pousr]_|github_pat_).*/\1<redacted>/'
```

The terminal shows only the shortened form of each match, but the matched text does pass through the pipe, and file names in the output can themselves be sensitive. We tested the pattern on made-up strings: it matched four made-up strings in those formats (including a stateless-style `ghs_` token) and ignored two short strings. Treat any match as a live credential until you have revoked it, even though some matches will turn out to be fakes or false positives. No match proves little, because your tools may not keep logs and other hosts use other token formats.

## Step 6: Use scoped, short-lived tokens for agents

An agent needs the narrowest credential that does the job, for the shortest time. Using GitHub as the example, [GitHub's documentation](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/github-credential-types) describes these options:

- A **fine-grained personal access token** is limited to one owner, can be limited to selected repositories, carries specific permissions rather than broad scopes, and has an expiry that you choose. A token without an expiry is allowed unless an organization or enterprise policy sets a maximum lifetime, so choose the shortest finite expiry that works. It also keeps read-only access to public repositories.
- A **GitHub App installation access token** expires after one hour. When you create it, you can limit it to named repositories and to a subset of the app's permissions.
- A **classic personal access token** is long-lived, according to GitHub's table, and uses coarse scopes. The broad `repo` scope covers every repository the account can access, including those in its organizations, not selected ones. Prefer a fine-grained token for agents wherever it can do the job.

If you use another Git host, look for the same three properties: limited repositories, limited permissions, and a short lifetime. If a token like this leaks, its scope and its expiry reduce what an attacker can do with it afterwards, although they do not undo anything done while it was valid.

## Step 7: Treat what the agent reads as untrusted

The advisory's attack path is a repository that carries no secrets of its own and relies on yours. The same principle applies to every agent tool: inspecting someone else's code with your credentials in reach is the risky part. Keep credentials out of the agent's environment where you can, and review third-party skills and plugins before they run. We wrote a checklist for that: [Audit an AI agent skill before it runs](https://ngnext.tech/knowledge/audit-ai-agent-skill-before-it-runs).

## What we did not test

We did not test with real credentials, with a production MCP application, or with the Streamable HTTP transport. We used the Python MCP SDK's stdio client. We did not test whether a given application asks for approval before calling `git_remote`, or how it logs or retains tool output; those statements come from the advisory. We did not test the leading-whitespace case, the system-level configuration case, or the other fixes in the v2.6.0 release.

## Evidence

As of 28 November 2026.

| Claim | Status | Basis |
|---|---|---|
| Affected range 2026.11.4 up to before 2026.11.27, patched in 2026.11.27, Moderate, CVSS 5.3, CWE-200, no CVE | Verified against a primary source | GHSA-wvv2-676g-r57j, published 27 November 2026; GitHub API record of the advisory (the advisory lists no CVE) |
| PyPI releases in the range are 2026.11.4, 2026.11.11 and 2026.11.18, and 2026.11.27 is the latest | Verified against a primary source | PyPI project page data, read 28 November 2026 |
| The fix, the v2.6.0 release date and the six other mcp-server-git fixes | Verified against a primary source | modelcontextprotocol/servers v2.6.0 release notes |
| `git_remote` returns a made-up token on 2026.11.4, 2026.11.11 and 2026.11.18, and not on 2026.11.27 | Tested here | Real server over stdio with a made-up token, Linux, Python 3.12.3, Git 2.43.0, 28 November 2026 |
| With `GIT_CONFIG_GLOBAL=/dev/null`, plain `git remote -v` shows no rewrite and the 2026.11.18 server returns no token | Tested here | Git 2.43.0, real server over stdio, made-up token, 28 November 2026 |
| The `insteadOf`, remote-name and token-pattern commands flag the sample cases and hide the values | Tested here | Sample configuration, sample repository and made-up token strings, including a made-up stateless `ghs_` token |
| MCP clients generally call the read-only tool without a prompt, and the token then reaches model context, logs and provider transcripts | Reported, not reproduced | The advisory; we did not test a production MCP application |
| GitHub token types, the one-hour installation token, repository limits for fine-grained and installation tokens, and the stateless `ghs_` format | Verified against a primary source | GitHub documentation and changelog on credential types, installation tokens and the token format rollout |
| Keychain-backed and OAuth credential helpers exist; Git's `store` helper writes a plain file and `cache` keeps passwords in memory | Verified against a primary source | Git gitcredentials documentation |

## FAQ

### Which versions of mcp-server-git are affected?

The advisory lists the pip package mcp-server-git from 2026.11.4 up to, but not including, 2026.11.27, and gives 2026.11.27 as the patched version. On PyPI, the releases in that range are 2026.11.4, 2026.11.11 and 2026.11.18. The Model Context Protocol servers release notes for v2.6.0 describe the affected range as through 2026.11.18.

### Am I exposed if I never put a token in my Git configuration?

The path in the advisory needs a credential-bearing url.insteadOf rewrite in your global or system Git configuration, which the tool then returns. Without a credential in such a rewrite, there is nothing for this path to return. The advisory also mentions repositories whose own .git/config holds a credential in a URL value with leading whitespace. The upgrade fixes both redaction bypasses, but it does not remove tokens from your configuration or undo an earlier disclosure.

### How does the leak happen?

The git_remote tool parses the output of git remote -v. A remote name that contains a tab character shifts the columns, and the redaction step only looks for a URL scheme at the very start of the field, so it skips the credential. The advisory describes a repository that carries no secrets itself and only a crafted remote name.

### Do I need to rotate my token?

Rotate it if you ran an affected version and your agent may have inspected a repository that you did not write or fully trust, because the token could then reach the model context, session logs or provider transcripts, depending on your client and its retention settings. Revoke a token that may have been exposed promptly, and update the tools that use it, because rotation can interrupt them.

### What is a better setup than a token inside insteadOf?

A Git credential helper backed by your system keychain (for example libsecret, osxkeychain, wincred or Git Credential Manager), or a helper that generates credentials on demand, instead of a token written into the Git configuration file. Git's own store helper writes credentials to a plain file, so it is not a substitute. Pair the helper with a token limited to the repositories and permissions the task needs, and with a short lifetime.

### What are scoped, short-lived tokens on GitHub?

A fine-grained personal access token is limited to one owner, can be limited to selected repositories, carries specific permissions, and has an expiry that you choose. A token without an expiry is allowed unless an organization or enterprise policy sets a maximum lifetime, so choose a short, finite one. A GitHub App installation token expires after one hour and can be limited to named repositories and permissions. Other Git hosts have their own equivalents.

### Is there a CVE number?

As of 28 November 2026, the advisory lists no CVE ID. It rates the issue Moderate, with a CVSS 3.1 score of 5.3, and classifies it as CWE-200, exposure of sensitive information.

### Did you test this?

Yes, with a made-up token and a throwaway repository. On 28 November 2026 we ran four versions of the server through the Python MCP SDK's stdio client. The three affected releases returned the made-up token and 2026.11.27 did not. We did not test with real credentials, other Git hosts, or a production MCP application and its approval and logging behaviour.

## References

- GitHub advisory: [GHSA-wvv2-676g-r57j, git_remote credential redaction bypass](https://github.com/modelcontextprotocol/servers/security/advisories/GHSA-wvv2-676g-r57j)
- Model Context Protocol servers: [v2.6.0 release notes](https://github.com/modelcontextprotocol/servers/releases)
- PyPI: [mcp-server-git](https://pypi.org/project/mcp-server-git/)
- Git: [gitcredentials documentation](https://git-scm.com/docs/gitcredentials)
- GitHub: [credential types reference](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/github-credential-types)
- GitHub: [generating an installation access token for a GitHub App](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app)
- GitHub: [managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
- GitHub changelog: [stateless installation tokens rolled out](https://github.blog/changelog/2026-10-02-stateless-github-app-installation-tokens-rolled-out/)

If you run AI agents against your own repositories and want a second pair of eyes on how they handle credentials, the know-how here stays free. [NG-NeXT](https://ngnext.tech) also does consulting for private infrastructure. Tell us what you run through the [contact page](https://ngnext.tech/contact).

— Nishant Gauraw, Founder and CEO, [NG-NeXT Tech](https://ngnext.tech)

## Updated and author

Last updated 2026-11-28 by Nishant Gauraw, [NG-NeXT](https://ngnext.tech).
