CiviCRM permission-checks may incorporate a mix of boolean operations (AND and OR). In certain combinations, the permission-check
has a premature short-circuit and grants access erroneously.
The issue is highly dependent on the specific boolean expression. It is believed that civicrm-core does not have any live, vulnerable
expressions. However, extensions could have exploitable expressions.
Technical details
The method CRM_Core_Permission::check() accepts a string or an array-tree. Some inputs work as expected; others do not.
// OK: Simple check
CRM_Core_Permission::check('administer CiviCRM');
// OK: AND before OR
CRM_Core_Permission::check([
'administer CiviCRM', // and
['view all contacts', 'access CiviCRM'], // or group
]);
// Bad: OR before AND
CRM_Core_Permission::check([
['view all contacts', 'access CiviCRM'], // or group
'administer CiviCRM' // and
]);
// OK: Pure PHP booleans
(
CRM_Core_Permission::check('view all contacts')
||
CRM_Core_Permission::check('access CiviCRM')
)
&&
CRM_Core_Permission::check('administer CiviCRM');
CiviCRM v6.19.2 and earlier
CiviCRM v6.19.3, v6.16.6 (ESR), and later
Upgrade to a fixed version of CiviCRM
Alternatively, if you are an extension-developer whose extension is affected and your users cannot upgrade, then you may re-write your expression. Use a safe ordering or use pure PHP booleans.
(Alphabetically) Coleman Watts (CiviCRM), Seamus Lee (JMA Consulting)
