Problem/Motivation
When users with the "administer comments" permission go to 'admin/content/comment', they are able to see node titles for nodes that they wouldn't otherwise have permission to see (unpublished nodes, for example). While they can't access those nodes, they can still edit the associated comments using the 'edit' link.
Proposed resolution
The issue with listings of nodes, which are controlled by node access API, was taken care of by the patch from Comment #11, committed by webchick in Comment #22.
Remaining tasks
A solution needs to be found to dealing with comment editor's access to unpublished nodes. Published/unpublished access control is part of hook_node_access() which is only applied to single nodes.
User interface changes
None based on Patch #11; TBD for remaining problem
API changes
None based on Patch #11; TBD for remaining problem
Original report by Stella
This is public hardening issue brought to you by the security team.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 904214-drupal-comments-19.patch | 4.37 KB | coltrane |
| #18 | drupal_904214.patch | 3.53 KB | tobiasb |
| #11 | comment_admin.patch | 694 bytes | moshe weitzman |
| #8 | drupal-904214.jpg | 41.79 KB | tobiasb |
| #6 | 904214-access-title-comments_admin.patch | 4.05 KB | tobiasb |
Comments
Comment #1
dawehnerThe question is whether it's good to load every node on this page. This is not a problem for performant sites, because they use entity-cache.
One advantage here is that there is no need to join the node table anymore.
Comment #2
dawehnerComment #4
tobiasbComment #5
tobiasbDisplay 'Access denied' for the node title and for the comment subject "FooBar ('Access denied')" without the link to node or comment.
And I added a test.
Comment #6
tobiasbComment #7
dawehnerA screenshot would be fine here.
Comment #8
tobiasbComment #9
moshe weitzman commentedEr, thats really weird behavior. IMO, this node nor any of its comments should be listed to unauthorized users. The comments belong to the node and are similarly inaccessible. So the fix is to add the node_access tag to the query.
Comment #10
moshe weitzman commentedComment #11
moshe weitzman commentedThis 1 line is all it takes IMO
removing needs tests tag because node access system has tests. we just weren't using node access.
Comment #12
tobiasbthe last patch don#t work for me.
Comment #13
moshe weitzman commentedYou are going to have to provide more detail than that. Please elaborate. The intent of my patch is that these inaccessible comments are not shown at all. It is not Drupalish to show them but not be able to view/edit/delete. Whats the point of showing 'access denied'?
How are you restricting access? I am using the hidden node_access_test module.
Comment #14
tobiasbmy testuser with the permission "administer comments ... " see the comment/node title from a unpublished node and thats not what we wanted. Or in other words, I couldn#t see a different w/o the patch. And I believe
addTag('node_access');works only for selects likedb_select('node', 'n').Comment #15
moshe weitzman commented@tobias - that unpublished use case is different than the one i was trying to fix. i was focused on nodes that were protected by the node access API. your case is not easy to solve in a performant way. the published/unpublished access control is part of hook_node_access() which is only applied to single nodes, and does not apply to a listing. A listing uses node access API. Sorry about the confusing language here. Its unfortunate.
We still need to do the patch I proposed.
Comment #16
agentrickardNode access _alter queries should account for node visibility (published/unpublished). It is possible that the issue in #14 was solved by #920614: Unpublished content visible when a Node Access module is enabled.
Comment #17
salvisYes, hiding inaccessible nodes from admin/content/comment is a must.
The patch works fine with Forum Access (plus the core patch in #553944-154: Define hook_menu_get_item_alter() as a reliable hook that runs before the page is doomed).
comment/CID[/view] is already blocked, however comment/CID/edit isn't!
Is this a security hole in core?
Comment #18
tobiasbEdit:
Comment #19
coltrane#18 updated with node_access() check for edit. Patch works great.
Comment #20
salvisThe snippet in #18 looks good.
However, you're eliminating rows after the pager query, which means you end up with less than 50 (possibly even zero!) rows per page.
Comment #21
salvisWe got side-tracked here. We should at least commit moshe's patch in #11.
The rest can be dealt with later.
Comment #22
webchickOk, #11 committed to HEAD.
Back to.. needs work?
Comment #23
salvisThanks! Yes.
My grasp of the unpublished situation is still not good enough to deal with this. The first priority should be to get this to work correctly without any node access module. What is correct behavior?
Probably to block view/edit of all comments of unpublished nodes that are not visible to the user. Taking into account the 'view' accessibility of the nodes (which includes published state) in listings should be necessary and sufficient. If the NA modules implement this correctly, then it should work with them, too.
Could this be as easy as adding
$query->addTag('node_access');to the comment query in comment_admin_overview()? How does core restrict the listing of unpublished nodes?More questions than answers and no time right now...
Comment #24
Tor Arne Thune commentedComment #25
Bojhan.core commentedA normal bug?
Comment #26
salvisYou could call it a sechole, too...
Did #11 make it into D7?
Comment #27
agentrickardYes. It's in 7.7.
Comment #28
dawehnerI'm not sure about d7 but shouldn't we load the full user as well? Wait shouldn't this be the current user looking at the list of nodes?
I'm wondering whether it would make sense to lazy-load the node only when the other access checks are TRUE
It would be probably easier to understand if there would be a comment what exactly is the issue here.
-3 days to next Drupal core point release.
Comment #28.0
TransitionKojo commentedUpdating the issue summary to reflect the current state of the issue; patch from Comment #11 is already committed
Comment #28.1
TransitionKojo commentedformatting change
Comment #29
hefox commentedBased on IRC discussion, the current security stance is that users do not need to be able to see a node to be able view/edit/delete a comment on it. This very much surprised me.
Opened the broader issue #1781766: Enforce that a user must be able to view a node to view/edit/delete the comments of that node to try and change that stance so that view/edit/etc. a comment is depending on ability to view the node.
Comment #29.0
hefox commentedUpdated Issue Summary using the Issue Summary Template
Comment #30
mgiffordComment #31
jonathanshawPatch in #11 is committed, current security policy is to allow editing of comments on a node without permission for the node, discussion of this has moved to #1781766: Enforce that a user must be able to view a node to view/edit/delete the comments of that node, therefore close this issue as won't fix.
Comment #32
mgiffordAlmost sounds like it's a duplicate...
Comment #33
jonathanshaw#1781766: Enforce that a user must be able to view a node to view/edit/delete the comments of that node is a follow-up to this one; it's IS explains the relationship.