Summary
WeGIA has an authorization flaw in permission-management requests: the access check does not verify the requested action or method. An authenticated employee with a qualifying permission and a valid CSRF token from their own session may change permissions for arbitrary roles, potentially gaining elevated access or disrupting other users.
Affected context
The issue affects WeGIA's FuncionarioControle permission-management operations in web/controle/control.php. The risk arises when an authenticated employee has a permission row for resource 11 or 91, but the authorization check does not validate the stored action level or whether that permission covers the requested method. The issue is described as affecting versions before 3.9.1.
Exploit preconditions
- Attack surface: Authenticated web requests to employee permission-management operations
- Required access: An employee account with a permission row for resource 11 or 91, plus a valid CSRF token from that employee's session
- Trigger point: A request invoking
adicionarPermissao,alterarPermissao, orexcluirPermissao - Why exploitation is possible: The permission check does not compare the stored
id_acaovalue or authorize the specific requested method, allowing the request to affect permissions for arbitrary roles
Why this happens
The root cause is an authorization decision based on an insufficient permission check. MiddlewareDAO::verificarPermissao() checks for a permission row associated with a resource but does not confirm that the row grants the required action or that the requested method is authorized. This is an incorrect authorization condition (CWE-863) and can result in incorrect privilege assignment (CWE-266).
Potential impact
- An attacker may grant higher action levels over sensitive resources to a role they choose.
- Protected employee, patient, configuration, or administrative data could be exposed or modified by accounts in an affected role.
- An attacker could remove permissions from other roles and disrupt legitimate access.
General mitigation guidance
Common defensive patterns include:
- Authorize each operation against the specific resource, action level, and method being requested.
- Deny access by default when a permission is missing, ambiguous, or does not match the requested action.
- Centralize permission checks so controller methods cannot bypass or weaken policy enforcement.
- Reduce reliance on mutable permission data and tightly restrict who can change role assignments.
- Apply least privilege to employee roles and regularly review permission changes.
- Treat CSRF protection as a complementary control; it does not replace authorization checks.
How teams detect issues like this
- Use static analysis and code review to identify permission checks that verify resource access but omit action-level or method-specific authorization.
- Review controller routes and permission-management methods for consistent, deny-by-default authorization.
- Audit permission-change events, looking for unexpected role targets, elevated action levels, or removals affecting multiple users.
- Enforce policy checks in automated tests and deployment review processes; automated code review tools may help flag incomplete authorization patterns.

