أمن قواعد البيانات
تغطي هذه الوحدة تهديدات أمن قواعد البيانات والتدابير المضادة لها، بالإضافة إلى نماذج الأمان المختلفة مثل التحكم التقديري (DAC)، الإلزامي (MAC)، والمبني على الأدوار (RBAC).
Database Security
This module covers database security threats and countermeasures, along with various security models including Discretionary (DAC), Mandatory (MAC), and Role-Based Access Control (RBAC).
أهداف التعلم
- شرح التهديدات التي تواجه قواعد البيانات والتدابير المضادة لها.
- شرح نماذج الأمان المختلفة (DAC, MAC, RBAC).
- وصف تشفير البيانات في القنوات الخفية.
- Explain the threats to Databases and their countermeasures.
- Explain various security models.
- Describe encryption of data in a covert channel.
1 تهديدات أمن قواعد البيانات والتدابير المضادة
1 Database Security Threats and Countermeasures
حماية قواعد البيانات تعني الدفاع عنها ضد فقدان السلامة، التوافر، والسرية باستخدام أدوات تحكم متعددة.
Database security means defending against loss of integrity, availability, and confidentiality using multiple control measures.
تتضمن أنواع الأمان قضايا قانونية وأخلاقية، قضايا سياسات، وقضايا متعلقة بالنظام.
التهديدات الرئيسية لقواعد البيانات هي: فقدان السلامة (Integrity)، فقدان التوافر (Availability)، وفقدان السرية (Confidentiality).
لحماية قواعد البيانات، يتم تنفيذ أربعة أنواع من التدابير المضادة:
- التحكم في الوصول (Access Control): تقييد الوصول للنظام ككل.
- التحكم في الاستنتاج (Inference Control): حماية قواعد البيانات الإحصائية من استنتاج معلومات فردية.
- التحكم في التدفق (Flow Control): منع تدفق المعلومات للمستخدمين غير المصرح لهم (مثل القنوات الخفية Covert Channels).
- تشفير البيانات (Data Encryption): حماية البيانات الحساسة أثناء النقل.
Security types include legal/ethical issues, policy issues, and system-related issues.
The main threats to databases are: Loss of integrity, Loss of availability, and Loss of confidentiality.
To protect databases, four kinds of countermeasures are implemented:
- Access control: Restricting access to the database as a whole.
- Inference control: Protecting statistical databases from revealing individual data.
- Flow control: Preventing information from flowing to unauthorized users (e.g., Covert channels).
- Data encryption: Protecting sensitive data during transmission.
القنوات الخفية (Covert Channels) هي مسارات لتدفق المعلومات بشكل ضمني بطرق تنتهك السياسة الأمنية للمؤسسة.
في قواعد البيانات الإحصائية، تكمن المشكلة في أن المستخدم قد يستنتج بيانات شخصية من خلال طلب ملخصات إحصائية متكررة ومتقاطعة، مما يستدعي آليات معقدة للتحكم في الاستنتاج.
Covert channels are pathways for information to flow implicitly in ways that violate the security policy of an organization.
In statistical databases, the challenge is that a user might deduce individual data by requesting overlapping statistical summaries, requiring complex inference control mechanisms.
كيف يمكن لمهاجم استخدام قاعدة بيانات إحصائية (مثل متوسط الرواتب) لمعرفة راتب موظف محدد؟ How could an attacker use a statistical database (like average salaries) to find out a specific employee's salary?
عن طريق طلب متوسط راتب قسم معين، ثم طلب متوسط الراتب لنفس القسم بعد استبعاد الموظف المستهدف، واستنتاج راتبه من الفرق.
By querying the average salary of a department, then querying the average salary of the same department excluding the target employee, and deducing the salary from the difference.
2 مسؤول قاعدة البيانات والتدقيق
2 DBA and Database Audits
مسؤول قاعدة البيانات (DBA) هو السلطة المركزية، ومسار التدقيق هو سجل يراقب كل تحركات المستخدمين لاكتشاف التلاعب.
The DBA is the central authority, and the audit trail is a log that monitors all user actions to detect tampering.
مسؤول قاعدة البيانات (DBA) يمتلك حساب نظام (superuser) يوفر قدرات قوية تشمل:
- إنشاء الحسابات،
- منح الصلاحيات،
- إلغاء الصلاحيات،
- وتعيين مستويات الأمان.
يجب على النظام تتبع جميع العمليات من خلال سجل النظام (System Log).
إذا تم الاشتباه في أي تلاعب، يتم إجراء تدقيق قاعدة البيانات (Database Audit)، والذي يتكون من مراجعة السجل لفحص جميع الوصول والعمليات.
السجل المستخدم لأغراض أمنية يسمى مسار التدقيق (Audit Trail).
The Database Administrator (DBA) has a system or superuser account providing powerful capabilities:
- Account creation,
- Privilege granting,
- Privilege revocation,
- and Security level assignment.
The system must track all operations via a system log.
If tampering is suspected, a database audit is performed by reviewing the log to examine all accesses and operations.
A database log used mainly for security is called an audit trail.
يعد مسار التدقيق أداة حاسمة ليس فقط للأمان ولكن للامتثال التنظيمي.
يجب أن يكون السجل نفسه محميًا بشدة (غالبًا للقراءة فقط أو يُكتب في وسائط غير قابلة للتعديل) لضمان عدم تمكن المهاجم من مسح آثاره بعد اختراق النظام.
The audit trail is a critical tool not just for security but for regulatory compliance.
The log itself must be heavily protected (often append-only or written to immutable media) to ensure an attacker cannot erase their tracks after compromising the system.
لماذا يعتبر حساب DBA هدفاً رئيسياً للمخترقين؟ Why is the DBA account a primary target for hackers?
لأنه يمتلك صلاحيات مطلقة (superuser) تتيح له تجاوز جميع القيود الأمنية، إنشاء حسابات وهمية، وتعديل أو حذف مسار التدقيق.
Because it has superuser privileges that allow bypassing all security controls, creating rogue accounts, and modifying or deleting the audit trail.
3 التحكم التقديري في الوصول (DAC)
3 Discretionary Access Control (DAC)
نموذج أمان يتيح لمالك البيانات منح أو إلغاء صلاحيات الوصول للآخرين بحرية.
A security model that allows the data owner to freely grant or revoke access privileges to others.
يعتمد DAC على منح (GRANT) وإلغاء (REVOKE) الصلاحيات.
يتم تطبيق الصلاحيات على مستويين:
- مستوى الحساب (مثل CREATE TABLE)
- ومستوى العلاقة/الجدول (مثل SELECT, MODIFY, REFERENCES).
يتبع هذا النموذج نموذج مصفوفة الوصول (Access Matrix Model) حيث تمثل الصفوف الكيانات (المستخدمين) والأعمدة تمثل الكائنات (الجداول).
يمكن لمالك الجدول تمرير الصلاحيات باستخدام GRANT OPTION، مما يسمح بانتشار الصلاحيات. يمكن الحد من هذا الانتشار أفقياً أو عمودياً.
كما يمكن استخدام العروض (Views) كآلية أمان لإخفاء أعمدة أو صفوف معينة عن المستخدمين.
DAC is based on granting and revoking privileges.
Privileges apply at two levels:
- Account level (e.g., CREATE TABLE)
- and Relation/Table level (e.g., SELECT, MODIFY, REFERENCES).
It follows the Access Matrix Model where rows represent subjects (users) and columns represent objects (tables).
The owner can pass privileges using the GRANT OPTION, allowing privilege propagation. This propagation can be limited horizontally or vertically.
Views can also be used as a security mechanism to hide specific columns or rows from users.
العيب الرئيسي لنموذج DAC هو ضعفه أمام الهجمات الخبيثة مثل أحصنة طروادة (Trojan Horses).
نظراً لأن المستخدمين يمكنهم نقل الصلاحيات، يمكن لبرنامج خبيث يعمل بصلاحيات مستخدم شرعي أن ينسخ البيانات الحساسة إلى جدول آخر يمتلك المهاجم صلاحية الوصول إليه.
The main drawback of DAC models is their vulnerability to malicious attacks, such as Trojan horses.
Because users can propagate privileges, a malicious program running with a legitimate user's privileges can copy sensitive data to another table accessible by the attacker.
GRANT SELECT ON EMPLOYEE, DEPARTMENT TO A3 WITH GRANT OPTION;
REVOKE SELECT ON EMPLOYEE FROM A3;
إذا منح A1 صلاحية لـ A2 مع GRANT OPTION، وقام A2 بمنحها لـ A3. ماذا يحدث إذا قام A1 بإلغاء الصلاحية من A2؟ If A1 grants a privilege to A2 with GRANT OPTION, and A2 grants it to A3. What happens if A1 revokes the privilege from A2?
سيقوم النظام تلقائياً بإلغاء الصلاحية من A3 أيضاً (إلغاء متسلسل).
The system will automatically revoke the privilege from A3 as well (cascading revoke).
4 التحكم الإلزامي في الوصول (MAC)
4 Mandatory Access Control (MAC)
نموذج أمان صارم يصنف البيانات والمستخدمين إلى مستويات أمنية (مثل سري للغاية، سري) ويمنع تسريب المعلومات.
A strict security model that classifies data and users into security levels (e.g., Top Secret, Secret) and prevents information leakage.
يُستخدم MAC عندما تكون هناك حاجة لسياسة أمان إضافية تصنف البيانات والمستخدمين.
الفئات الأمنية النموذجية هي: سري للغاية (TS) ≥ سري (S) ≥ سري (C) ≥ غير مصنف (U).
النموذج الأكثر شيوعاً هو نموذج Bell-LaPadula، والذي يفرض قيدين:
- خاصية الأمان البسيطة (Simple Security Property): لا يُسمح للموضوع S بقراءة الكائن O إلا إذا كان تصنيف S أعلى من أو يساوي تصنيف O (لا تقرأ لأعلى).
- خاصية النجمة (* Property): لا يُسمح للموضوع S بكتابة الكائن O إلا إذا كان تصنيف S أقل من أو يساوي تصنيف O (لا تكتب لأسفل).
MAC is used when an additional security policy is needed to classify data and users.
Typical security classes are Top Secret (TS) ≥ Secret (S) ≥ Confidential (C) ≥ Unclassified (U).
The commonly used model is the Bell-LaPadula model, which enforces two restrictions:
- Simple security property: Subject S cannot read Object O unless class(S) ≥ class(O) (No read up).
- Star property (* property): Subject S cannot write Object O unless class(S) ≤ class(O) (No write down).
تمنع خاصية النجمة (Star Property) تسريب المعلومات من مستوى أمني عالٍ إلى مستوى أدنى.
على سبيل المثال، لا يمكن لبرنامج خبيث (Trojan) يعمل بصلاحيات 'سري للغاية' أن ينسخ البيانات ويحفظها في ملف 'غير مصنف'، مما يحل المشكلة الرئيسية الموجودة في نموذج DAC.
The Star Property prevents information leakage from a higher security level to a lower one.
For example, a Trojan horse running with 'Top Secret' clearance cannot copy data and write it to an 'Unclassified' file, solving the main vulnerability of the DAC model.
| DAC | MAC | |
|---|---|---|
| المرونةFlexibility | درجة عالية من المرونة، مناسب لتطبيقات متنوعة.High degree of flexibility, suitable for a large variety of domains. | جامد جداً، قابل للتطبيق في بيئات محدودة (مثل العسكرية).Too rigid, only applicable in limited environments. |
| مستوى الحمايةProtection Level | عرضة للهجمات الخبيثة مثل أحصنة طروادة.Vulnerable to malicious attacks like Trojan horses. | درجة عالية من الحماية، يمنع التدفق غير القانوني للمعلومات.High degree of protection, prevents illegal flow of information. |
لماذا يُسمح للمستخدم في نموذج Bell-LaPadula بالكتابة في مستوى أمني أعلى من مستواه (Write Up)؟ Why is a user in the Bell-LaPadula model allowed to write to a higher security level (Write Up)?
لأن الكتابة في مستوى أعلى لا تسرب معلومات حساسة إلى مستويات أدنى. ومع ذلك، في الواقع العملي، قد يتم تقييد ذلك للحفاظ على سلامة البيانات (Integrity).
Because writing to a higher level does not leak sensitive information to lower levels. However, in practice, this might be restricted to maintain data integrity.
5 العلاقات متعددة المستويات والتعددية الاستنساخية
5 Multilevel Relations and Polyinstantiation
في قواعد البيانات الآمنة، قد يرى المستخدمون ذوو الصلاحيات المختلفة بيانات مختلفة لنفس السجل، وهو ما يسمى بـالتعددية الاستنساخية.
In secure databases, users with different clearances might see different data for the same record, known as polyinstantiation.
لدمج الأمان متعدد المستويات في قواعد البيانات العلائقية، يتم ربط كل سمة (Attribute) بـ سمة تصنيف (Classification Attribute).
يسمى المفتاح الأساسي في هذا النظام بـ المفتاح الظاهري (Apparent Key).
يؤدي هذا إلى مفهوم التعددية الاستنساخية (Polyinstantiation)، حيث يمكن أن تحتوي عدة صفوف على نفس قيمة المفتاح الظاهري ولكن بقيم سمات مختلفة للمستخدمين في مستويات تصنيف مختلفة.
يتم تطبيق قواعد سلامة إضافية مثل سلامة الكيان (Entity Integrity) (يجب أن يكون للمفتاح الظاهري نفس التصنيف الأمني داخل الصف) وسلامة القيم الفارغة (Null Integrity).
To incorporate multilevel security, each attribute is associated with a classification attribute.
The primary key in a regular relation becomes the apparent key in a multilevel relation.
This leads to polyinstantiation, where several tuples can have the same apparent key value but different attribute values for users at different classification levels.
Additional integrity rules apply, such as entity integrity (apparent key attributes must have the same security classification within a tuple) and null/interinstance integrity.
تمنع التعددية الاستنساخية قنوات الاستنتاج الخفية.
إذا حاول مستخدم ذو تصنيف منخفض إدخال سجل بمفتاح موجود مسبقاً في مستوى سري، فإن رفض الإدخال سيكشف للمستخدم أن هذا المفتاح موجود.
بدلاً من ذلك، يقبل النظام الإدخال ويخلق نسختين (Polyinstantiation) لمنع تسريب حقيقة وجود السجل السري.
Polyinstantiation prevents inference channels.
If a low-clearance user tries to insert a record with a key that already exists at a secret level, rejecting the insert would reveal the existence of the secret record.
Instead, the system accepts it, creating two instances (polyinstantiation) to hide the existence of the higher-level data.
كيف تؤثر التعددية الاستنساخية على سلامة البيانات (Data Integrity) من منظور قواعد البيانات التقليدية؟ How does polyinstantiation affect data integrity from a traditional database perspective?
تكسر قاعدة تفرد المفتاح الأساسي (Primary Key Uniqueness)، حيث يسمح النظام بوجود صفوف متعددة بنفس المفتاح الظاهري، مما يعقد عمليات التحديث والاستعلام.
It breaks the traditional primary key uniqueness rule, as the system allows multiple rows with the same apparent key, complicating update and query operations.
6 التحكم في الوصول المبني على الأدوار (RBAC)
6 Role-Based Access Control (RBAC)
منح الصلاحيات بناءً على المسمى الوظيفي (الدور) بدلاً من المستخدم الفردي، مما يسهل إدارة الأنظمة الكبيرة.
Granting privileges based on job titles (roles) rather than individual users, simplifying management in large systems.
ظهر RBAC كتقنية مثبتة لإدارة الأمان في الأنظمة واسعة النطاق.
الفكرة الأساسية هي أن الأذونات ترتبط بالأدوار (Roles)، ويتم تعيين المستخدمين للأدوار المناسبة. يتم إنشاء الأدوار باستخدام CREATE ROLE.
يوفر RBAC تسلسل هرمي للأدوار (Role Hierarchy) يعكس خطوط السلطة والمسؤولية في المؤسسة.
كما يدعم القيود الزمنية (Temporal Constraints) على الأدوار، مثل مدة التفعيل.
يعتبر RBAC مثالياً لتطبيقات الويب والمؤسسات الناشئة مقارنة بـ DAC و MAC.
RBAC emerged as a proven technology for managing security in large-scale systems.
The basic notion is that permissions are associated with roles, and users are assigned to appropriate roles. Roles are created using CREATE ROLE.
RBAC provides a Role hierarchy that reflects the organization's lines of authority.
It also supports temporal constraints on roles, such as time and duration of activations.
RBAC is highly desirable for Web-based applications compared to DAC and MAC.
يحل RBAC مشكلة الإدارة المعقدة في DAC والجمود في MAC.
من خلال فصل المستخدمين عن الصلاحيات عبر طبقة 'الأدوار'، يمكن للمؤسسة تغيير دور الموظف بسهولة دون الحاجة لتعديل مئات الصلاحيات الفردية في جداول قاعدة البيانات.
RBAC solves the complex management overhead of DAC and the rigidity of MAC.
By decoupling users from privileges via the 'Roles' layer, an organization can easily change an employee's role without needing to modify hundreds of individual privileges in the database tables.
ما هي ميزة القيود الزمنية (Temporal Constraints) في نموذج RBAC؟ What is the advantage of Temporal Constraints in the RBAC model?
تسمح بمنح صلاحيات مؤقتة (مثل دور 'مدير مناوب' يعمل فقط من 9 صباحاً إلى 5 مساءً)، مما يقلل من نافذة الخطر الأمني.
They allow granting temporary privileges (e.g., a 'Shift Manager' role active only from 9 AM to 5 PM), reducing the security risk window.