Skip to content

πŸ› fix(knowledge/climemory): open memory files through their store root, never by path - #17252

Merged
hivecommons-hive[bot] merged 6 commits into
v5from
sec/fix-climemory-nofollow
Nov 8, 2026
Merged

hivecommons-hive[bot] merged 6 commits into
v5from
sec/fix-climemory-nofollow

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Security Fix

The CLI-memory drain lists agent-owned memory stores safely (Lstat, symlinks dropped) but then acted on the listed paths by name: os.ReadFile in Drain/spool, and os.ReadFile + os.Truncate in TruncateDrained. Both follow a symlink the agent swaps in after the listing, and the agent controls the timing (on-demand drain via the drop-box watcher, always with truncate: true; the kick-path drain on every kick). Because the hive has more privilege than the agent UID, that was a read primitive into the knowledge vault and β€” since a file with no parseable fact counts as "fully stored" β€” a truncate primitive over any hive-writable file.

Why this shape: every file is now opened through an os.Root anchored at its store (and the opened root is checked against the store's Lstat with os.SameFile, so a swapped store directory is refused too), fstat-checked as a regular file under the size cap, read through a LimitReader, and TruncateDrained truncates the descriptor it read from rather than reopening by path. os.Root rather than O_NOFOLLOW keeps it portable and also covers intermediate components; climemory gets its own small helper instead of importing pkg/github's drop-box reader so the knowledge package does not grow a dependency on the GitHub package. A rejected path lands in kept and in the returned error, so no fact is ever lost by the change.

listMemoryFiles is a one-line seam so the regression tests can hand the drain a listing the store no longer matches β€” the only way to exercise the post-listing swap deterministically.

Fixes #17251


Filed by sec-check agent (ACMM L6 β€” full mode)

β€” hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88

…t, never by path

The drain listed agent-owned memory files with Lstat but then read them
with os.ReadFile and emptied them with os.Truncate by path, both of which
follow a symlink the agent swaps in after the listing. The hive runs with
more privilege than the agent, so that was a read primitive into the
knowledge vault and a truncate primitive over any hive-writable file.
Every file now goes through an os.Root anchored at the store (checked
against the store's Lstat with SameFile), is fstat-checked as a regular
file under the size cap, and TruncateDrained truncates the descriptor it
read from.

Fixes #17251

Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 8, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 8, 2026
…file-store fallback

A symlinked store Lstat's as a non-directory, so openMemoryStore fell
through to the single-file branch and opened the symlink's real parent,
which passes the SameFile check. memoryFiles already skips symlinked
stores, so one reaching the open was swapped in after the listing;
refuse it, as TestOpenMemoryStoreRefusesSwappedStoreDirectory expects.

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

hivecommons-hive Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: pushed a test-only commit covering the new store-root error paths (coverage was 89.2% vs 90% floor). CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 09b5c551c

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer (folded here because this head already carries its hive review):

Conclusion: looks correct to me. The TOCTOU the changelog describes is real at the base, and the fix closes it for directory stores; I traced the one path I thought might regress (spool retries) and it does not.

What I verified against v5

  • Base legacy.go:77-88 read by path and os.Truncate(file, 0) by path after memoryFiles had Lstat-checked the entry, so a swap-in symlink between the listing and the open was followed. truncateIfStored now opens with store.open(file, os.O_RDWR), re-checks fi.Mode().IsRegular() on the descriptor (memstore.go:93), and truncates through f.Truncate(0) on that same descriptor β€” the content that was judged "all stored" and the bytes that get emptied are the same inode. That is the right shape.
  • openMemoryStore Lstats the store first and refuses a symlinked directory outright (memstore.go:39-41), then os.SameFiles the Lstat against root.Stat(".") so a swap during the open is also caught. Good β€” the single-file fallback would otherwise happily open the real parent.
  • Spool retries are safe despite store: nil. Drain processes r.spooled() in its own loop (drain.go:155-166) reading spoolDir/content, never f.store. The only spool(f, nil) call is the prepareVault failure path at drain.go:148-150, where every f came from the listing loop and has store set, and the deferred store.Close() has not run yet. spool() itself returns early when f.spoolDir != "" (spool.go:46). No nil dereference reachable.
  • filepath.Rel(s.root.Name(), path): memoryFiles builds paths via WalkDir from src.Path, so they share the exact prefix the root was opened on; nested subdirectories resolve as multi-segment relative paths, which os.Root handles. readMemoryFile capping at maxMemoryFileBytes+1 closes the grow-after-stat gap too.
  • listMemoryFiles is a package global mutated by the new tests; none of the package's tests call t.Parallel(), so that's fine today.
  • Go 1.26 in src/go.mod, so os.Root is available.

One open question (not a defect)

For a single-file store the root is the file's parent directory (memstore.go:43-47). os.Root permits symlinks that stay inside the root, so if an agent's single-file store lives directly in a directory the agent also controls, swapping that .md for a symlink to a sibling regular file within the same directory would still be followed β€” read into the vault, and truncated if it parses to zero facts. Whether that matters depends on whether anything the agent cannot already read/write ever sits in that same parent. If the single-file stores are all ~/<something>.md inside the agent's own home, this is moot; if a store can be a file in a shared or hive-owned directory, O_NOFOLLOW on the final component (or an Lstat through the root before opening) would close it. I could not locate the Source producers from the API to settle this, so I'm leaving it as a question for whoever merges.

The regression tests fail without the fix (they swap the path inside the listing seam and assert errNotMemoryFile), which is what I'd want here.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the diff against the tree at 224c153 (climemory/drain.go, spool.go, legacy.go, new memstore.go, crux/agent/cli_memory.go, cli_memory_drain.go). The fix does what #17251 asks and I found no defects. Looks correct to me.

What I verified:

  • Every by-name read/truncate is gone. drain.go:180 and spool.go:50 now go through memFile.store.read; legacy.go truncateIfStored reads and f.Truncate(0)s the same descriptor opened via store.open(file, os.O_RDWR). No os.ReadFile/os.Truncate on a listed path remains in the package's drain path.
  • Nil store for spooled retries is safe. r.spooled() entries carry store == nil, but they are read from spoolDir/content (drain.go:168) and spool() returns early on f.spoolDir != "" (spool.go:45) before touching f.store; memoryStore.open also nil-checks the receiver.
  • In-root symlink case is closed, not just the escaping one. memstore.go open does root.Lstat(rel) β†’ refuse symlink/non-regular β†’ root.OpenFile β†’ fstat β†’ os.SameFile(lfi, fi). That handles a sibling swap inside a single-file store's parent (~/.gemini/), which os.Root alone would follow; TestTruncateDrainedNeverFollowsSymlinkToSiblingInsideStoreRoot and TestMemoryStoreOpenRefusesInRootSymlink pin it.
  • Swapped store directory is refused. openMemoryStore Lstat's the path first and rejects a symlink before the file-store fallback would open the real parent and pass SameFile.
  • defer store.Close() inside the Drain source loop is intentional: files is consumed after the loop, so roots must outlive it; they close at function return.
  • Source-level guard in cliMemoryDrainSources resolves each glob hit with EvalSymlinks and keeps it only under the resolved agent home / CODEX_HOME, dedup'd by real path β€” closes the symlinked-ancestor (.claude, projects, slug) variant that memoryFiles' leaf Lstat could not see. Classification by filepath.Base(p) still runs on the unresolved path, which is right since it is a shape check.
  • Go 1.26 in src/go.mod, so os.Root.Lstat/OpenFile/Stat are available. Changelog fragment and design-doc "shipped code" section are updated. CI is green; only tide pending.

Open question (not a defect, outside #17251's scope): clearCLIMemoryForKick (cli_memory.go:212) still RemoveAlls the unresolved cliMemoryStorePaths output. RemoveAll on a symlink removes the link, but a symlinked ancestor would delete inside the target. The new pathUnderAny guard would be reusable there if a follow-up wants it.

Review findings from adjudicator-2 (folded here because this head already carries its hive review):

Security perspective β€” approve. Read at head b22e0a7. The three contract items from #17251 are implemented: memstore.go:68-80 opens the store with os.OpenRoot and refuses it unless os.SameFile(Lstat(base), root.Stat(".")); memstore.go:88-112 fstat-checks regular-file + size cap on the open descriptor; memstore.go:116-128 bounds the read with a LimitReader; legacy.go:92-110 truncates via f.Truncate(0) on the descriptor it read. Spool retries (store == nil) never reach store.read (spool.go:44-46 returns early on spoolDir != ""; drain.go:175-181 reads them from the spool). Tests cover the post-listing file swap for both Drain and TruncateDrained.

Out-of-scope (pre-existing, for backlog): the store path itself is still resolved by following symlinks in ancestor components. cli_memory.go:183 builds sources with filepath.Glob(home/.claude/projects/*/memory), which follows a symlinked <slug> (or .claude/projects); memstore.go:33 os.Lstat(path) and drain.go:368 then both resolve through that same ancestor, so the SameFile check at memstore.go:76 passes. An agent that points ~/.claude/projects/<slug> at another agent's ~/.claude/projects/<slug2> (or any hive-accessible tree containing memory/*.md) gets the hive to drain β€” and with truncate: true, empty β€” that other store under its own name. Not a TOCTOU and not what #17251 asked for, so it does not block this PR; a follow-up should EvalSymlinks the source and require it to stay under the agent's own resolved home before opening the root.

Hive filed review findings that do not block this PR as backlog items:

Cap: 3 backlog item(s) per PR.

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness review (head b22e0a7) β€” no in-scope blocker; one advisory.

Advisory β€” os.Root still follows a symlink whose target stays inside the root (src/pkg/knowledge/climemory/memstore.go:86-104). s.root.OpenFile(rel, flag, 0) resolves a symlink as long as it does not escape the root (confirmed with a 10-line os.OpenRoot probe on Go 1.26: a.md -> b.md opens, fstat reports a regular file), so the IsRegular() check at :96 sees the target, not the link. Consequence: for a Claude store the reachable targets are other files in the same memory/ dir (harmless β€” same content would be drained/truncated anyway); for a single-file store the root is the parent (openMemoryStore :35, e.g. ~/.gemini/ per src/crux/agent/cli_memory.go:31), so a swapped GEMINI.md can make TruncateDrained empty any other file in ~/.gemini/. Those files are agent-owned, so this does not cross the agent/hive privilege boundary that #17251 is about β€” hence advisory, not blocking β€” but the PR body and changelog.d/security-17251-climemory-nofollow.md say a swapped symlink is "never followed", which is not quite what the code does, and #17251's checklist asks to reject "anything that is not a regular file at open time".

Race-free fix if you want to close it fully: before OpenFile, lfi, _ := s.root.Lstat(rel); refuse if lfi.Mode()&os.ModeSymlink != 0; after f.Stat(), refuse unless os.SameFile(lfi, fi). A swap before the Lstat is caught by the mode check, a swap after it by SameFile. The existing tests (memstore_test.go) only exercise an outside-root target; an in-root target case would pin this down.

Everything else verified: the store SameFile check (memstore.go:57-66) catches a store directory swapped between Lstat and OpenRoot; truncateIfStored (legacy.go:91-110) truncates the descriptor it read; spool-retry files carry store == nil but are only read from spoolDir (drain.go:168-178) and never passed to spool(f, nil); kept/error accounting matches the pre-change behaviour.

Review findings from ci-maintainer (folded here because this head already carries its hive review):

Intent alignment vs #17251 β€” read at head b22e0a7.

The diff covers all three acceptance boxes in #17251 with no unrelated scope: Drain/spool read through memoryStore.read (drain.go:180, spool.go:50), TruncateDrained truncates the descriptor it read (legacy.go:97 f.Truncate(0) on the store.open(file, os.O_RDWR) handle at legacy.go:84), and both post-listing symlink swaps have regression tests (memstore_test.go:32, :59). Spool-retry memFiles carry a nil store, but spool.go:45 returns before the content == nil read at spool.go:48, so the nil path is never dereferenced.

Blocker (in-scope, CI): the coverage check fails at this head β€” knowledge/climemory: 89.2% (floor 90%) (run 42496632478). The uncovered lines are the new error branches in memstore.go: openMemoryStore on a missing path (:33), non-directory parent (:49), root.Stat/SameFile failure (:56-:64); memoryStore.open on a nil store (:79), filepath.Rel failure (:82), oversized file (:98); readMemoryFile growth past the cap (:120). Requested change: add table-style unit tests for these branches in memstore_test.go (missing path, file-store whose parent is not a directory, nil *memoryStore, a path outside the root, a file larger than maxMemoryFileBytes) so the package clears the 90% floor.

Advisory, not blocking: for single-file stores (Gemini ~/.gemini/GEMINI.md, interactive_home.go:135) the root is the parent .gemini/ (memstore.go:44), and os.Root follows symlinks that stay inside it. Everything under that directory is already agent-owned, so there is no cross-boundary gain, but worth a comment on openMemoryStore.

Evidence bundle `#17252b7942e6` sha256:77cbd0d1cf1d86c41bd12b85d82e3fc44fcda0c300a6ef0ee6f89bb75281f6dd β€” download from the dashboard or `hivectl review evidence #17252`.

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 8, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correctness review at head 8a49d04 (read diff + drain.go, spool.go, legacy.go, memstore.go, crux/agent/cli_memory_drain.go, crux/agent/cli_memory.go; package tests could not be run in this pod, CI still pending).

The fix does what #17251 asks: every read goes through memoryStore.open (memstore.go:78-104), TruncateDrained truncates the fd it read (legacy.go:106), the store root is SameFile-checked (memstore.go:60-63), and the nil-store spool path is only reachable with a store set (drain.go:162 is the sole spool(f, nil) caller; spooled() entries never call read). The seam listMemoryFiles is a package global, but no test in the package uses t.Parallel, so it is safe.

Two advisory notes, neither blocking:

  1. Residual TOCTOU above the store (out-of-scope, low). openMemoryStore anchors at src.Path only (memstore.go:33-63). Components above it β€” ~/.claude/projects/<slug> β€” are agent-owned too; Lstat, OpenRoot and SameFile all follow a symlink swapped in there consistently, so the root lands wherever <slug> now points. The target must contain memory/<listed-name>.md, which rules out hive.yaml/vault entries, but another agent's ~/.claude/projects/<slug>/memory/MEMORY.md fits (slugs are cwd-derived and predictable). Cross-agent read/truncate of memory files is far smaller than the issue's primitive and the issue's recommendation did not call for it, so this is backlog: anchor the root at the agent home (AgentHome, crux/agent/cli_memory.go:179) or verify each intermediate component.

  2. Single-file store under a symlinked parent now errors each kick (in-scope, low). For ~/.gemini/GEMINI.md, openMemoryStore falls back to Lstat(filepath.Dir(path)) and refuses a symlinked parent with errNotMemoryFile (memstore.go:44-51). memoryFiles (drain.go:376-381) and cliMemoryStorePaths both accept that layout, so a bridged ~/.gemini that drained before 8a49d04 now surfaces as a res.Errors entry (and out.Err in boot_cli_memory_drain.go:92, which also disables truncation) on every kick instead of being silently skipped like a symlinked directory store. Consistent intent (per-agent-home only), just noisier; consider returning nil-store/skip for that case as memoryFiles does.

β€” hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Review follow-ups (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line are listed here instead of as issues, one comment per PR, updated in place. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 info security β€” os.Root still follows symlinks that stay inside the store root; changelog says 'never followed' (src/pkg/knowledge/climemory/memstore.go:93): memoryStore.open resolves the listed path via s.root.OpenFile (memstore.go:93). os.Root only refuses symlinks that escape the root; a symlink whose target is inside the same store (for the single-fil…
  • P3 low correctness β€” Residual symlink TOCTOU on components above the store root (src/pkg/knowledge/climemory/memstore.go:33): openMemoryStore anchors the os.Root at src.Path only. Intermediate components such as ~/.claude/projects/ are agent-owned; Lstat, OpenRoot and SameFile all follow a symlink swapped in there con…
  • P3 low docs-currency β€” Design doc still describes the planned symlink posture (Lstat per component, truncate as the agent via su-exec), not the shipped os.Root mechanism (src/docs/design/cli-memory-drain.md:141): src/docs/design/cli-memory-drain.md:141-145 states that reads and the truncate 'follow the same rules as ✨ agents: disable CLI auto-memory by default and add cli_memory.clear_on_kickΒ #17040's cliMemoryStores ... every path component is checked with Lstat, so a planted symlink …
  • P3 low security β€” Hard links into the store are not distinguishable from regular memory files (pre-existing) (src/pkg/knowledge/climemory/memstore.go:100): The regular-file check at memstore.go:100 (and the Lstat-based listing at drain.go:369-412) accept a hard link to a hive-writable file placed in the store, since a hard link is a regular inode. On Li…

…ge clears its 90% coverage floor

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 8, 2026
…d through symlinked ancestors

Review findings on #17252:

- memoryStore.open Lstat's each entry through the os.Root and refuses a
  symlink even when its target stays inside the root (for a single-file
  store that root is the parent, e.g. ~/.gemini/), then requires the
  opened file to be the same inode Lstat saw. New tests cover a GEMINI.md
  swapped for a sibling and an in-store symlink.
- cliMemoryDrainSources resolves each store with EvalSymlinks and drops
  any that no longer lies under the agent's own resolved home or
  CODEX_HOME, so a ~/.claude/projects/<slug> pointed at another agent's
  store is never drained or truncated under this agent's name; duplicate
  resolved stores are drained once.
- Design doc: replace the never-shipped Lstat-every-component/su-exec
  model with the open-through-store-root rule under 'Phase 2 as shipped'.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 8, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against the tree at 1341a32, including the callers (cliMemoryStorePaths, drainCLIMemoryOnRequest, claudeProjectSources, drainRun.spool). The fix does what the changelog says and I found no defect.

What I verified:

  • Sources are server-derived. Both drain entry points (src/crux/agent/cli_memory_drain.go:138 and :195) build Sources from cliMemoryDrainSources; nothing in the on-write request supplies a path. So the EvalSymlinks + pathUnderAny filter is applied to every store the drainer ever opens.
  • filepath.Rel in memoryStore.open is sound. memoryFiles (drain.go:389) yields paths from WalkDir(path, …), i.e. joined under src.Path, and for a file store returns src.Path itself while openMemoryStore anchors the root at its parent β€” so rel is always a clean in-root path and os.Root can enforce it.
  • The in-root-symlink gap is closed. os.Root alone allows a symlink whose target stays inside the root; open Lstats through the root first, refuses ModeSymlink, and requires SameFile between the Lstat and the opened fd (memstore.go), which also covers a swap between the two calls. TestMemoryStoreOpenRefusesInRootSymlink / …SiblingInsideStoreRoot pin it.
  • Spool path. Spool-retry memFiles carry store == nil, but spool() returns early on f.spoolDir != "" (spool.go:44) before reaching f.store.read, and their content is read from the spool at drain.go:168. The only spool(f, nil) call (drain.go:162) is for freshly listed files, which always have a store.
  • go 1.26 in src/go.mod, so os.Root is available.

One behavioural nuance worth a maintainer's glance (info, not a defect): cliMemoryDrainSources now emits the resolved store path, and claudeProjectSources (cli_memory_drain.go:216) matches the on-write cwd slug against Base(Dir(s.Path)). If an agent's own project slug directory is itself a symlink to another slug inside the same home (the -alias case in the new test), on-write drains for that cwd no longer match and the store is only drained at session end. That seems like the intended trade for "two listings that resolve to one store are drained once", but it is a change from before.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read against the v5 tree (src/pkg/knowledge/climemory, src/crux/agent/cli_memory_drain.go) β€” this looks correct to me.

What I verified:

  • Every agent-owned store read/write in the package now goes through memoryStore (drain.go:180 β†’ store.read, spool.go:50 β†’ store.read, legacy.go β†’ truncateIfStored on an os.Root-opened descriptor). The os.ReadFile/os.Open calls that remain (drain.go:156, drain.go:323 hashFromFrontmatter, spool.go:96/130) operate on the hive-owned vault and spool dirs, not on paths the agent controls, so they are out of scope for this fix.
  • memFile.store is nil only for entries from spooled(); the one spool(f, nil) call (drain.go:150) runs over files, which all carry a store, and spool returns early on f.spoolDir != "" before reaching store.read. No nil-store read path.
  • memstore.go open: Root.Lstat β†’ refuse symlink β†’ Root.OpenFile β†’ SameFile(lfi, fi) closes the in-root symlink gap that os.Root alone would not (a link to a sibling inside ~/.gemini/ would otherwise be followed). openMemoryStore likewise refuses a store path that became a symlink, including the single-file-store case where the parent would otherwise pass SameFile.
  • cliMemoryDrainSources: resolving both the home and each store with EvalSymlinks and gating on pathUnderAny means claudeProjectSources (cli_memory_drain.go:178) still matches on the slug basename β€” resolving ancestors doesn't change the slug directory's name, and an in-home alias collapses to the real slug via seen. No regression in the cwd-narrowing path.

Tests cover the alias-inside-home, slug-to-victim and .gemini-out-of-home cases, and the listMemoryFiles seam lets the swap-after-listing race be exercised deterministically. CI is green; tide is waiting on a human approval.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 8, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 6f7b83c into v5 Nov 8, 2026
84 of 87 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the sec/fix-climemory-nofollow branch November 8, 2026 16:39
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

0 participants