Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Missing output encoding in `delete_json_doc`: `id` is echoed raw in the confirmation message

Aperta Adatta ai principianti
#6 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Ambito
database, security

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

  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 fireproof-storage/mcp-database-server

Tutte le issue di fireproof-storage/mcp-database-server

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.