Final Module: Database Security الوحدة الأخيرة: أمن قواعد البيانات
Protecting the data. From threats and access control models (DAC, MAC, RBAC) to SQL injection and privileges. حماية البيانات. من التهديدات ونماذج التحكم في الوصول (DAC, MAC, RBAC) إلى حقن SQL والامتيازات.
Security Goals & Threats أهداف الأمن والتهديدات
Database security aims to protect against intentional or accidental threats. The core goals form the CIA triad. يهدف أمن قاعدة البيانات إلى الحماية من التهديدات المتعمدة أو العرضية. تشكل الأهداف الأساسية ثالوث CIA.
- Loss of integrity (Modification) فقدان النزاهة (التعديل)
- Loss of availability (DoS) فقدان التوافر (هجمات الحرمان من الخدمة)
- Loss of confidentiality (Data Theft) فقدان السرية (سرقة البيانات)
- SQL Injection (Code Execution) حقن SQL (تنفيذ الأكواد)
Discretionary Access Control (DAC) Discretionary Access Control (DAC)
The SQL Standard معيار SQL
Typical SQL security. Access is based on the identity of the requestor and access rules (privileges) stating what requestors are (or are not) allowed to do.
Key Feature: Users can pass their privileges to others.
أمان SQL النموذجي. يعتمد الوصول على هوية الطالب وقواعد الوصول (الامتيازات) التي تحدد ما يُسمح (أو لا يُسمح) للطالب بفعله.
ميزة رئيسية: يمكن للمستخدمين تمرير امتيازاتهم للآخرين.
WITH GRANT OPTION: Allows the user to pass the privilege to others.
CASCADE: If A grants to B, and A's rights are revoked, B loses them too.
WITH GRANT OPTION: يسمح للمستخدم بتمرير الامتياز للآخرين.
CASCADE: إذا منح A الامتياز لـ B، وتم سحب حقوق A، يفقد B حقوقه أيضاً.
Mandatory Access Control (MAC) Mandatory Access Control (MAC)
Multilevel Security الأمان متعدد المستويات
Based on system-wide policies that cannot be changed by individual users.
Subjects (Users) and Objects (Data) are assigned Security Classes (Clearance Level).
Example: Top Secret (TS) > Secret (S) > Confidential (C) > Unclassified (U).
يعتمد على سياسات على مستوى النظام لا يمكن تغييرها بواسطة المستخدمين الأفراد.
يتم تعيين فئات أمنية (مستوى التصريح) للمواضيع (المستخدمين) والكائنات (البيانات).
مثال: سري للغاية (TS) > سري (S) > خاص (C) > غير سري (U).
1. No Read Up: Cannot read data with higher classification.
2. No Write Down: Cannot write data to lower classification (prevents leaks). يركز على السرية.
1. لا قراءة للأعلى: لا يمكن قراءة بيانات ذات تصنيف أعلى.
2. لا كتابة للأسفل: لا يمكن كتابة بيانات لتصنيف أدنى (لمنع التسريب).
Role-Based Access Control (RBAC) Role-Based Access Control (RBAC)
Modern Enterprise Security أمن المؤسسات الحديث
Privileges are assigned to Roles (e.g., Manager, Teller), not directly to Users. Users are then assigned to Roles. يتم تعيين الامتيازات لـ أدوار (Roles) (مثل المدير، الصراف)، وليس للمستخدمين مباشرة. ثم يتم تعيين المستخدمين لهذه الأدوار.
The Exam Vault خزنة الاختبار
Professor's Secrets & Trap Avoidance أسرار البروفيسور وتجنب الفخاخ
TRAP: No Write Down فخ: لا كتابة للأسفل (No Write Down)
In MAC (Bell-LaPadula), "No Write Down" (*-Property) seems counter-intuitive.
Why can't a General write to a Soldier?
Because a malicious program (Trojan Horse) running at Top Secret level could copy sensitive data and write it to a Public file. It prevents Information Leakage.
في MAC (Bell-LaPadula)، تبدو قاعدة "لا كتابة للأسفل" غير منطقية.
لماذا لا يستطيع الجنرال الكتابة للجندي؟
لأن برنامجاً خبيثاً (حصان طروادة) يعمل بمستوى "سري للغاية" قد ينسخ بيانات حساسة ويكتبها في ملف عام. هذا يمنع تسريب المعلومات.
TRAP: View Security فخ: أمان الـ View
"How do you hide the Salary column from a user?"
Correct Answer: Create a VIEW that selects only non-sensitive columns, then GRANT access to the View (not the Table).
"كيف تخفي عمود الراتب عن المستخدم؟"
الإجابة الصحيحة: أنشئ VIEW يختار فقط الأعمدة غير الحساسة، ثم امنح (GRANT) الوصول للـ View (وليس للجدول).
SECRET: SQL Injection سر: SQL Injection
The most common web database threat. Attackers inject SQL code via input fields.
Prevention: Always use Prepared Statements (Bind Variables). Never concatenate strings to build queries.
أكثر تهديدات قواعد البيانات شيوعاً على الويب. يقوم المهاجمون بحقن كود SQL عبر حقول الإدخال.
الوقاية: استخدم دائماً Prepared Statements (Bind Variables). لا تدمج النصوص لبناء الاستعلامات أبداً.
KEY CONCEPT: The Audit Trail مفهوم أساسي: Audit Trail
Security isn't just prevention; it's detection. The Audit Trail logs all DB operations (who did what and when). It allows for post-incident analysis and deterrence. الأمن ليس مجرد وقاية؛ بل هو اكتشاف. الـ Audit Trail يسجل جميع عمليات قاعدة البيانات (من فعل ماذا ومتى). يسمح هذا بالتحليل بعد الحوادث والردع.