MCP run_cypher guard misses a write keyword glued to a number
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python, typescript
- Ambito
- backend-api-design, security
Direzione di ricerca
Leggi src/selfgraph/mcp/server.py attorno a _WRITE_CLAUSE e i relativi test, poi controlla la protezione corrispondente in typescript/src/mcp.ts. Riproduci i casi con valori letterali numerici dell’issue e conferma che entrambe le protezioni li rifiutino con read_only_query, mentre le normali query di sola lettura continuano a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The MCP run_cypher tool is meant to be read-only, but a write clause that directly follows a numeric literal, with no space in between, gets past _is_blocked_query. Kuzu still parses the query as two clauses and runs the write. The tool returns an empty result and the store is changed.
Reproduction (Python 0.2.2, Kuzu backend)
from selfgraph.mcp import server as srv
srv._is_blocked_query("MATCH (n:N) WHERE 1=1DELETE n") # False
await srv.run_cypher("MATCH ()-[r:R]->() WHERE 1=1DELETE r") # deletes every edge
await srv.run_cypher("MATCH (n:N) WHERE 1=1DELETE n") # deletes every node
await srv.run_cypher("UNWIND [1] AS x WITH x LIMIT 1CREATE (:N {pk: 'evil', ns: 'x'})") # creates a node
await srv.run_cypher("MATCH (n:N) WITH n LIMIT 1000SET n.doc = 'x'") # overwrites every stored doc
await srv.run_cypher("MATCH (n:N) WITH n LIMIT 1000MERGE (:N {pk: 'x'})")
Each call returns {"columns": [], "rows": [], ...}. A count before and after shows the nodes and edges are gone, or the new node exists.
Cause
_WRITE_CLAUSE in src/selfgraph/mcp/server.py:48-53 matches \b(CREATE|...|DELETE|SET|...)\b. A digit and a letter are both word characters, so there is no \b between 1 and DELETE, and the keyword is never matched. Kuzu's lexer ends the integer literal at the digit and reads DELETE as a keyword, and the openCypher grammar allows clauses with no space between them. Any clause that can end in a number works as a carrier: WHERE ... = 1, LIMIT n, SKIP n, WITH ..., 1 AS one LIMIT 1.
This is not the 1. DELETE form from #213. That form does not parse on Kuzu, and this one does.
The TypeScript guard uses the same boundary over PY_WORD_CLASS (typescript/src/mcp.ts:41-47).
Expected
run_cypher rejects these queries with read_only_query.
Suggested fix
Treat a keyword that follows a digit as a separate token. For example, use a lookbehind that rejects only a preceding letter or underscore, or insert a space between a digit run and a following letter before the scan.
- Lingua principale
- TypeScript
- Stelle
- 173
- Fork
- 58
- Merge medio
- 6h
- PR unite (30g)
- 120
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hydra-db/selfgraph#401 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: store bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#398 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
hydra-db/selfgraph#392 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: parity area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hydra-db/selfgraph#391 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hydra-db/selfgraph
Issue simili
-
parity: scripting.net's net-http row fails on macOS with errno 61 where the BDS golden has 111ApertaBug Tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
JSPrismarine/JSPrismarine#3384 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
zingolabs/zingo-mobile#1951 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Automattic/data-liberation-agent#2175 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
xdelmo/Portfolio-minimal#613 ·
I maintainer di solito rispondono entro 1 giorno
-
backend documentation low-priority Stellar Wave
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Savitura/Savitools#611 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni