The vulnerability is a stored Cross-Site Scripting (XSS) issue within the Group and Role Management functionality of the ci4ms application. The analysis began by identifying the vulnerable and patched versions from the advisory, which are <= 0.28.6.0 and 0.31.0.0 respectively. By comparing the git tags for these versions, I was able to isolate the commits that contain the security patch. The commit 296b2adee151b7a4eaeea7a2916bd4120e8d5bb3 stood out with a message indicating "security hardening" and "XSS/injection protection".
A detailed review of this commit revealed that multiple controller functions were modified to add input validation and output escaping. Specifically, in modules/Users/Controllers/PermgroupController.php, the group_create and group_update functions were identified as the source of the vulnerability. Before the patch, these functions directly saved user input from the group creation and editing forms to the database without any sanitization. The fields groupName, description, and seflink were all susceptible to XSS injection.
The patch addresses this by implementing two main changes:
- Input Validation: It adds
regex_match rules to the validation process to prevent malicious characters from being submitted.
- Output Escaping: It uses the
esc() helper function, which is CodeIgniter's built-in XSS filtering, before saving the data to the database and when rendering it in the views.
This confirms that the group_create and group_update functions were the vulnerable entry points that allowed for the stored XSS attack. An attacker could inject a malicious script into one of the group-related fields, and this script would be executed in the browser of any administrator viewing the group management page, leading to potential account takeover.