Security hardening: fix SQLi, XSS, file upload, and migrate DB to RDS
- Fix all SQL injection vulnerabilities across Service_model, User_model, Module_model, Log_model, and Admin controller using parameterized queries - Add htmlspecialchars() to all user-controlled output in admin views (bookings, services, workers, service categories, login form) - Fix XSS in AJAX worker response and manage-booking-cancelled view - Add file extension whitelist (jpg, jpeg, png, gif, webp) to all uploads - Remove webshell (pentest2.php) from assets/img/profiles/ - Stop logging plaintext passwords on failed login attempts - Migrate database.php hostname from localhost to AWS RDS endpoint - Fix dropdown styling (white-on-white) in worker calendar view Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
307f17faa6
commit
420bcb37fd
@@ -13,13 +13,13 @@ class Module_model extends CI_Model {
|
||||
|
||||
public function getModuleById($module_id){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_id = "'.$module_id.'" LIMIT 1;');
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_id = ? LIMIT 1', array($module_id));
|
||||
return $query->result()[0];
|
||||
}
|
||||
|
||||
public function getModuleBySlug($module_slug){
|
||||
$this->load->database();
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_slug = "'.$module_slug.'" LIMIT 1;');
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_slug = ? LIMIT 1', array($module_slug));
|
||||
return $query->result()[0];
|
||||
}
|
||||
|
||||
@@ -145,11 +145,16 @@ public function is_groupId_available_in_module($module_id, $groupId){
|
||||
public function updateModule($fieldName, $module_id, $moduleUserArray){
|
||||
$this->load->database();
|
||||
|
||||
$allowedFields = array('permission_group_ids', 'permission_ids');
|
||||
if (!in_array($fieldName, $allowedFields)) return;
|
||||
|
||||
if(!empty($moduleUserArray)){
|
||||
$query = $this->db->query("UPDATE modules SET ".$fieldName." ='".serialize($moduleUserArray)."' WHERE module_id = '".$module_id."';");
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->update('modules', array($fieldName => serialize($moduleUserArray)));
|
||||
}
|
||||
else{
|
||||
$query = $this->db->query("UPDATE modules SET ".$fieldName." ='' WHERE module_id = '".$module_id."';");
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->update('modules', array($fieldName => ''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +179,7 @@ public function getModulesByPermissionSlug($permissionSlug){
|
||||
public function getPermissionBySlug($permissionSlug){
|
||||
$this->load->database();
|
||||
|
||||
$query = $this->db->query('SELECT * FROM permissions WHERE permission_slug = "'.$permissionSlug.'";');
|
||||
$query = $this->db->query('SELECT * FROM permissions WHERE permission_slug = ?', array($permissionSlug));
|
||||
if($query->num_rows() == 1){
|
||||
return $query->result()[0];
|
||||
}
|
||||
@@ -188,7 +193,7 @@ public function user_can_access_this_module($moduleSlug, $userId){
|
||||
$this->load->model('User_model');
|
||||
$selectedUser = $this->User_model->getUserById($userId);
|
||||
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_slug = "'.$moduleSlug.'" LIMIT 1;');
|
||||
$query = $this->db->query('SELECT * FROM modules WHERE module_slug = ? LIMIT 1', array($moduleSlug));
|
||||
|
||||
if($query->num_rows() == 1){
|
||||
$result = $query->result()[0];
|
||||
|
||||
Reference in New Issue
Block a user