Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
shortcut.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Mar 2014 at 14:18 UTC
Updated:
20 Feb 2015 at 16:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mariusz.slonina commentedComment #2
mariusz.slonina commentedIn Drupal7 the shortcuts links are rendered through
menu_load_linksmenu_tree, and the access for each item is directly checked. In current HEAD however, entity_load is used, and shortcut_renderable_links function does not take into account the menu link access. From _menu_link_translate I borrowed$item['access'] = \Drupal::getContainer()->get('access_manager')->checkNamedRoute($item['route_name'], $item['route_parameters'], \Drupal::currentUser());Simple patch attached - this is my first D8 patch attempt and I don't understand many things going on under the hood, however I am willing to help on this issue
Comment #3
mariusz.slonina commentedComment #5
dawehnerI consider this at least as major. Note: access checking was done previously using menu_tree() so we kinda lost the functionality while converting shortcuts to its own entity type.
You could use this nice little shortcut:
Comment #6
dawehner---
Comment #7
lokapujyaI will try it.
Comment #9
dawehnerNote: #2235457: Use link field for shortcut entity probably also fixes the bug. For this case here you could store the $url object and then use
$url->access()...Comment #10
lokapujyaI think testAccessShortcutsPermission needs to give the "Administer site configuration" permission to authenticated user in order to fix the 2 remaining fails.
Comment #11
lokapujyaComment #12
dawehnerThat fix for itself is fine.
Added a beta evaluation.
Comment #13
catchInformation disclosure -> critical.
Comment #16
dawehnerWorking on it in the sky
Comment #17
dawehnerDid not a straight reroll but rather adapted the test coverage to be a little bit more sensible.
Comment #19
larowlanlooking at fails
Comment #20
larowlanSo the fix broke existing tests for using shortcuts, which is good - and what we want - so I fixed them and expanded them to ensure we have coverage for 'using' shortcuts.
The new tests in earlier patches for admin lists, didn't handle access there.
So changed that to not show the operation links if no access to the link (we don't let you add them, so why would we let you edit them) - and same story for titles - if you can't access the link - we make the title 'N/A' - the form still works - but you can't get the information disclosure.
This is inline with how we handle those with 'administer comments' who can don't have access to commented entity.
Comment #21
larowlanComment #22
dawehnerNot convinced here ... the URL the shortcut links to could also have information in there, as the path aliases might got resolved.
Comment #23
larowlanOk, I can make #access => false on the row, but we then need to fix #theme table (or w/e it uses) to not output an empty row
Comment #24
dawehnerwell that, or just wrap it with an if() statement. I think this is fine for security purposes, honestly.
Comment #25
berdirIsn't completely hiding a shortcut row going to mess up the weights which are set there?
Comment #26
lokapujyaRemoving access to see shortcuts by a user with "administer shortcuts" doesn't need to be part of this issue.
Comment #27
larowlanI'm not so sure, we don't let people create shortcuts to paths they have no access to, so we shouldn't let them view/edit them either.
Let's get some committer feedback
Comment #28
catch'administer shortcuts' doesn't have
restrict access: trueso unless we add that, then you shouldn't be able to see anything with that permission that you wouldn't otherwise have access to.Comment #29
catchTagging.
Comment #30
dawehnerSo let's hide it entirely.
@Berdir
As far as I see, we don't recalculate the weights?
Comment #32
berdirI think the JS does, if you move something around?
So access overview with a shortcut that you can't access, move something around, then the hidden one will not be updated and be in a wrong location.
Comment #33
dawehner@berdir
In this case we have the same problem for menu trees as well, or pretty much everything which uses the JS and access checking.
Just a reroll in the meantime.
Comment #35
berdirSure, I guess it is a very theoretical problem, because which site is going to give that permission to users that do not have full access anyway. But better safe than sorry :)
Comment #37
dawehnerLet's fix the missing permissions.
Comment #38
larowlanBut it won't effect you because you'll never see those shortcuts anyway.
It will effect the admin, who can go in an fix it.
In other words I think we can live with that.
Comment #39
larowlanThis can go now (done in attached)
Manual testing
Super-admin adds shortcut to admin/config/development/performance
Non super admin user has shortcut admin role
shortcut admin role has permission to edit shortcuts
Non super admin user can edit shortcut links but doesn't see links they should not
Non super admin can't see shortcuts with no access
RTBC in my book
Comment #40
larowlanMissed last screenshot
Comment #41
larowlanComment #42
lokapujyaRemove 2nd parameter.
same.
note: I see 2 other places in Core with the same problem.
Comment #43
lokapujyaComment #44
larowlanWhat?
Comment #45
berdirNice find.
AssertNoLink() has no index (the 0). so we're using 0 as the message, and the message as the group.
Comment #46
larowlanooh, lokapujya++
Comment #47
dawehnerGood catch!!
Comment #48
jibranBack to RTBC then.
Comment #49
alexpottShouldn't we be clicking shortcuts here and then testing that cron does not appear? Because I think what we are verfiying here is something else.
Comment #50
dawehnerWell, ... those shortcuts does not appear on the page, as the user doesn't has access to it. How would you click on them?
Comment #51
berdirYes. This is all about visibility of the shortcut links. Whether the user can actually visit that page or not has nothing to do with shortcut.
Comment #52
webchickGreat. Committed and pushed to 8.0.x. Thanks!