להגן על עוזר AI וחיפוש RAG באמצעות הרשאות מחוץ לפרומפט
שער כלים עם בידוד לקוחות, הרשאות מסמכים ותקציב קריאות. כולל שמונה בדיקות מקומיות ופרומפטים באנגלית.

מתחילים כאן: למה המדריך שימושי
מסמך אומר לעוזר להתעלם מהכללים ולשלוח רשומות של לקוח אחר. זו הזרקה עקיפה: מידע הופך בטעות להוראה. פרומפט חזק אינו מחליף הרשאות חיצוניות. תבנו גבול שרת שקובע אילו מסמכים מותר לקרוא ומגביל קריאות, ללא מודל אמיתי או כלי כתיבה. הבדיקות מוכיחות מדיניות ולא עמידות אוניברסלית של מודלים.
דוגמה מעשית
זו דוגמה לפורמט תשובה ולא תוצאת ביקורת של היישום שלכם. עקבו אחר השלבים והשוו קבצים, בדיקות ופלט אמיתיים ליעד. אם העוזר רק אומר שסיים, בקשו תוצר, ראיות ומה עדיין לא נבדק.
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.המטרה
עוזר עשוי לקרוא מסמך שמכיל הוראות. היישום עדיין צריך לקבוע לאילו נתונים וכלים יש למשתמש גישה. התרגיל אוכף שער קריאה בלבד בלי להפעיל מודל או שירות חיצוני.
1. הגדרת גבולות הבדיקה
חלצו ZIP לתיקייה חדשה והשתמשו ב-Node.js 22 ומעלה. המסמכים, הזהויות ותשובות המודל המדומות הם בדיוניים. בשירות אמיתי זהות והרשאות צריכות להגיע מהשרת, ולא ממסמך שהועלה או מארגומנטים של המודל.
2. הפעלת התרגיל המקומי
הריצו שמונה בדיקות: קריאה מותרת, לקוח אחר, הרשאה חסרה, כלי כתיבה אסור, זהות מזויפת, הוראה בתוך מסמך, תקציב והגדרה לא תקינה. טקסט המסמך מוחזר בכוונה כמידע ולא מתבצע.
node --version
node --test lab.test.mjs3. לבקש ראיות מה-AI
הפרומפט הראשון מבקש למפות גבולות אמון. ציון דמיון וקטורי אינו הרשאה. הבדיקות בוחנות קוד מדיניות דטרמיניסטי ולא מוכיחות שמודל אמיתי עמיד לכל הזרקה.
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. אימות התיקון
הפרומפט השני מגדיר שינוי קטן ובדיקת נסיגה. השאירו בדיקות הרשאה וארגומנטים מחוץ למודל. הוראה להתעלם מהוראות מסמך אינה מנגנון הרשאות אכיף.
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. יישום בפרויקט שלכם
ב-RAG אמיתי סננו לקוח והרשאות מסמך בצד השרת בזמן השליפה, לפני שליחת ההקשר למודל. בדקו כל קריאת כלי, קודדו פלט לפי יעדו ואכפו תקציב משותף בייצור. כלי כתיבה עתידי ידרוש אישור לפעולה המדויקת שמקושר לזהות ולארגומנטים האמיתיים.
מקורות רשמיים
מכאן לפרויקט שלכם
הורידו את הקבצים, שמרו את המדריך או תנו לעוזר הפיתוח תיאור משימה מוכן.
מכינים את הפרויקט עם AI
העתיקו את הפרומפט באנגלית לעוזר הפיתוח. הוא כולל את המאמר, הקבצים הזמינים ושלבי ההכנה.
הצגת פרומפט ההכנה
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.

