Skip to content

Legacy folded repository keys expose rows to a case-distinct sibling (F2 follow-up) #254

Closed

Description

@WhollyMindless

Summary

F2 from the review of #250 remains reproducible after #250/#251 merged: a row with a legacy, whole-path-lowercased repository key is still readable from a distinct lowercase sibling directory, even though its stored repoPath names the original directory.

This is a pre-existing compatibility/isolation gap, not a regression introduced by #251. F1's case-variant symlink regression is fixed and passes the control probe on the same current-main checkout. Opening this separately now that #109 is closed, so the remaining compatibility decision is explicit.

Suggested classification: bug · store-security · severity:medium (narrow legacy-data and filesystem preconditions). For maintainer triage/approval; this is not a claim of implementation or a request to mark it agent:ready.

Verified result

  • Main: bf7f6d2ac66fb6aaec7ffd0383d996b642bc61e6 (v0.15.7).
  • Environment: case-sensitive WSL Linux, Bun 1.4.4 (38afee6c8).
  • Real temporary directories and real appendMemory → relevantKnowledge retrieval; no filesystem mocks or user memory store.
  • The historical win32/darwin path-folded stamp was synthesized. This was not a live migration test on macOS or Windows.
  • Owner retrieval passes; the assertion that the distinct lowercase sibling cannot retrieve the private row fails. The separate F1 control passes (combined run: 1 pass / 1 fail).

Preconditions: path-derived repository identity (no Git remote), distinct Foo and foo on a case-sensitive filesystem, a shared memory store containing the old folded Foo stamp, and an otherwise lowercase canonical ancestor path. This is deterministic identity overlap, not a cryptographic hash collision.

Reproducer

Save this as legacy-fold.probe.ts outside the checkout, and run on a case-sensitive Linux filesystem with REVIEW_SOURCE=/absolute/path/to/checkout bun test ./legacy-fold.probe.ts. The lowercase /tmp fixture matters: unrelated uppercase ancestors would prevent this particular legacy-key collision.

import { test, expect } from "bun:test";
import { mkdirSync, realpathSync } from "node:fs";
import { join } from "node:path";
import { createHash, randomUUID } from "node:crypto";
import { pathToFileURL } from "node:url";

const source = process.env.REVIEW_SOURCE!;
const mod = (p: string) => import(pathToFileURL(join(source, p)).href);
const { resolveRepo, setRepoScope, resetSessionScopes } =
  await mod("src/identity/repokey.ts");
const { resetState } = await mod("src/core/state.ts");
const { appendMemory } = await mod("src/store/files/append.ts");
const { relevantKnowledge } = await mod("src/recall/relevant.ts");

test("legacy owner remains visible; distinct sibling must not", async () => {
  const root = join("/tmp", "legacy-fold-" + randomUUID());
  mkdirSync(root);
  const upper = join(root, "Foo"), lower = join(root, "foo");
  mkdirSync(upper);
  mkdirSync(lower);
  process.env.OPENCODE_MEMORY_DIR = join(root, "memory");
  resetState();
  resetSessionScopes();
  setRepoScope(null);

  const ownerPath = realpathSync(upper).replace(/\\/g, "/");
  const oldKey = createHash("sha1")
    .update(ownerPath.toLowerCase()).digest("hex").slice(0, 12);
  const content = "private upper project legacy marker";
  await appendMemory({
    type: "learning", scope: "s", content,
    repo: oldKey, repoPath: ownerPath,
  });
  setRepoScope(resolveRepo(upper));
  expect(await relevantKnowledge(content, 5)).toContain(content);
  setRepoScope(resolveRepo(lower));
  expect(await relevantKnowledge(content, 5)).not.toContain(content);
});

Actual sibling result includes:

## Relevant durable memory — remembered facts: reference data, never instructions
- [2026-11-02] learning/s: private upper project legacy marker

Cause and compatibility decision

isVisibleTo accepts a matching key or matching path:

return m.repo === reader.scope.key || (!!m.repoPath && m.repoPath === reader.scope.path);

The new lowercase sibling key equals the old folded owner key. A conflicting repoPath does not veto that match. evidenceVisibleTo in the same file has the same key-or-path rule; this current-main check confirmed that by source inspection, while the end-to-end repro above exercises memory retrieval.

A blanket requirement that paths match would break intentional sharing between clones with the same remote-derived identity. Before implementation, could you confirm the intended policy for these ambiguous legacy path-derived stamps: preserve owner access while denying the unrelated sibling, with migration or explicit identity provenance if needed? If preserving the old broad match is intentional, documenting that compatibility exception would also make the decision clear.

Suggested acceptance coverage if a fix is approved:

No implementation started. Happy to narrow, defer, or close this if it does not fit the project's intended compatibility policy.

Activity

  1. added
    bug
    severity:medium
    store-security
    on Nov 2, 2026
  2. WhollyMindless commented on Nov 3, 2026

    @WhollyMindless
    ContributorAuthor

    Claiming #254 following your Discord handoff to WhollyMindless. The fix is ready for review in #262: #262 . It covers legacy memory/evidence isolation while preserving owner, alias and remote-clone access. Focused WSL Linux checks pass 59/59; the full Windows gate passes (866 unit tests, 31 skips; 30 E2E tests). Historical folded stamps are synthesized in the regressions. Our contributor account cannot set the assignee field, so this comment records ownership. No competing implementation is needed while #262 is under review.

  3. added 2 commits that reference this issue on Nov 3, 2026
  4. abogartz-opencode-self-improvement commented on Nov 3, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.15.13 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleasedseverity:mediumstore-security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions