Practical technical guides / Recent development: Gemini CLI v0.68.0 (10 November 2026), pull request 29999, case-insensitive path containment on Windows

When C: and c: Disagree: Path Containment Checks on Case-Insensitive File Systems Must Fail Closed

Gemini CLI 0.68.0 fixed a case-sensitive containment check that let .gitignore rules be bypassed on Windows. Compare paths like the file system does, and fail closed.

By Sandeep Belgavi · Published 2026-11-11

Gemini CLI 0.68.0 fixed a case-sensitive containment check that let .gitignore rules be bypassed on Windows. Compare paths like the file system does, and fail closed.

The ignore file that stopped applying

Gemini CLI v0.68.0, released on 10 November 2026, includes a fix that is worth understanding even if you never run Gemini CLI, because the same mistake is easy to make in any tool that decides whether a file is inside a workspace. Pull request 29999, "fix(core): make isWithinRoot case-insensitive on Windows", merged on 28 October and listed in the v0.68.0 release notes, describes the problem in its summary.

On Windows, the same directory often arrives with different casing from different sources. An editor or IDE reports c:\Users\..., while process.cwd() or os.homedir() reports C:\Users\.... The function isWithinRoot() compared the resolved paths with case-sensitive equality and startsWith(), so valid in-workspace paths were judged to be outside. The pull request lists three consequences:

  • the ACP file system service fell back to native disk reads and writes instead of routing in-project files through the IDE connection, or "failed to protect global ~/.gemini files when os.homedir() casing differed";
  • GitIgnoreParser and IgnoreFileParser received null from getNormalizedRelativePath(), "bypassing .gitignore and .geminiignore rules for paths with mismatched casing";
  • in-workspace paths attached with @ were treated as outside-workspace paths.

The fix resolves paths with path.win32 when the platform is Windows and lower-cases both sides before comparing, while keeping comparisons case-sensitive on Linux and macOS.

The second consequence is the one to study. A containment check that said "outside" turned into an ignore check that said "not ignored", and files that the user had explicitly excluded were treated as ordinary files. A false negative in one function became a fail-open decision in another.

Reproducing the shape

The companion example uses Python's ntpath module, which applies Windows path rules on any operating system, so the results are the same everywhere. The workspace root comes from the process: C:\Users\Geetha\shop. The ignore rules are .env, secrets/ and *.pem. The paths arrive with editor casing.

Containment first, for four checks:

PathCase-sensitiveLower-casedPureWindowsPathPrefix without separator
C:\Users\Geetha\shop\.envinsideinsideinsideinside
c:\users\geetha\shop\.envoutsideinsideinsideinside
c:\Users\Geetha\shop\secrets\api.txtoutsideinsideinsideinside
C:\Users\Geetha\shop-old\server.pemoutsideoutsideoutsideinside
c:\users\geetha\shop\..\notes\todo.txtoutsideoutsideoutsideoutside

The case-sensitive check rejects every path that arrives with different casing. Lower-casing and Python's PureWindowsPath, whose comparisons and is_relative_to are case-insensitive, accept them. The last column is a different classic bug: startswith without a trailing separator accepts shop-old as part of shop. Every check normalises .. before comparing; without that step, shop\..\notes would pass a lexical prefix test.

Now the ignore filter built on top. It calls a helper that returns the path relative to the root, or None when the path is outside. The fail-open version treats None as "no rule matched":

PathCase-sensitive, fail-openCase-sensitive, fail-closedLower-cased, fail-closed
c:\users\geetha\shop\.envprocessrefuseskip (ignored)
c:\Users\Geetha\shop\secrets\api.txtprocessrefuseskip (ignored)
c:\Users\Geetha\shop\src\cart.pyprocessrefuseprocess

With the case-sensitive check and a fail-open filter, the .env file and the secrets folder are processed: read, indexed, perhaps sent to a model. That is the reported bug. With the same broken check and a fail-closed filter, those files are refused. The user sees an annoying "outside workspace" error for cart.py instead of a silent leak of .env. Fixing the comparison then removes the annoyance.

Design rule one: unknown means no

Any function that answers "is this path inside the area I am allowed to touch" feeds a security decision. When it cannot place a path inside, the caller must deny, not proceed as if no restriction applied. In code, that means the relative-path helper's None is an error path, not a default.

def decide(path, root, rules):
    rel = relative_inside(path, root)
    if rel is None:
        return 'refuse (outside workspace)'
    return 'skip (ignored)' if ignored(rel, rules) else 'process'

The test that keeps this true is short: for every path the containment check rejects, the filter must refuse. The companion runs it over every path and check.

Design rule two: compare the way the file system does

Lower-casing both sides fixes the common case on Windows. It is still an approximation of what the file system does, for three reasons.

Case sensitivity on Windows is a directory attribute. Microsoft's documentation on case sensitivity explains that the Windows file system treats names case-insensitively by default, but supports a per-directory flag that makes a directory case-sensitive, used mainly with the Windows Subsystem for Linux. A blanket lower-case comparison is wrong inside such a directory.

macOS is not always case-sensitive. The fix keeps macOS comparisons case-sensitive, but Apple's Disk Utility offers both APFS and a separate APFS (Case-sensitive) format, and describes plain APFS as the choice when you do not need a case-sensitive format. On a plain APFS volume, Shop and shop name the same folder, and the same mismatch can arise.

Lower-casing is not the file system's case table. str.lower() in Python and toLowerCase() in JavaScript apply Unicode case mappings, which may differ from the table a file system uses for non-ASCII names. For example, Python maps U+212A KELVIN SIGN to an ordinary "k", so PureWindowsPath('C:/\u212a') == PureWindowsPath('C:/k') is true in Python 3.13. Whether a given file system agrees is a property of that file system, not of the string library.

The robust approach is to ask the file system. Resolve the path with the operating system's own canonicalisation (Python's os.path.realpath or Java's Path.toRealPath), which on Windows returns the stored casing of existing components and follows links, then compare. Or compare identity rather than spelling: walk up from the path and check each parent with os.path.samefile against the root, which compares device and file identifiers. Both work only for paths that exist; for a file about to be created, canonicalise its parent directory.

Design rule three: decide once, at one boundary

The Gemini CLI fix touched two functions, isWithinRoot() and getNormalizedRelativePath(), because both made path decisions. Tools tend to grow several such places: an ignore parser, a file reader, an attachment resolver, a sandbox policy. Each is a chance to disagree with the others. Prefer one function that turns an incoming path into a canonical, contained, relative path or an error, and pass the result, not the raw string, to everything downstream.

Tests worth adding

  • Casing: the root and the path differing only by case, on a case-insensitive platform, and the same pair on a case-sensitive one.
  • Prefix siblings: shop and shop-old.
  • Dot segments and links: .. that leaves the root, and a link inside the root that points outside.
  • Fail-closed behaviour: every path the containment check rejects is refused, never processed.
  • Ignore rules with mismatched casing: an ignored file reached through a differently cased path is still ignored.

What remains uncertain

The pull request does not describe any real-world exposure, and this article did not reproduce the bug in Gemini CLI itself; the examples are a model of the shape it describes. The release notes list the change without further detail.

Limits of the companion

It uses ntpath and PureWindowsPath, which are lexical: they do not touch the disk, follow links or know about per-directory case sensitivity. The identity-based check described above needs a real file system and is not part of the recorded output. The ignore matcher is a small subset of gitignore semantics.

Primary references and authorship

Sources dated on or before 11 November 2026. Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/path_case_containment. Views are my own and do not represent any employer, past or present.