Based on similar discussion in 12542, this patch changes permissions to use a delimiter. This ensures that user_access() and user_roles() calls always return the correct result for a given permission by essentially searching for '%|permission|%' rather than '%permission%' (which may yield incorrect results with similarly-named permissions).

Comments

killes@www.drop.org’s picture

There is no patch.

killes@www.drop.org’s picture

Title: Use permission delimiter » Use permission delimiter properly

The problem is no there wouldn't be a delimiter, the problem is that the INSERT works like this:

db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, implode(', ', array_keys($edit[$role->rid])));

I think it should be

db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, ','. implode(', ', array_keys($edit[$role->rid])) .',' );

then you can look for ,perm,

chx’s picture

Priority: Normal » Minor

this is partially fixed in user_access , user_roles is not yet fixed but as that function is rarely used with parameters, I am downgrading this to minor.

magico’s picture

What are the real consequences of this bug? In what situations?

killes@www.drop.org’s picture

if (isset($perm[$account->uid])) {
return strpos($perm[$account->uid], "$string, ") !== FALSE;
}

as I see it you will get a wrong result if you have too permissions "foo" and "bar foo". If the user has the "foo" permission, he'll automatically have the "bar foo" permission too. I admit it is unlikely to be a real problem but it might screw up somebody badly and he'd have a hard time figuring it out.

stevenpatz’s picture

Version: x.y.z » 6.x-dev
Status: Active » Postponed (maintainer needs more info)

is this still an issue?

mdupont’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing.