Proteggere un assistente IA e RAG con permessi fuori dal prompt
Crea un gateway con isolamento dei clienti, permessi sui documenti e budget delle chiamate. Otto test locali e prompt inglesi.

Inizia qui: a cosa serve la guida
Un documento ordina di ignorare regole e inviare dati altrui: iniezione indiretta. Un prompt forte non sostituisce permessi esterni. Il gateway decide documenti, usa identità affidabile e limita chiamate, senza LLM reale o strumenti di scrittura. I test provano la politica, non resistenza universale del modello.
Un esempio concreto
La risposta illustra il formato atteso, non un audit della tua applicazione. Segui i passaggi e confronta file, test e risultati reali. Se l’assistente dice soltanto di aver finito, chiedi il risultato concreto, le prove e cosa resta da verificare.
Proposal: read_document for a document belonging to another tenant.
Decision: denied by server policy, regardless of the document instruction.
Proposal: delete_records.
Decision: denied; this gateway exposes no write operation.L’obiettivo
Un assistente può leggere un documento contenente istruzioni. L’applicazione deve comunque decidere quali dati e strumenti l’utente può usare. Il laboratorio impone un gateway di lettura senza chiamare LLM o servizi esterni.
1. Definire il perimetro
Estrai lo ZIP in una nuova cartella e usa Node.js 22 o successivo. Documenti, identità e risposte proposte sono fittizi. In un servizio reale identità e permessi provengono dal server, non da documenti caricati o argomenti del modello.
2. Eseguire il laboratorio locale
Esegui otto test: lettura permessa, altro cliente, permesso mancante, scrittura vietata, identità falsificata, istruzione nel documento, budget e configurazione non valida. Il testo viene restituito come dato, senza eseguirlo.
node --version
node --test lab.test.mjs3. Chiedere prove all’IA
Il primo prompt chiede di mappare i confini di fiducia. La similarità vettoriale non è un permesso. I test verificano una politica deterministica, non la resistenza completa di un modello reale.
Review this LOCAL AI/RAG boundary lab. No real model or external service is
connected. Read lab.mjs and lab.test.mjs. Identify trusted actor and ACL metadata,
untrusted document text, proposed model tool calls and the execution budget. Test
whether a document instruction, forged tenant field or unknown write tool could
bypass the gateway. Do not treat a system prompt, an opaque document ID, a vector
search score or a model’s user_confirmed flag as authorization. Produce evidence and
remaining integration requirements, not a claim of complete prompt-injection
resistance.4. Verificare la correzione
Il secondo prompt delimita una modifica e un test di regressione. Mantieni autorizzazione e validazione degli argomenti fuori dal modello. Chiedere di ignorare le istruzioni del documento non impone un controllo d’accesso.
Implement only the agreed local gateway improvement and add a regression test. Keep
authorization and argument validation in server-controlled code outside the model.
Use authenticated actor/tenant metadata, a document ACL, an explicit tool allowlist
and a bounded call budget. Keep retrieved document text as data. Use harmless
synthetic documents and proposed tool calls; do not connect a real database, send
messages or execute shell commands. Run node --test lab.test.mjs. Document that
these tests check policy enforcement, not a live model, a vector database
integration or an injection detector.5. Applicare al proprio progetto
Nel RAG reale filtra cliente e permessi sul server durante il recupero, prima di inviare contesto al modello. Verifica ogni chiamata, codifica l’output per la destinazione e imponi un budget condiviso in produzione. Un futuro strumento di scrittura richiede approvazione legata all’attore e agli argomenti esatti.
Riferimenti ufficiali
Portalo nel tuo progetto
Scarica i file, conserva la guida o consegna al tuo assistente istruzioni pronte.
Prepara con l’IA
Copia questo prompt inglese nel tuo assistente. Include articolo, file disponibili e passaggi di preparazione.
Mostra il prompt di preparazione
Read this tutorial as reference material:
https://nethanelfitoussi.com/article/ai-rag-prompt-injection-guardrails?lang=en
Goal: apply the documented workflow to my development project.
Read the existing project instructions, inspect the relevant files and explain the smallest useful setup.
Available starter files:
https://nethanelfitoussi.com/api/media/f34e57b8-eb7c-49ea-889f-441e88ba63f0.zip
Download and inspect these files in a temporary folder before using them. Do not overwrite existing project instructions.
If I have not supplied a project folder, ask which development project to use. Do not invent a repository URL.
Additional project setup instructions:
Use the downloaded starter lab in a NEW folder. Read README.md and both English prompts first. Run its dependency-free Node.js tests before editing.
Review this LOCAL AI/RAG boundary lab. No real model or external service is
connected. Read lab.mjs and lab.test.mjs. Identify trusted actor and ACL metadata,
untrusted document text, proposed model tool calls and the execution budget. Test
whether a document instruction, forged tenant field or unknown write tool could
bypass the gateway. Do not treat a system prompt, an opaque document ID, a vector
search score or a model’s user_confirmed flag as authorization. Produce evidence and
remaining integration requirements, not a claim of complete prompt-injection
resistance.
Implement only the agreed local gateway improvement and add a regression test. Keep
authorization and argument validation in server-controlled code outside the model.
Use authenticated actor/tenant metadata, a document ACL, an explicit tool allowlist
and a bounded call budget. Keep retrieved document text as data. Use harmless
synthetic documents and proposed tool calls; do not connect a real database, send
messages or execute shell commands. Run node --test lab.test.mjs. Document that
these tests check policy enforcement, not a live model, a vector database
integration or an injection detector.
Adapt example paths, commands and acceptance criteria to this repository rather than assuming they match.
Give me a short plan, then make the agreed local changes and run the relevant checks. Report actual results and anything not verified. Stop before credentials, paid services, production changes, push, merge or deployment.

