العودة إلى دفتر الملاحظات
IT & Security4 دقائق قراءة

تدقيق أمان التطبيق بالذكاء الاصطناعي: إثبات الصلاحيات محليًا

حوّل شكوك الذكاء الاصطناعي إلى أدلة وإصلاح محدد وسبعة اختبارات صلاحيات. مشروع جاهز وتعليمات إنجليزية.

ابدأ هنا: ما فائدة هذا الدليل

يحوي تطبيق B2B فواتير شركات متعددة. يغيّر مستخدم مسجل المعرّف: هل يقرأ فاتورة أخرى؟ الدخول وحده لا يكفي. ستحوّل الخطر لقاعدة صلاحيات ومراجعة بأدلة واختبار تراجع. النتيجة إصلاح صغير يرفض الممنوع ويحفظ حق المالك. حذف مقارنة المؤسسة يجب أن يفشل اختبارًا بين العملاء؛ النجاح لا يصادق على التطبيق كله.

مثال عملي

الجواب مثال للشكل المتوقع وليس تدقيقًا لتطبيقك. اتبع الخطوات وقارن الملفات والاختبارات والنتائج الفعلية بالهدف. إن قال المساعد إنه انتهى فقط فاطلب الناتج والدليل وما لم يجر التحقق منه.

Illustrative expected response
Finding: invoice lookup must enforce the authenticated tenant.
Evidence: exact policy function and the cross-tenant regression case.
Expected: owner in Acme allowed; the same user cannot read Beta data.
Remaining work: verify the actual HTTP route derives identity on the server.

الهدف

استخدم الذكاء الاصطناعي لفحص حد أمني واحد، ثم أثبت السلوك بالاختبارات. يفحص التمرين من يمكنه قراءة فاتورة في تطبيق B2B. إنه مثال لسياسة صلاحيات وليس نظام دخول متكاملًا.

1. تحديد نطاق العمل

نزّل ZIP أدناه وافكّه في مجلد جديد وافتحه. يكفي Node.js 22 أو أحدث دون تبعيات أو حساب أو مفتاح API. افحص شيفرة تملكها أو تملك إذنًا لمراجعتها.

2. تشغيل المختبر المحلي

شغّل الأوامر. تشمل الاختبارات السبعة المالك وعضوًا آخر ومسؤول المالية والوصول بين العملاء والهوية الناقصة. تنجح السياسة المصحّحة فيها. لرؤية تراجع، احذف مقارنة العميل مؤقتًا في نسخة تجريبية؛ ينبغي أن تفشل اختبارات الوصول بين العملاء.

Run the local exercise
node --version
node --test lab.test.mjs

3. طلب أدلة من الذكاء الاصطناعي

أعطِ المساعد التعليمات الإنجليزية الأولى. يحدّد الاستنتاج المفيد الشيفرة والفاعل والوصول الممنوع. المصادقة تحدّد الهوية، والتفويض يقرّر إن كان يمكنها قراءة الفاتورة.

English prompt: review with evidence
Act as a security reviewer for this LOCAL training project. Read lab.mjs and
lab.test.mjs before proposing changes. The actor must come from verified server
authentication. Map the invoice owner, tenant boundary and finance_admin exception.
Produce a table: claim, exact file/line, required attacker capability, affected
data, existing test and missing evidence. Separate confirmed findings from
hypotheses. Check same-tenant and cross-tenant cases, anonymous users and missing
fields. Do not assume that a hidden button or an unpredictable ID is authorization.
Do not contact a live service or change files yet.

4. التحقق من الإصلاح

تضبط التعليمات الثانية إصلاحًا محليًا متفقًا عليه. اختبر المنع والاستخدام الصحيح معًا. قول الذكاء الاصطناعي إن الشيفرة آمنة ليس نتيجة اختبار.

English prompt: correction and verification
Implement only the smallest agreed authorization correction in this local exercise.
Keep the same-tenant owner and finance administrator use cases working. Add a
negative regression case that would fail with the original faulty policy. Run node
--test lab.test.mjs and report the real result, remaining assumptions and diff. Do
not weaken an existing check to make a test pass. In an application, derive identity
and roles from verified server authentication and enforce the policy on every
relevant request. Stop before deployment.

5. التطبيق على مشروعك

في التطبيق الحقيقي يجب أن تأتي الهوية وبيانات العميل من مصادقة موثوقة على الخادم. أضف اختبارات API تثبت أن JSON القادم لا يختار مستخدمًا أو عميلًا آخر. وثّق أدوات الفحص والمراجعة البشرية بشكل منفصل؛ لا تصادق الاختبارات السبعة على أمان التطبيق كله.

المراجع الرسمية

طبّقه في مشروعك

نزّل الملفات، واحفظ الدليل، أو أعطِ مساعد البرمجة تعليمات جاهزة للاستخدام.

الإعداد بمساعدة الذكاء الاصطناعي

انسخ هذه التعليمات الإنجليزية إلى مساعدك. تتضمن المقال والملفات المتاحة وخطوات تجهيز المشروع.

عرض تعليمات الإعداد
AI setup prompt · English
Read this tutorial as reference material:
https://nethanelfitoussi.com/article/ai-security-code-review?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/b10c304f-9e50-4c20-8185-b8190a92c5cd.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.

Act as a security reviewer for this LOCAL training project. Read lab.mjs and
lab.test.mjs before proposing changes. The actor must come from verified server
authentication. Map the invoice owner, tenant boundary and finance_admin exception.
Produce a table: claim, exact file/line, required attacker capability, affected
data, existing test and missing evidence. Separate confirmed findings from
hypotheses. Check same-tenant and cross-tenant cases, anonymous users and missing
fields. Do not assume that a hidden button or an unpredictable ID is authorization.
Do not contact a live service or change files yet.

Implement only the smallest agreed authorization correction in this local exercise.
Keep the same-tenant owner and finance administrator use cases working. Add a
negative regression case that would fail with the original faulty policy. Run node
--test lab.test.mjs and report the real result, remaining assumptions and diff. Do
not weaken an existing check to make a test pass. In an application, derive identity
and roles from verified server authentication and enforce the policy on every
relevant request. Stop before deployment.

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.
اقرأ المصدر الأصليOWASP · Secure Code Review
AI security reviewAuthorizationCybersecurityB2B