When used in conjunction with nodeaccess_password, if an anonymous user accesses a node using the correct password, the cache_set() in nodeaccess_nodereference_calculate_grants() causes a grant to be cached for user 0, which is then retrieved by nodeaccess_nodereference_node_grants() on future node views.

This means that the first anonymous user to access a protected node with the correct password effectively "unlocks" that node to the rest of the world, so anyone can access it from any browser or IP address, without logging in or entering a password.

Comments

morbiD’s picture

Priority: Normal » Minor

This is probably going to be an extremely rare occurance. It only happens with funky combinations of node references and passing on of permissions, possibly only with the use of the propagate settings in #1471584: Passing grants to referred nodes.

The config I was using that triggered this was pretty random, but I had 3 content types (let's call them A, B and C).

B inferred view permissions from A.
C also passed view permissions to B and B also passed view permissions to A.
I set up password protection on B.

So when anonymous viewed B, the view permission bounced to A and back to B, which caused the caching issue.

I've altered my settings slightly by stopping B inferring from A since it was unnecessary, and the issue has stopped.

I don't know if this kind of occurrance should be solved here or in the other issue.

danielb’s picture

So basically you're saying... don't call set_cache when uid is 0 ?

morbiD’s picture

Yeah, that would work. I originally traced the issue by commenting out the set_cache().

I was wondering if there was any better way to handle it without completely disabling caching for user 0, but if you're happy with that :)

danielb’s picture

Status: Active » Fixed

If the uid is 0 it'll use the session id instead now

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.