Skip to content

fix(gix-config): reject extra tokens after implicit values - #3203

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-config-parsing
Nov 14, 2026
Merged

Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-config-parsing

Conversation

@Byron

@Byron Byron commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Malformed config lines such as x url = ../evil were parsed as an implicit x and another URL setting. In .gitmodules, that could expose a URL that Git refuses to read and direct a downstream consumer to clone from it. This work was motivated by GitPython PR #2345, which adds a fallback around this mismatch in its native gix backend.

gix-config now requires implicit values to end at EOF, LF, or CRLF after spaces/tabs. Extra settings, comments, and headers after bare keys are rejected. Valid header-line settings, implicit booleans, quoting, and continuations retain their behavior.

A read-only fixture establishes a 25-case Git baseline, checking acceptance and the winning URL through the public config parsers. A gix-submodule::File::from_bytes() regression checks the sensitive consumer directly. Both regressions failed before the fix. Existing fuzz tests now expect rejection for malformed inputs, while retaining the memory budget check.

The config writer now puts comments after implicit values on the following line, so it produces valid config too. Round-trip tests cover LF, CRLF, and CLI overrides while preserving implicit boolean semantics.

Git baseline

Git 2.54.0 (Apple Git-157), with behavior checked against the local Git source at 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd: config.c:get_value() and t/t1300-config.sh's header-line setting test. The fixture runs git config --file - --list and records URLs for accepted inputs. Both affected fuzz inputs are also rejected by Git with exit 128.

Validation

  • Affected crate test suites with all features: 415 passed, including the new Git baseline and .gitmodules regression.
  • gix config/submodule tests: 182 passed.
  • Stable-compatible affected crate doctests: 31 passed.
  • Clippy with all targets/features and warnings denied, workspace formatting, ShellCheck, and diff checks passed.

CI follow-up

Required CI is green on d542690, including Linux, macOS, Windows, feature tests/builds, docs, journey tests, CIFuzz, CodeQL, and zizmor. The final Codex commit review found no introduced bug, and there are no pending review threads.

Nine advisory consumer jobs fail on API changes already present in the base, rather than this parser fix:

  • jj, jj-testutils, crates-index, rustsec, and cargo need adaptations to explicit repository option reuse (5647da5466).
  • starship needs the optional diff resource argument (1d94b9dd14).
  • vergen-gix needs fallible path/shallow query handling (029c5971cd and the existing shallow query API).
  • Both GitButler consumer jobs need the credentials Outcome::identity to credentials rename (f7cbe2793b).

These jobs are explicitly advisory in the workflow; the required Tests pass check succeeds. CI also caught the new fixture's missing executable bit, which is corrected in this commit and passes the housekeeping check.

Reported issue

$issue-full-auto   https://github.com/gitpython-developers/GitPython/pull/2345 is the motivation, which shows that Gitoxide can parse files which Git rejects for good reason, which in turn can be abused for .gitmodules files which are sensitive. Setup a baseline with Git as part of the fix.

This removes a long-standing 'leniency' that I thought was a feature.
But probably it can always be turned into something surprising that
better doesn't exist.

<!-- agent -->
GitPython's native gix backend exposed submodule settings from malformed
`.gitmodules` files that Git refuses to read. In particular, a line such
as `x url = ../evil` could override an earlier URL and make a consumer
clone from that location. This work was motivated by
gitpython-developers/GitPython#2345.

Require an implicit value to end at EOF, LF, or CRLF after the existing
space/tab handling. Extra names, attached or spaced comments, and section
headers are errors unless the key has an explicit `=`. Keep valid
header-line settings, implicit booleans, quoting, and continuations.

Add a read-only, 25-case baseline generated by `git config --file -
--list`, including winning URLs for accepted files. Compare the public
event and file parsers, including filtered events, and add a public
`gix-submodule::File::from_bytes()` regression. Both new regressions failed
before the fix. Update the old permissive comment expectation, diagnostics,
and malformed fuzz fixtures while retaining the memory budget check.

Reference: Git 2.54.0 (Apple Git-157); local Git source
`6de20f6092dcf9bdb1c8efe03db4b70c82b423dd`, `config.c:get_value()` and
`t/t1300-config.sh`'s same-line section-setting test. Git also rejects both
affected fuzz fixtures with exit 128.

Assisted-by: GPT 6.1 Sol
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
@Byron
Sebastian Thiel (Byron) marked this pull request as ready for review November 14, 2026 20:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T20:53:17.117846Z 3d3aa94 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Byron
Sebastian Thiel (Byron) merged commit 154ffbc into main Nov 14, 2026
24 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant