Missing output encoding in `delete_json_doc`: `id` is echoed raw in the confirmation message
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Il codice rilevante è il caso delete_json_doc in src/index.ts, intorno alle righe 120-132. Leggi come id viene preso da request.params.arguments e perché il controllo !id fallisce dopo String(...). Poi verifica i casi load_json_doc e query_json_docs, che secondo la segnalazione seguono lo stesso schema. Il lavoro è completo quando un id mancante o malformato viene rifiutato prima di db.del e il testo di conferma codifica l'ID invece di ripeterlo grezzo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tool: delete_json_doc · Tested commit: 605dbb7
Weakness: CWE-79 Cross-site Scripting / unescaped output
Summary
delete_json_doc deletes a document from the Fireproof json_docs database and replies Deleted document with ID: <id>, with the caller's id inserted verbatim. The ID is not validated or escaped, so markup or control characters in it come back unchanged. This only matters if a client renders tool output as HTML or Markdown, but the fix is small.
Details
src/index.ts:120-132:
case "delete_json_doc": {
const id = String(request.params.arguments?.id);
if (!id) {
throw new Error("ID is required");
}
await db.del(id);
return {
content: [{
type: "text",
text: `Deleted document with ID: ${id}`
}]
};
}
There is no check on the ID's format and no encoding of the echoed value. Two related details: String(undefined) is the string "undefined", so the !id guard never fires when id is missing; and the reply says "Deleted" whether or not a document with that ID existed.
Impact
The id argument is chosen by the model and can be steered by prompt injection, and the echoed text goes back to the client. In clients that show tool results as plain text nothing happens. A client or UI that renders tool output as HTML or Markdown without escaping would render the caller's markup. Severity is low; this is a hardening issue in a demo server.
Suggested fix
Validate the ID before use (for example typeof id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(id), matching the IDs Fireproof generates), fix the missing-argument check by testing the raw argument before String(...), and return the ID JSON-encoded, for example Deleted document with ID: ${JSON.stringify(id)}. The same pattern applies to load_json_doc and query_json_docs.
- Lingua principale
- JavaScript
- Stelle
- 31
- Fork
- 10
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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
- 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 fireproof-storage/mcp-database-server
-
problem with cloud buildForse di nuovo libera @necrodome l’ha presa 664 giorni fa e non c’è nessuna pull request aperta. Aperta
fireproof-storage/mcp-database-server#1 · 8 commenti · 1 assegnatario ·
Tutte le issue di fireproof-storage/mcp-database-server
Issue simili
-
Four problem loader browser tests fail on WindowsForse già presa @Patriciaath999 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
juice-shop/juice-shop#3686 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ScottKirvan/GOMAC#56 ·
-
area:install bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
yetone/magpie#2406 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno