Repository navigation
fix(git): a sync path can no longer be read as a git option (abilityai/trinity-enterprise#1117) - #4294
Merged
vybe merged 13 commits intoNov 6, 2026
Conversation
…bilityai/trinity-enterprise#1117) The Push endpoint staged the caller's paths with `git add <paths>`, so an element such as `-f` was parsed as an option: `paths: ["-f", ".env"]` force-staged the gitignored .env and the same sync committed and pushed it. Stage with `git add -- <paths>`, so every element is a pathspec. The test drives the real endpoint against a scratch repo with a local bare origin and asserts on what reached origin; the no-paths `git add -A` branch is pinned unchanged.
…ai/trinity-enterprise#1117) An agent keeps the agent server it was created with until it is recreated on a new base image, and the older server stages paths without `--`. The backend sync request now rejects any `paths` element starting with '-' with a 422 that names the element, before the agent is called. A dash elsewhere in a path (`sub/-x.md`) is accepted; a file whose name starts with '-' can be named as `./-name`.
…nity-enterprise#1117) The git_sync tool schema now rejects any `paths` element starting with '-' with a parameter error naming the element (`paths.<i>: '<element>' starts with '-' ...`), so the call never reaches the backend. The constraint is also advertised in the tool's JSON schema as `pattern: ^(?!-)`.
…yai/trinity-enterprise#1117) The plain-paths sync test changed only the files it named, so staging everything (`git add -A`) whenever `paths` is given passed it too. It now also modifies an unrelated tracked file and asserts that file is not in origin's tree at its new content and is still dirty locally. It also names a root-level file whose name starts with '-' as `./-x.md`, the spelling the backend's 422 recommends, and checks it is pushed. (Abilityai/trinity-enterprise#1117)
…aths alike (Abilityai/trinity-enterprise#1117) The backend model and the MCP tool schema each refuse a sync path that starts with '-'. Nothing pinned that they agree, so either side could become stricter (reject ' -f' or '') or looser (a multiline regex accepts '-f\nx') and a caller would get different answers from the API and from MCP. Both test files now read tests/fixtures/git-sync-path-cases.json and must decide every row the same way: options, a lone dash, '--', dash then NUL or newline are refused; leading whitespace, an empty string, './-x', a dash after a slash or newline, Unicode dashes and a BOM are accepted, because git reads an option only when the first byte is an ASCII '-'. The "names the element" checks now require the message to lead with the element (`paths[i] '<elem>' starts with '-'` and `'<elem>' starts with '-'`). The old substring check passed for ["-"] even with the element dropped, since "'-'" is already in "starts with '-'". (Abilityai/trinity-enterprise#1117)
…inity-enterprise#1117) A sync path that starts with '-' is refused with a message that names the element twice: once to point at it, once in the './<name>' suggestion. The request bounds nothing, so a 10,000-character element made a ~20 KB 422. The backend validator and the git_sync tool schema now echo at most 200 characters of the element, followed by an ellipsis. The message still leads with the index and the element. (Abilityai/trinity-enterprise#1117)
…inst git (Abilityai/trinity-enterprise#1117) The table held three of the seven Unicode dashes that were checked against git. A backend that also refused U+2013 or U+2014, which the MCP tool accepts, passed both suites. It now holds U+2010, U+2011, U+2013, U+2014, U+2212, U+FE63 and U+FF0D as accepted rows, and the coverage test requires all seven. The file is now plain ASCII with \u escapes, so the BOM, zero-width space and soft-hyphen rows cannot be stripped by an editor without showing in the diff. (Abilityai/trinity-enterprise#1117)
… a 500 (Abilityai/trinity-enterprise#1117) A JSON body may carry an unpaired surrogate as an escape, for example {"paths": ["-\ud800"]}. The refusal message quoted the element once through repr() but put it raw into the './<name>' suggestion. A raw lone surrogate cannot be encoded as UTF-8, so pydantic-core raised UnicodeEncodeError while building the validation error and the route answered 500 before the 422 handler ran. The suggestion now goes through repr() too. For every ordinary element the message text is unchanged ('./-f'). The shared path table gains two refused rows with a lone surrogate and one accepted row (a surrogate with no leading dash). A route test sends a surrogate first, in the middle, inside the 200-character echo and past it, and requires a 422 whose body decodes as strict UTF-8 JSON. On the MCP side, the same elements are refused with an error that serialises to valid UTF-8 JSON. The MCP tests pass before and after this change, because JSON.stringify already escapes a lone surrogate. (Abilityai/trinity-enterprise#1117)
…bilityai/trinity-enterprise#1117) The git_sync refusal echoes at most 200 characters of the element. The cut counted UTF-16 units, so an emoji straddling unit 200 was split and the message carried half of a surrogate pair. The cut now counts code points, the same unit the backend uses, so it never splits a pair. (Abilityai/trinity-enterprise#1117)
…bilityai/trinity-enterprise#1117) tests/fixtures/git-sync-path-cases.json is read by both the backend unit tests and the MCP git_sync tests. The backend workflow has no path filter, but the MCP workflow ran only on src/mcp-server/**. A change to the table alone could therefore break the MCP side without CI noticing. The table is now in both of that workflow's path lists. (Abilityai/trinity-enterprise#1117)
…117-s6a-git-add-option-injection
obasilakis
approved these changes
Nov 6, 2026
obasilakis
left a comment
Contributor
There was a problem hiding this comment.
Reviewed (code review + /validate-pr, lane C). Approving the code.
git add -- <paths>in the agent server is the real fix; every other git call taking caller paths already uses--. The backend 422 and MCP check cover older base images and agree (first-character check, 200-code-point echo).- Mutation: reverting
--fails 2/4 includingtest_dash_f_cannot_force_stage_and_push_an_ignored_env; backend validator off fails 20/49; MCP regex neutralised fails 19/42.
Before merge:
- Conflicts with dev at
tests/registry.json(append next to the ent#1107 entry; mechanical). frontend-e2eskipped (nouilabel), which lane C asks for.
Follow-ups (both pre-existing):
agent_server/routers/git.py:2355— when staging the named paths fails, sync logs a warning, commits whatever was staged, and returns success. The caller is never told the paths were dropped.tests/fixtures/git-sync-path-cases.json:30— a lone-surrogate path is accepted by backend and MCP, then raisesUnicodeEncodeErrorinsubprocess.runon the agent server (500 → backend 400). Refusing it at the 422 would make the table's "ordinary path" claim true.
|
Resolve by running |
…117-s6a-git-add-option-injection # Conflicts: # tests/registry.json
AndriiPasternak31
marked this pull request as ready for review
November 6, 2026 18:40
|
Resolve by merging |
yunyminaya
pushed a commit
to yunyminaya/trinity
that referenced
this pull request
Nov 11, 2026
…i/trinity-enterprise#1117) (Abilityai#4294) * fix(agent-server): a sync path can no longer be read as a git option (Abilityai/trinity-enterprise#1117) The Push endpoint staged the caller's paths with `git add <paths>`, so an element such as `-f` was parsed as an option: `paths: ["-f", ".env"]` force-staged the gitignored .env and the same sync committed and pushed it. Stage with `git add -- <paths>`, so every element is a pathspec. The test drives the real endpoint against a scratch repo with a local bare origin and asserts on what reached origin; the no-paths `git add -A` branch is pinned unchanged. * fix(git): the sync route refuses a path that starts with '-' (Abilityai/trinity-enterprise#1117) An agent keeps the agent server it was created with until it is recreated on a new base image, and the older server stages paths without `--`. The backend sync request now rejects any `paths` element starting with '-' with a 422 that names the element, before the agent is called. A dash elsewhere in a path (`sub/-x.md`) is accepted; a file whose name starts with '-' can be named as `./-name`. * fix(mcp): git_sync refuses a path that starts with '-' (Abilityai/trinity-enterprise#1117) The git_sync tool schema now rejects any `paths` element starting with '-' with a parameter error naming the element (`paths.<i>: '<element>' starts with '-' ...`), so the call never reaches the backend. The constraint is also advertised in the tool's JSON schema as `pattern: ^(?!-)`. * test(agent-server): a subset sync pushes only the named paths (Abilityai/trinity-enterprise#1117) The plain-paths sync test changed only the files it named, so staging everything (`git add -A`) whenever `paths` is given passed it too. It now also modifies an unrelated tracked file and asserts that file is not in origin's tree at its new content and is still dirty locally. It also names a root-level file whose name starts with '-' as `./-x.md`, the spelling the backend's 422 recommends, and checks it is pushed. (Abilityai/trinity-enterprise#1117) * test(git): the API and the git_sync tool decide one shared table of paths alike (Abilityai/trinity-enterprise#1117) The backend model and the MCP tool schema each refuse a sync path that starts with '-'. Nothing pinned that they agree, so either side could become stricter (reject ' -f' or '') or looser (a multiline regex accepts '-f\nx') and a caller would get different answers from the API and from MCP. Both test files now read tests/fixtures/git-sync-path-cases.json and must decide every row the same way: options, a lone dash, '--', dash then NUL or newline are refused; leading whitespace, an empty string, './-x', a dash after a slash or newline, Unicode dashes and a BOM are accepted, because git reads an option only when the first byte is an ASCII '-'. The "names the element" checks now require the message to lead with the element (`paths[i] '<elem>' starts with '-'` and `'<elem>' starts with '-'`). The old substring check passed for ["-"] even with the element dropped, since "'-'" is already in "starts with '-'". (Abilityai/trinity-enterprise#1117) * fix(git): cap the path echoed in a refused sync request (Abilityai/trinity-enterprise#1117) A sync path that starts with '-' is refused with a message that names the element twice: once to point at it, once in the './<name>' suggestion. The request bounds nothing, so a 10,000-character element made a ~20 KB 422. The backend validator and the git_sync tool schema now echo at most 200 characters of the element, followed by an ellipsis. The message still leads with the index and the element. (Abilityai/trinity-enterprise#1117) * test: register the sync-path option tests in tests/registry.json (Abilityai/trinity-enterprise#1117) (Abilityai/trinity-enterprise#1117) * test(git): the shared path table covers every Unicode dash probed against git (Abilityai/trinity-enterprise#1117) The table held three of the seven Unicode dashes that were checked against git. A backend that also refused U+2013 or U+2014, which the MCP tool accepts, passed both suites. It now holds U+2010, U+2011, U+2013, U+2014, U+2212, U+FE63 and U+FF0D as accepted rows, and the coverage test requires all seven. The file is now plain ASCII with \u escapes, so the BOM, zero-width space and soft-hyphen rows cannot be stripped by an editor without showing in the diff. (Abilityai/trinity-enterprise#1117) * fix(git): a refused sync path carrying a lone surrogate is a 422, not a 500 (Abilityai/trinity-enterprise#1117) A JSON body may carry an unpaired surrogate as an escape, for example {"paths": ["-\ud800"]}. The refusal message quoted the element once through repr() but put it raw into the './<name>' suggestion. A raw lone surrogate cannot be encoded as UTF-8, so pydantic-core raised UnicodeEncodeError while building the validation error and the route answered 500 before the 422 handler ran. The suggestion now goes through repr() too. For every ordinary element the message text is unchanged ('./-f'). The shared path table gains two refused rows with a lone surrogate and one accepted row (a surrogate with no leading dash). A route test sends a surrogate first, in the middle, inside the 200-character echo and past it, and requires a 422 whose body decodes as strict UTF-8 JSON. On the MCP side, the same elements are refused with an error that serialises to valid UTF-8 JSON. The MCP tests pass before and after this change, because JSON.stringify already escapes a lone surrogate. (Abilityai/trinity-enterprise#1117) * fix(mcp): cut the echoed sync path by code points, not UTF-16 units (Abilityai/trinity-enterprise#1117) The git_sync refusal echoes at most 200 characters of the element. The cut counted UTF-16 units, so an emoji straddling unit 200 was split and the message carried half of a surrogate pair. The cut now counts code points, the same unit the backend uses, so it never splits a pair. (Abilityai/trinity-enterprise#1117) * ci: run the MCP server tests when the shared sync-path table changes (Abilityai/trinity-enterprise#1117) tests/fixtures/git-sync-path-cases.json is read by both the backend unit tests and the MCP git_sync tests. The backend workflow has no path filter, but the MCP workflow ran only on src/mcp-server/**. A change to the table alone could therefore break the MCP side without CI noticing. The table is now in both of that workflow's path lists. (Abilityai/trinity-enterprise#1117) (cherry picked from commit 22e5942)
vybe
added a commit
to jordanallenlewis/determinity
that referenced
this pull request
Nov 19, 2026
main carries 7 commits that are not ancestors of dev: the ent#1117 security back-ports (Abilityai#4291, Abilityai#4294, Abilityai#4314, Abilityai#4315, Abilityai#4399, Abilityai#4400) and the llms.txt refresh (Abilityai#4287). Every one of them is already on dev in its original form, so this is a merge with dev's tree kept as-is (strategy ours). It records main as a parent so the dev -> main release PR no longer conflicts. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of abilityai/trinity-enterprise#1117.
Journey Impact: none: git sync refuses a path that starts with '-'; ordinary syncs are unchanged
Problem
The agent server's Push (
POST /api/git/sync) staged the caller'spathswithgit add <paths>, so git parsed any element starting with-as an option.paths: ["-f", ".env"]force-staged the gitignored.env, and the same sync committed it and pushed it to the remote. An agent's owner, an admin, or the agent's own key can send that request through the API or thegit_syncMCP tool, without shell access. CodeQL reports it aspy/command-line-injection(Critical, alert #22).Fix
git add -- <paths>, so every element is a pathspec. The no-paths branch (git add -A) and the rest of the sync are unchanged.pathselement that starts with-with a 422, before the agent is called.paths[0] '-f' starts with '-' ...) and echoes at most 200 characters of it.\ud800) also gets a 422, not a 500.git_synctool schema refuses the same elements with a parameter error naming the element (paths.0: '-f' starts with '-' ...). It is capped the same way, counting code points like the backend, so the cut never splits a surrogate pair. The tool's JSON schema advertises it aspattern: ^(?!-).A dash anywhere else in a path (
sub/-x.md) is still accepted, as are leading whitespace, an empty string and Unicode dashes: git reads an option only when the first byte is an ASCII-. A file whose name really starts with-can be named as./-name.Evidence
tests/unit/test_ent1117_s6a_git_add_option_injection.pydrives the real endpoint against a scratch repo with a local bare origin..envreached origin (assert '.env' not in {'.env', '.gitignore', 'notes.md'}). After the fix, 4 passed../-x.mdstages a file whose name starts with-.git add -A.tests/unit/test_ent1117_s6a_sync_paths_option_reject.pycovers the model and the real router with the platform's 422 handler.-f.paths[0] '-f', the agent is never called, a dash in the middle is forwarded unchanged, and an empty body still syncs everything.src/mcp-server/src/tools/git.ent1117-s6a.test.tsvalidates through the same~standard.validatecall FastMCP makes. It also checks that a refusal carrying a lone surrogate serialises to valid UTF-8 JSON, and that the cap never splits a surrogate pair.tests/fixtures/git-sync-path-cases.json. It has 30 inputs, including leading whitespace,'', a dash before or after a newline, seven Unicode dashes, a BOM, and lone surrogates. Both sides must decide every row the same way: for any input in the table, a test fails if one side refuses what the other accepts.tests/:pytest -p no:randomly unit/test_ent1117_s6a_git_add_option_injection.py unit/test_ent1117_s6a_sync_paths_option_reject.py unit/test_models_centralized.py unit/test_ent109_validation_error_no_input.py unit/test_2529_gitignore_precedence.py unit/test_1596_git_sync_observability.py unit/test_4001_no_auto_maintenance.py unit/test_agent_server_auto_sync.py unit/test_2338_journey_catalog.pygives 191 passed, 1 skipped.src/mcp-server:node --import tsx --test src/tools/git.test.ts src/tools/git.ent1117-s6a.test.tsgives 52 passed.tsc --noEmitis clean.Not covered
.envalready pushed by this route before the fix stays in the remote's history. Rotate those credentials.["git", "add", "--", *paths]) from an equivalent concatenation, which builds the same list at runtime; no test can distinguish them.