Skip to content

Epic: Screen repo-detected command memories for injection content #291

Closed
2 of 2 issues completed
Closed

Description

@WhollyMindless

This is a possible behavior to investigate, not a confirmed bug. It came out of an AI-assisted local review of cb68647 (v0.15.21). I haven't shown any real-world impact, so please treat it as a lead and defer or close it as you see fit.

What I saw

detectPackageScripts builds npm run ${name} from each notable script key with no character check (src/init/detect.ts:90). Makefile and Justfile targets are limited to [A-Za-z0-9_-]+ (src/init/detect.ts:98).

Using the test harness with memory_init and a script key of test && echo SYNTHETIC:

  • Stored row: ... command: run "npm run test && echo SYNTHETIC" from the repo root (package.json). (src/init/run.ts:164)
  • Marking and screening: the row carries the tags init and package.json, so it gets no [via ...] marker (src/inject/format.ts:17). Init rows aren't passed through the quarantine scan that import uses.
  • Later sessions: a row like this was still injected after package.json changed. In a harness run it also appeared after switching away from the branch and in a second clone of the same remote.
  • Effect on the real command: this depended on the key text. Short keys such as test && x and test; x kept the plain npm run test row from being written (superseded_overlap). test && echo SYNTHETIC did not.
  • Recovery: after memory_forget removed these rows, re-running init refused the plain row (previously_rejected), and force didn't change that. A viewer un-reject let it through again.
  • Rendered string: run in a shell with real npm and a harmless marker, the rendered text ran a second command. Quoting the key ran only that script.

What is not established

  • The plugin never executes these strings. No model was run, so nothing shows a model acting on them.
  • It needs someone to run memory_init or /repo-init on a checkout containing such a key. It isn't automatic.
  • The injected block is framed as reference data, not instructions.
  • A repo that can edit package.json already controls its npm scripts and AGENTS.md on that checkout. The open question is whether keeping the text after leaving that branch matters in practice.
  • Everything ran on Windows through the test harness with a fake host.

If it's worth changing

Reusing the Makefile character class for script keys, or scanning init rows the way import does, might be enough. That's your call.

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    bug
    severity:medium
    store-security
    on Nov 4, 2026
  2. added
    agent:ready
    on Nov 4, 2026
  3. abogartz commented on Nov 4, 2026

    @abogartz
    Owner

    osi-spec-hash: 531145ba4585be8b 2026-11-04T18:37:28Z - acceptance criteria frozen at this text. A later edit to the body changes this hash, and the reviewer will withhold approval until a maintainer replies spec ok.

  4. added
    spec:incomplete
    on Nov 4, 2026
  5. ocsi-triager commented on Nov 4, 2026

    @ocsi-triager

    Not agent-ready: the ticket is an investigation lead with no measurable acceptance criterion — "might be enough. That's your call" leaves a machine unable to tell done from not-done. Either add it or close this.

  6. added
    agent:analysis
    on Nov 4, 2026
  7. added
    architect:working
    and removed
    agent:analysis
    on Nov 4, 2026
  8. changed the title [-]Possible behavior to investigate: package.json script names stored as command memories without a character check[/-] [+]Epic: Screen repo-detected command memories for injection content[/+] on Nov 4, 2026
  9. ocsi-architect commented on Nov 4, 2026

    @ocsi-architect

    Architect verdict: PASS — decomposed into 2 draft tickets.

    Verified against main at sha 7405dc61d919e7eee7033dea6e4324eda58ee669 (v0.15.33). The lead reproduces from the code: the asymmetry and the unscreened write path are both still present.

    PROBLEM — A user who runs memory_init on a checkout with a crafted package.json script key (e.g. test && echo SYNTHETIC) gets a command memory containing shell metacharacters, injected into every later session with no [via ...] marker, surviving the branch and clone the key came from.

    COST — Two tickets, three files (src/init/detect.ts, src/init/run.ts, test/init.test.ts), small review cycles. Proportionate: the fix is tiny, reuses existing mechanisms, and closes a gap on the store's trust boundary.

    COMPLEXITY — Adds no machinery: ticket 1 reuses the [A-Za-z0-9_-]+ class already enforced at src/init/detect.ts:98; ticket 2 reuses quarantineCandidate already called by capture (src/capture/runtime.ts:268) and import (src/portable/import.ts:86). It removes an inconsistency rather than adding a moving part.

    DOWNSIDE OF AS-IS — The package.json detector keeps storing crafted keys verbatim (src/init/detect.ts:90, only isNotable at :88), and init stays the one capture path with no quarantine screening. Real execution still needs a model to obey the injected block, so the gap is narrow but ongoing hygiene on a documented boundary.

    Feasibility: REAL (quotes above), DECOMPOSABLE (2 tickets, RED/GREEN each), SIZED (≤3 files each), IN-SCOPE (no workflows/rulesets/secrets), DECIDED (no open design question inside scope — whether init rows should also carry a [via init] provenance marker is deliberately out of scope; neither ticket depends on it).

    Children:

    Tickets are drafts: label one agent:ready when you want it built.

  10. added
    architect:done
    and removed
    architect:working
    on Nov 4, 2026
  11. removed
    agent:ready
    on Nov 4, 2026
  12. ocsi-triager commented on Nov 5, 2026

    @ocsi-triager

    All 2 sub-issues closed as completed: #301, #302. Closing the epic.

  13. ocsi-triager commented on Nov 5, 2026

    @ocsi-triager

    Reopening: closed in error by ocsi-triager. Sub-issues #301 and #302 are both OPEN (completed 0/2), so the close condition was not met. No action needed from maintainers.

  14. abogartz commented on Nov 9, 2026

    @abogartz
    Owner

    Both suggested changes are now implemented, so this is done.

    Both close when their PRs merge. What this report established — that a repo-derived row could reach the prompt with no provenance marker and no screening — is the part worth keeping, and it is now covered by a test in each PR.

    Two of your "not established" points still stand and are why this stays a hardening change rather than a fix for a live problem: the plugin never executes these strings, and it needs someone to run init on a hostile checkout.

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

    architect:donebugseverity:mediumspec:incompletestore-security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions