Closing a login bypass in a booking systemإغلاق ثغرة تجاوز الدخول في نظام حجوزات
The problemالمشكلة
A desktop booking system for a wedding hall: customers, staff, bookings and a staff login. It worked, and on the surface it looked finished.نظام حجوزات لسطح المكتب لقاعة أفراح: العملاء والموظفين والحجوزات وشاشة دخول. كان يعمل، وظاهريًا يبدو مكتملًا.
What I foundما وجدته
The login query glued the typed username and password straight into SQL. Typing ' OR '1'='1 as the password would log anyone in. Six more queries for customers and staff had the same flaw.استعلام الدخول كان يدمج اسم المستخدم وكلمة المرور مباشرة داخل SQL. كتابة ' OR '1'='1 في كلمة المرور تُدخل أي أحد. وستة استعلامات أخرى للعملاء والموظفين فيها نفس الثغرة.
What I changedما غيّرته
Rewrote every injectable query as a parameterized command, 20 parameters in total, on a separate copy so the original stayed untouched.أعدت كتابة كل استعلام قابل للحقن كأمر بمعاملات، 20 معاملًا في المجموع، على نسخة منفصلة ليبقى الأصل كما هو.
The resultالنتيجة
The login bypass and the data-tampering holes are closed. Plain-text passwords and a hard-coded database path are documented as the next fixes. This is exactly what a Launch-Ready audit delivers.ثغرة تجاوز الدخول وثغرات التلاعب بالبيانات أُغلقت. وكلمات المرور غير المشفرة ومسار قاعدة البيانات الثابت موثّقة كإصلاحات تالية. وهذا بالضبط ما يقدّمه فحص «جاهز للإطلاق».
- "select COUNT(*) FROM StaffTbl where StaffName = '" - + UnameTb.Text + "' and StaffPassword = '" - + PasswordTb.Text + "'"
+ "SELECT COUNT(*) FROM StaffTbl + WHERE StaffName = @name AND StaffPassword = @pass" + cmd.Parameters.AddWithValue("@name", UnameTb.Text); + cmd.Parameters.AddWithValue("@pass", PasswordTb.Text);