Hi there, I'm about to describe a very nasty bug that appears to exist in different guises in at least Zope 2.1.6 and Zope 2.2.2. The bug is nasty because it occurs under rather restricted circumstances, so nobody else noticed it yet, but it keeps biting _me_. The circumstances: * we have external method E in the root * we have a user defined in the root. This user has a certain role A. * we authenticate that user with a DTML method in root for role A. (so role A in this setup exists to force authentication only) * we give the user a local role B (or local user account with same username/password with that role) in a higher folder, X. * the external method E has security permissions to only work with role B (and manager), not with anonymous. As far as I am aware, our user should be able to execute E in the context of X and any subfolders, as the user has the right role there. Our user should not be able to execute E in the context of any other folder, however. (the execution happens through a DTML call) The symptoms: In Zope 2.1.6, the user cannot execute the external method E. Instead, the user is asked to reauthenticate. Naturally, reauthenticating the user again as himself won't work. In Zope 2.2.2, the user cannot execute the external method E either. Instead, the calling DTML code raises a NameError, basically saying our external method does not exist. The subtle bits -- when it *does* work fine --: This is probably why nobody actually ran into this one before. * it works fine when the user has manager role (at least in root) * it works fine when the external method is executable by anonymous. * it works fine when the external method is defined in another folder (not root folder) * it works fine with DTML methods * it even works fine (tested in 2.1.6) when the role is *not* added as a local role or with a local user account; if the user has role B from the start, it works. This one particularly gave me a lot of grief. The workaround that gets closest to what I want is to define the external methods in folder higher up instead. But that's not really desirable, in my circumstances I want the external method callable in the entire site, if the user is authenticated. Some minor observations: * ZClass instances seem to be affected as well. I'm not as sure about the symptoms here though. Anyway, I tried to upgrade to 2.2.2 to avoid this bug in particular, but the only thing I got was a NameError instead of an Authentication error. Sigh.. It doesn't appear to be a security leak, it appears to be overzealeous security instead. :) I'll also dump this description into the collector, but posted to the list because I like to complain. And who knows, perhaps someone else ran into the same. Regards, Martijn
On 25 Sep 2000, at 21:01, Martijn Faassen wrote:
In Zope 2.2.2, the user cannot execute the external method E either. Instead, the calling DTML code raises a NameError, basically saying our external method does not exist.
I'll also dump this description into the collector, but posted to the list because I like to complain. And who knows, perhaps someone else ran into the same.
I also get the same problem in a different way. I posted a note the other day about Login Manager and ownership generating NameError. I thought it was a Login Manager thing. The results are about the same, I get a NameError accessing an External method from a DTML method when the current user has been authenticated using a Login manager protectec sub folder of the root. My fix, strangely enough, was to change the ownershipp of the DTML method that was making the call to the External Method. It was owned (somehow) by a user from Login Manager, rather than from the root acl_users folder. Changing the ownership fixed the problem. I didn't know who should look into this, Ty or DC, so I posted to the list. Unfortunately it looks like no one has responded. I don't have the brains to figure it out. Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements
Brad Clements wrote:
On 25 Sep 2000, at 21:01, Martijn Faassen wrote:
In Zope 2.2.2, the user cannot execute the external method E either. Instead, the calling DTML code raises a NameError, basically saying our external method does not exist.
I'll also dump this description into the collector, but posted to the list because I like to complain. And who knows, perhaps someone else ran into the same.
I also get the same problem in a different way. I posted a note the other day about Login Manager and ownership generating NameError.
I thought it was a Login Manager thing. The results are about the same, I get a NameError accessing an External method from a DTML method when the current user has been authenticated using a Login manager protectec sub folder of the root.
This was just plain vanilla user folder. I also get it with ZClass instances, though I get a reauthentication request (impossible one) in that case. In 2.1.6, I'd get reauthentication requests for both external methods and ZClass instances.
My fix, strangely enough, was to change the ownershipp of the DTML method that was making the call to the External Method. It was owned (somehow) by a user from Login Manager, rather than from the root acl_users folder.
Changing the ownership fixed the problem.
I don't see how to accomplish this in my page. The root folder isn't owned by anyone, and I can't change it to be owned, I think. The external methods are all owned by my manager user, can I can't seem to change that either.
I didn't know who should look into this, Ty or DC, so I posted to the list. Unfortunately it looks like no one has responded. I don't have the brains to figure it out.
If it is indeed the same problem, it seems to be a Zope core bug. In fact I misreported that moving the external method to a subfolder solved all problems -- it still fails (at least in 2.2.2, perhaps it worked in 2.1.6), as long as the local role needed to execute it is added to the user in a subfolder below it). If the role is added in the same folder or a folder above the definition of the external method, it works. Regards, Martijn
Martijn Faassen wrote: [snip]
In fact I misreported that moving the external method to a subfolder solved all problems -- it still fails (at least in 2.2.2, perhaps it worked in 2.1.6), as long as the local role needed to execute it is added to the user in a subfolder below it). If the role is added in the same folder or a folder above the definition of the external method, it works.
More clearing up of misreporting: The manager role is not special. If a manager role is added as a local role below the place of definition of the external method or ZClass instance, that manager will not be able to execute said objects. (problem also occurs with ZClass instances) The behavior seems to be more consistent than I originally thought; it's indepedent of the root folder and the type of role. The main inconsistency is that it isn't behaving as I'd expect, and that DTML methods *do* behave as I expect. General problem description: For a ZClass instance/external methods that is only viewable by users with a particular role, the view operation fails if that role is only added to a user in a place deeper in the folder tree than the folder where the External Method/ZClass instance was defined. This occurs when the 'view' is occuring in the acquisition context of the folder. It succeeds if the role is added to the user in a folder higher in the tree, at or above the folder where the external method or ZClass instance is defined. The view operation fails with a reauthentication request in Zope 2.1.6 (so authentication exception raised presumably). In Zope 2.2.2 the failure is a NameError for External Methods, and reauthentication for ZClass instances. Am I missing something terribly obvious, or is this a rather huge bug that's been unnoticed for a long time? I assume it *must* be a bug as DTML methods behave in a different way. I also want it to be a bug, as I don't like this behavior. It makes it very hard to delegate responsibility. Regards, Martijn
Martijn Faassen wrote:
General problem description:
For a ZClass instance/external methods that is only viewable by users with a particular role, the view operation fails if that role is only added to a user in a place deeper in the folder tree than the folder where the External Method/ZClass instance was defined. This occurs when the 'view' is occuring in the acquisition context of the folder.
It succeeds if the role is added to the user in a folder higher in the tree, at or above the folder where the external method or ZClass instance is defined.
This sounds 100% correct. When checking security, acquisition context is ignored. What matters is *containment* (which is also accessed through the acquisition machinery, but in a special way: aq_inner). A user can only access objects that are defined in a container where the user is granted access. You probably don't really want to change it to use context instead. It would open a mile-wide security hole.
The view operation fails with a reauthentication request in Zope 2.1.6 (so authentication exception raised presumably).
In Zope 2.2.2 the failure is a NameError for External Methods, and reauthentication for ZClass instances.
Am I missing something terribly obvious, or is this a rather huge bug that's been unnoticed for a long time? I assume it *must* be a bug as DTML methods behave in a different way. I also want it to be a bug, as I don't like this behavior. It makes it very hard to delegate responsibility.
The difference is a result of the change in the way security is handled. It now gets a NameError because the name lookups skip over entries to which you're disallowed access. That logic can be very puzzling, but you might try the ZDebug product which helps you make sense of it. Shane
Shane Hathaway wrote:
Martijn Faassen wrote:
General problem description:
For a ZClass instance/external methods that is only viewable by users with a particular role, the view operation fails if that role is only added to a user in a place deeper in the folder tree than the folder where the External Method/ZClass instance was defined. This occurs when the 'view' is occuring in the acquisition context of the folder.
It succeeds if the role is added to the user in a folder higher in the tree, at or above the folder where the external method or ZClass instance is defined.
This sounds 100% correct. When checking security, acquisition context is ignored. What matters is *containment* (which is also accessed through the acquisition machinery, but in a special way: aq_inner). A user can only access objects that are defined in a container where the user is granted access.
How come it does work with DTML methods then? I can access a DTML method 'foo' defined in the root folder that is only accessible with role A, even if role A is only added to me in a subfolder (from this subfolder).
You probably don't really want to change it to use context instead. It would open a mile-wide security hole.
Depends on how you reason. I was reasoning context based -- I should be able to execute something in the context of the current folder, if I have the right role to do it. That's exactly how it works with DTML methods, so I didn't expect external methods to be different. If you're opening a mile-wide security hole with external methods, then why not with DTML methods?
The view operation fails with a reauthentication request in Zope 2.1.6 (so authentication exception raised presumably).
In Zope 2.2.2 the failure is a NameError for External Methods, and reauthentication for ZClass instances.
Am I missing something terribly obvious, or is this a rather huge bug that's been unnoticed for a long time? I assume it *must* be a bug as DTML methods behave in a different way. I also want it to be a bug, as I don't like this behavior. It makes it very hard to delegate responsibility.
The difference is a result of the change in the way security is handled. It now gets a NameError because the name lookups skip over entries to which you're disallowed access. That logic can be very puzzling, but you might try the ZDebug product which helps you make sense of it.
Okay, I'll try that. I still don't see why DTML methods are different. Could you explain that? That's what initially caused much of my confusion; the DTML methods behave as expected, but call external methods that *don't*, which have *exactly* the same security settings. Note that this policy does make acquisition rather useless for delegating of responsibility, unless you're either using DTML only, or are coding for anonymous only. Regards, Martijn
On Tue, 26 Sep 2000, Martijn Faassen wrote:
Shane Hathaway wrote:
Martijn Faassen wrote:
General problem description:
For a ZClass instance/external methods that is only viewable by users with a particular role, the view operation fails if that role is only added to a user in a place deeper in the folder tree than the folder where the External Method/ZClass instance was defined. This occurs when the 'view' is occuring in the acquisition context of the folder.
It succeeds if the role is added to the user in a folder higher in the tree, at or above the folder where the external method or ZClass instance is defined.
This sounds 100% correct. When checking security, acquisition context is ignored. What matters is *containment* (which is also accessed through the acquisition machinery, but in a special way: aq_inner). A user can only access objects that are defined in a container where the user is granted access.
How come it does work with DTML methods then?
I can access a DTML method 'foo' defined in the root folder that is only accessible with role A, even if role A is only added to me in a subfolder (from this subfolder).
Let's say I'm user Joe and I have a role "Employee" that allows me certain functions throughout the site. A role "DepartmentManager" is also available, but I only have that role where it is given to me as a local role in the "accounting" folder. Let's say there's another folder on the site called "hr", for human resources. If security were context-dependent rather than containment-dependent then I could just access http://www.somesite.com/intranet/accounting/intranet/hr/manage and I'd have "DepartmentManager" privileges in the "hr" folder. Oops! (Note that there is only one "intranet" folder. This URL uses acquisition trickery.) (More info in my reply to your next message...)
Note that this policy does make acquisition rather useless for delegating of responsibility, unless you're either using DTML only, or are coding for anonymous only.
Tell us what kind of security you're trying to set up, and we can probably help you find the right way to do it. Shane
participants (3)
-
Brad Clements -
Martijn Faassen -
Shane Hathaway