Skip to content

revert: roll back workspace trust-boundary hardening - #4013

Merged
7Sageer merged 2 commits into
mainfrom
revert-pr-3964-hardening
Sep 24, 2026
Merged

7Sageer merged 2 commits into
mainfrom
revert-pr-3964-hardening

Conversation

@7Sageer

@7Sageer 7Sageer commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Revert the workspace trust-boundary hardening from #3964: once a user trusts a repository, content inside it is the user's own responsibility — we no longer harden against it.

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

Rolled back (all post-trust hardening):

 packages/agent-core-v2/
-├── src/app/git/hardening.ts              # hardened git-config probes + fail-closed logic
 ├── src/app/git/gitService.ts             # plain runCommand again
-├── src/tool/realpath-access.ts           # symlink realpath re-check layer
 ├── src/agent/tools/                      # read/write/edit/glob/grep/read-media: no realpath check
 ├── src/agent/permissionPolicy/policies/  # local.toml writes auto-approved again
 ├── src/workspace/workspaceDirs/          # local.toml applies regardless of trust
 ├── src/persistence/.../projectLocalConfigService.ts
 │                                         # no home/root rejection; no locateAdditionalDirsConfig
 └── src/session/agentLifecycle/profile/   # gitContext: own spawn logic again
 apps/kimi-code/
-├── src/utils/git/git-args.ts             # GIT_CONFIG_ARGS / GIT_DIFF_ARGS
 ├── src/utils/git/git-status.ts           # lazy repo detection kept; config args dropped
 └── src/feedback/codebase/scanner.ts      # plain git ls-files / rev-parse again

Kept (only affects the pre-trust window or the trust prompt itself):

  • kimi-tui.ts: a failed trust-info read is treated as untrusted and still prompts
  • git-status.ts: footer git repo detection stays deferred to the first render

Docs: removed the local.toml trust-gating and broad-dir-rejection sentences from docs/{en,zh}/configuration/config-files.md.

Changeset: .changeset/revert-trust-boundary-hardening.md (@moonshot-ai/kimi-code patch).

Impact Scope

  • packages/agent-core-v2: git service, file tools, permission policy, workspace dirs, project-local config, tower protocol git
  • apps/kimi-code: footer git status, codebase upload scanner
  • Tests: deleted the hardening / symlink / local-config test files; remaining suites pass (pnpm typecheck green, pnpm lint 0 errors, affected vitest files pass)

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve). — N/A, internal revert; rationale above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. — docs/{en,zh}/configuration/config-files.md updated in this PR.

Roll back the hardening added in #3964 that guarded against malicious
content inside an already-trusted repository:

- background git invocations no longer override repo-local git config
  (fsmonitor, hooksPath, filters, drivers, gpg, editor)
- agent file tools no longer re-resolve paths through symlinks
- project-local local.toml applies without workspace-trust gating,
  additional_dir entries are no longer rejected for resolving to the
  home directory or filesystem root, and writing it is auto-approved
  again inside a git worktree

Kept, since they only affect the pre-trust window or the trust prompt
itself: the fail-closed trust prompt and lazy footer git detection.
Copilot AI balanced review requested due to automatic review settings September 24, 2026 03:56
@changeset-bot

changeset-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4bb9061

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@7Hanrui

7Hanrui commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: bcbd7244d2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer
7Sageer marked this pull request as ready for review September 24, 2026 05:51
@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@4bb9061
npx https://pkg.pr.new/@moonshot-ai/kimi-code@4bb9061

commit: 4bb9061

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4bb9061406

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"@moonshot-ai/kimi-code": patch
---

Roll back some of the overly defensive changes in 2.1.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Describe the restored behavior in the changeset

Replace this vague sentence with the concrete user-visible behavior being restored, such as allowing file tools to follow external symlink targets, honoring repository Git configuration, and applying project-local additional_dir entries without extra approval. As written, the generated release notes only say that “some” changes were rolled back and do not tell users what changed, contrary to the repository requirement that changesets state the change in one short user-facing sentence.

AGENTS.md reference: AGENTS.md:L85-L86

Useful? React with 👍 / 👎.

@7Sageer
7Sageer merged commit 929403b into main Sep 24, 2026
16 checks passed
@7Sageer
7Sageer deleted the revert-pr-3964-hardening branch September 24, 2026 06:49
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Sep 24, 2026
…tch docs

Follows upstream 929403b (MoonshotAI#4013, revert of MoonshotAI#3964): background git
invocations no longer override repo-local git config (utils/git/git-args.ts
deleted), the codebase scanner and git-status cache drop the config-args
wiring, and the hardening-assertion tests are removed. The fail-closed
trust prompt and lazy footer git detection stay, matching upstream.

The Rust-side half was never committed (the MoonshotAI#3964 port lived only in the
working tree), so nothing to revert there; the local.toml feature itself
stays ungated. Residual divergence (resolve_for_write realpath vs lexical)
is recorded in ROADMAP §6.8.1.

Docs for the watch-default-on flip (MoonshotAI#4015) are taken byte-identical from
be7d5f5 (2.1.1 final): [watch] enabled defaults to on, KIMI_CODE_WATCH
override documented — the code half remains unported (tracked, ROADMAP
§6.8.2); the fork has no watcher subsystem and /reload stays explicit.

ROADMAP §6.8 records the full 2.1.0..2.1.1 triage; check-upstream-v2-delta
reports all deltas triaged.
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Sep 24, 2026
/add-dir gains a "remember" choice: the picked directory is written to
the project's .kimi-code/local.toml (workspace.additional_dir) and every
later session of that checkout starts with it in scope.

Both hosts implement the same rules with mirrored tests: the TS side
(packages/node-sdk/src/project-local-config.ts, FileProjectLocalConfig
port) locates the project root by walking up to .git, validates and
dedupes additional_dir entries, and merges trusted project roots into
session additionalDirs at create/resume; the Rust side
(project_local_config.rs) serves the standalone server / web UI / VS
Code path, folding the project roots into spec.extra_roots. The prompt
builder's ${additional_dirs_section} now reflects the merged list, and
the session transcript snapshot reports the task set instead of an
empty placeholder.

Writing local.toml follows the reverted trust-boundary policy (upstream
MoonshotAI#4013): no trust gating on the file itself, and the tests cover the
untrusted-project and session-only-directory edges.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Oct 5, 2026
Step 10 of the incremental sync to 2.1.1: 4 upstream commits over 59
files. The step rolls back the 2.1.0 trust-boundary hardening and turns
the filesystem watchers back on by default.

Upstream's changes in this step, all absorbed:
- roll back the workspace trust-boundary hardening (MoonshotAI#4013): background
  git invocations no longer override repo-local git config, agent file
  tools no longer re-resolve paths through symlinks, and project-local
  local.toml applies without trust gating again
- turn filesystem watch back on by default (MoonshotAI#4015)
- sync the 2.1.0 changelog into the release notes (MoonshotAI#4006)
- release packages (MoonshotAI#4016)

Fork behaviour that had to survive:
- the fork's node-local → host rename: the test files the revert touches
  keep importing `#/os/backends/host/...`
- the fork's inline media reading: the ReadTool-based symlink-escape test
  goes away with the guard it covered, and the retired ReadMediaFileTool
  stays retired
- the fork's i18n: the revert restores no user-facing strings, so no new
  locale keys are needed
- the fork's Windows-safe test cleanup and its own workspace and alias
  test additions stay in place

Verified: typecheck clean across every package and app; full suite
17764 passed / 0 failed / 81 skipped / 1 todo, plus kimi-inspect's own
115 tests; lint 0 errors.
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.

4 participants