fix(memory_engine): guard RAVEN_HOME in project skill roots

Aperta
#1,388 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pcbeingused333 ci sta già lavorando.

Dal 21/11/2026.

  • #1390 di @pcbeingused333 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, security

Direzione di ricerca

Start in raven/memory_engine/skill_forge/project_skills.py, where guarded and excluded are built in project_skill_roots and read_project_skills calls _is_guarded before build_skill_meta. Reproduce the leak with a test in tests/test_skill_forge_project_skills.py: a repo containing RAVEN_HOME, a SKILL.md symlinked to config.json, and an agent_home outside RAVEN_HOME. Done means the secret content no longer appears in SkillMeta. Linked PR #1390 is already open against this issue, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug security

What happens

project_skill_roots protects two trees from being read as project skills:

  • guarded = (home/.agents, agent_home) -- checked when a SKILL.md is read
  • excluded = {home, agent_home, *agent_home.parents} -- directories that may not become the git-root boundary

RAVEN_HOME (default ~/.raven, from raven.home.raven_home()) is not in guarded. It is covered only indirectly, as a parent of the default agent_home (RAVEN_HOME/workspace), through the unconditional *agent_home.parents set.

agents.defaults.workspace accepts any path and is not validated against RAVEN_HOME: Config.workspace_path uses an explicitly configured value as written. When that workspace points outside RAVEN_HOME, nothing keeps RAVEN_HOME out of the boundary search or out of the guarded check. A repository that contains RAVEN_HOME then becomes the git-root boundary, and a project skill whose SKILL.md symlinks to <RAVEN_HOME>/config.json is read as a project skill. That file holds provider API keys.

Reproduction

Layout:

repo/.git
repo/.raven/config.json      <- RAVEN_HOME, holds provider keys
repo/src/                    <- the turn's workdir
repo/src/.agents/skills/setup/SKILL.md -> repo/.raven/config.json
# agents.defaults.workspace (agent_home) configured outside the repo

repo/.raven/config.json held {"providers": {"openai": {"api_key": "sk-SECRET"}}} (a fake value).

Against the current main:

roots = project_skill_roots(src, agent_home=agent_home_outside, home=userhome)
# ProjectRoots(dirs=(.../repo/src/.agents/skills,), boundary=.../repo,
#              guarded=(.../userhome/.agents, .../agent_home_outside))
metas = read_project_skills(roots)
# SkillMeta(name='setup', source='project',
#           content='{"providers": {"openai": {"api_key": "sk-SECRET"}}}')

_format_skill_text(meta) returns the secret, so it reaches the BM25 index and every search or injection path built on it.

The same layout with the default agent_home (RAVEN_HOME/workspace) does not leak: repo is in excluded through agent_home.parents, git_root is dropped, boundary becomes src, and the symlinked SKILL.md resolves outside the boundary. The leak is triggered by the workspace setting, not by the skill layout.

A sibling layout leaks the same way: a checkout that contains the home, with the workdir outside it and agent_home outside RAVEN_HOME.

Why this is not #1354

#1354 stops a git root above the user's home from becoming the skill boundary. It does not address RAVEN_HOME.

guarded and excluded are identical on origin/main and on the branch checked here, and the leak reproduces with neither of #1354's changes applied. It is a pre-existing gap, not a regression from that PR.

Suggested fix

Add RAVEN_HOME directly to guarded:

  1. The payload is stopped at read time: read_project_skills calls _is_guarded(skill_file, roots.guarded) before build_skill_meta, so a symlink that leaves the project cannot resolve to the config file.
  2. With RAVEN_HOME guarded, the unconditional *agent_home_r.parents exclusion can be relaxed: the conservative trade-off where a checkout that contains the agent home collects no repository skills is no longer needed to keep RAVEN_HOME out.
  3. This also closes the workspace-configured-outside-RAVEN_HOME surface.

Implementation notes:

  • ProjectSkills.__init__ must receive raven_home(); today it only carries agent_home, and roots() calls project_skill_roots(workdir, agent_home=...) with home defaulting to None.
  • guarded is process-stable, so adding it to the cache key carries little semantic risk (_cache_key currently keys on dirs plus boundary).
  • Assembly points: raven/agent/loop/wiring.py:1525 and raven/context_engine/factory.py:292.

Files

  • raven/memory_engine/skill_forge/project_skills.py -- guarded at :65, excluded at :66, ProjectSkills at :295
  • raven/agent/loop/wiring.py:1525 and raven/context_engine/factory.py:292 -- assembly points that need raven_home() passed in
  • tests/test_skill_forge_project_skills.py -- add a payload test for the workspace-outside-RAVEN_HOME layout
Lingua principale
Python
Stelle
4.1k
Fork
94
Merge medio
2g 7h
PR unite (30g)
216

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di EverMind-AI/Raven

Tutte le issue di EverMind-AI/Raven

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.