engram
- Type
- Plugin
- Scanned
- Nov 17, 2026
- Version
- 0590eb8f0086
- Files read
- 126
Engram is a multi-platform AI coding agent plugin that tutors you on any topic using first-principles concept maps, blind-graded free recall, interactive local HTML pages, and spaced-repetition scheduling. Its biggest risk is in its OpenCode integration and skill startup scripts, which can be tricked into running untrusted Python code from a cloned repository via automatically installed Git filters or working-directory path lookups.
What it can reach
- Files
- Reads and writes learning state, concept graphs, grade receipts, and HTML artifacts in ~/.claude/learning (or ENGRAM_HOME); on OpenCode, extracts plugin files into ~/.config/opencode or .opencode/, updates AGENTS.md, and edits .git/config, .git/info/attributes, and .git/info/exclude.
- Shell commands
- Hooks and skills run python3 scripts/engram.py, subagents execute code/math verification or isolated pi -p grading runs, OpenCode hooks inject ENGRAM_ROOT and OPENCODE_PLUGIN_ROOT into shell sessions, and /coach contribute runs gh commands on explicit user consent.
- Network
- The core Python engine has no network code, but the curriculum-architect subagent searches and fetches web pages for the user's chosen topic, and /coach contribute posts text-stripped statistics to GitHub Discussions via gh only after explicit confirmation.
- Browser
- Opens locally generated HTML dashboards and interactive explorables using open, xdg-open, or explorer.exe when requested.
Findings
-
CriticalAutomatic Git filter installation executes untrusted scripts from cloned repositories or PR branches
.opencode-plugin/install.ts:537
When Engram is installed in OpenCode and the user opens a repository containing an opencode.json file, selfExtract copies missing files into .opencode/ without overwriting any existing files, modifies AGENTS.md on disk, and writes a [filter "engram"] clean and smudge configuration into .git/config that executes python3 .opencode/scripts/opencode-engram-clean and .opencode/scripts/opencode-engram-smudge relative to the repository root. If a stranger's repository (or a checked-out pull request branch) supplies its own script at .opencode/scripts/opencode-engram-clean alongside opencode.json and a tracked AGENTS.md, copyMissing leaves the attacker's script untouched and the next git status, git diff, or git checkout runs the attacker's code automatically with no AI interaction.
Fix: Never point .git/config clean or smudge filters at relative paths inside the Git working tree; reference the immutable installed package directory (or a user-owned global config path) instead, and do not preserve untrusted pre-existing executables in .opencode/scripts/.
-
HighWorkspace .opencode directory hijacks OPENCODE_PLUGIN_ROOT and ENGRAM_ROOT in OpenCode shells
OpenCode's shell.env hook (and the equivalent shell create.before hook in .opencode-plugin/v2.ts) sets OPENCODE_PLUGIN_ROOT and ENGRAM_ROOT to {cwd}/.opencode whenever {cwd}/opencode.json(c) and {cwd}/.opencode/scripts/engram.py exist. Because copyMissing in install.ts never overwrites existing files (and emits no update warning on a first extract or when a committed .engram-version.jsonc matches the installed version), opening an untrusted project directory that contains opencode.json and a malicious .opencode/scripts/engram.py redirects all Engram skill commands (/learn, /review, /coach) to execute the untrusted workspace's script instead of the installed package's engine.
Fix: Set ENGRAM_ROOT and OPENCODE_PLUGIN_ROOT to the trusted packageRoot where the plugin is installed rather than preferring a workspace-local .opencode/scripts/engram.py.
-
HighSkill engine-resolution waterfall runs $PWD/scripts/engram.py before ~/.agents/engram
In skills/learn/SKILL.md, skills/review/SKILL.md, skills/coach/SKILL.md, and agents/engram-artifact-smith.md, the mandatory engine-resolution loop checks "$PWD" and "$(git rev-parse --show-toplevel 2>/dev/null)" ahead of "$HOME/.agents/engram". On platforms where Engram is installed via the ~/.agents/engram clone or skills-only symlinks with no plugin-root environment variable set (such as DeepSeek Harness, ZCode Route B, and Codex Route B), running /learn, /review, or /coach while inside a cloned untrusted repository that contains scripts/engram.py causes the skill to execute the untrusted repository's script and load subagent instructions from $PWD/agents/.
Fix: Remove "$PWD" and "$(git rev-parse --show-toplevel)" from the automatic waterfall (relying on explicit ENGRAM_ROOT for local development checkouts), or place all trusted user-home install paths ahead of any working-directory fallback.
-
LowBlind assessor subagent omits tools restriction in frontmatter
Unlike agents/engram-curriculum-architect.md and agents/engram-artifact-smith.md, agents/engram-assessor.md omits the tools frontmatter field (even though its Codex port sets sandbox_mode = "read-only"). In Claude Code and OpenCode V1, omitting tools grants the subagent every tool available to the parent session (including file writes, edits, web fetches, and MCP tools), increasing impact if prompt injection reaches the grader via untrusted curriculum or problem text.
Fix: Add an explicit minimal tools allowlist in agents/engram-assessor.md frontmatter (and corresponding permissions in OpenCode V2) limited to what grading actually requires.
-
LowPredictable session deduplication file in shared /tmp without symlink or clobber guards
hooks/session-start-hermes.sh:48
The optional Hermes hook writes an empty deduplication marker to ${TMPDIR:-/tmp}/engram-nudge-${session_id} using shell redirection (: > "$marker") after checking [ -e "$marker" ]. On multi-user systems where TMPDIR defaults to world-writable /tmp, another local user can pre-create markers to silence session nudges or, if kernel fs.protected_symlinks is disabled, plant a dangling symlink that passes [ ! -e "$marker" ] and causes the hook to create an empty file at the symlink target.
Fix: Place the session marker inside the user-owned Engram state directory (${ENGRAM_HOME:-$HOME/.claude/learning}) and create it atomically with noclobber (set -C).
