Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
dashboard.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2010 at 21:37 UTC
Updated:
16 Jul 2010 at 15:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
Bojhan commentedThis is because the individual blocks are accesible by permission. Its a bit strange indeed.
Comment #2
jacineHmm, so what is the point of having a "View the administrative dashboard" permission?
Comment #3
Bojhan commentedWell, its a bug? I think its pretty clear that it is.
Comment #4
tstoeckler@Bojhan: could you elaborate:
... what you mean by this?
Comment #5
Bojhan commentedThe blocks you can see, because permissions allow you to see it.
Comment #6
tstoecklerAs in,
because they have not explicitly been restricted to certain roles via the block visibility settings?
Comment #7
yoroy commentedI can't reproduce on fresh HEAD, getting a plain 'acces denied' for anonymous on /admin (which is where dashboard lives now), without seeing anything dashboardy.
Comment #8
yoroy commentedDowngrading for now…
Comment #9
jacine@yoroy - you need to on one of the following to reproduce:
1 - Make sure your admin theme is the same as your front end theme.
2 - Place block(s) in dashboard regions for the front end theme.
I just tried it on a fresh install, and it's the same. I have a bad feeling this is "by design" though.
Comment #10
David_Rothstein commentedHere's a quick patch that should fix the bug.
This doesn't address the awkward markup, though. The problem is that Drupal 7 theoretically allows the main content block to be placed in any region of the page (too much flexibility?) so it's therefore not so easy for the dashboard module to find where it is and insert stuff into it. I'm guessing it's possible to fix - but probably best as a separate issue.
Comment #11
jacineSweet! Thanks David_Rothstein :) It works. Will wait for the testbot to RTBC and open a separate issue for the markup problem.
Comment #12
jacineComment #13
yoroy commentedI'd be interested in a little explanation of what you are doing here. I see in the patch that you add some kind of acces check. Can you do the 'for dummies' breakdown of this problem and fix? Just for kicks and learning :)
Comment #14
sunNot sure whether this patch is based on the assumption that #652122: Fix dashboard as the default /admin local task is given. If it is, then it needs a different solution.
Comment #15
tstoeckler@yoroy: I'll try for #13. I'm not too sure myself, so please correct me, if that's incorrect.
When you visit the admin/dashboard page (or whatever the URL is currently), the menu router (is that the right word?) is called to determine what to show to you. Part of that menur router is the page callback, which is already being referenced in $is_visible as you can see in the patch. Menu routers also have an access callback though, to see if you (as in the user) is allowed to see the page. That access callback returns either 1 or 0 depending on if you're allowed to see it. So the patch introduces a check to see if the access callback actually does return 1.
Comment #16
David_Rothstein commentedYes, I think that explanation is about right... Although actually, this is probably a really bad example to learn from, since the dashboard is doing some odd things :)
But a bit more detail: If you look at the list of dashboard module menu items, you see this code:
The last part tells Drupal that only users with the 'access dashboard' permission can view the page. When the page is actually visited, the menu item gets processed to add a new element 'access' which is set to 0 or 1 (or maybe FALSE or TRUE - same thing basically) depending on whether or not the current user actually has that permission.
Drupal automatically uses this information to replace the main page content with the "Access Denied" message when necessary. However, the other blocks on the page besides the main page content still need to be displayed; that's how "access denied" pages still get things like menus, the user login block, etc. For most pages in Drupal, that automatic behavior is enough and is exactly what you want.
In the case of the Dashboard module, the dashboard content is actually added in these other page regions (not part of the main page content) - basically in order to interface with the Block module's method of managing page regions. So it has a custom function dashboard_is_visible() that is called from various places and determines when to add all the dashboard content to the page. So from the patch:
Previously it just checked the 'page callback' from above - to see if we are on the correct page. And afterwards, it checks the 'access' property too, to make sure the current user is actually supposed to be able to see it.
Comment #17
David_Rothstein commentedRe #14:
I think it's OK since it's specifically checking the page callback, not the URL, so it shouldn't matter what happens there. We are basically just saying that dashboard_is_visible() should return TRUE only when we are visiting whichever menu item is trying to display the dashboard (and if the current user has access to that menu item).
Comment #18
tstoecklerWow, thanks. #16 is a *really* good explanation!
Comment #19
yoroy commentedExcellent, thanks for this to you both :)
Comment #20
dries commentedI recommend that we include some of the explanation in #16 in the PHPdoc of dashboard_is_visible(). I do think, though, if we want Drupal core to support much more advanced layouts/regions, that this needs to be addressed in a better way. Might be a good topic for the Drupal Developer Summit in SF.
I think it could also be a security concern. Menu routers are applied to paths (i.e. pages or URLs) so one would expect the entire page to be protected. It doesn't make sense to apply it to one region only.
Comment #21
yoroy commentedNeeds work to add the comments then. Agree that this is a summit-worthy topic :)
Comment #22
David_Rothstein commentedHere's a patch with code comments.
Also marking this as critical, since it's a (minor) access bypass vulnerability.
Comment #23
catchPatch looks fine but this looks like it a test would be easy to write and quite useful.
Comment #24
EvanDonovan commentedSubscribing.
Comment #25
jody lynnI'm writing a test.
Comment #26
jody lynnHere's the patch with a corresponding dashboard.test
Comment #27
David_Rothstein commentedYay, the first dashboard module test!
But...
For the first one, I'd use assertResponse() - check for 200 vs 403 - rather than looking for text on the page. For the second one, "dashboard" is misspelled. (And the same thing goes for the similar block of code that appears in the patch below this one.)
Comment #28
lotyrin commentedsub
Comment #29
lotyrin commentedReroll #22 and #26 against CVS, with suggestions from #27.
Comment #30
lotyrin commentedOops, didn't get my changes regarding #27 part 2 into that patch.
Comment #32
lotyrin commentedComment #33
David_Rothstein commentedThanks!
Found a couple minor issues:
I think this should be moved up one line so that the files[] stuff is all together.
This is a out of date (due to API changes in the interim). It should now refer to dashboard_block_list_alter() instead.
Sentence should end in a period.
(very minor) Probably no need for a space in between these.
This should be a complete sentence - I'd suggest maybe "Test access control for the dashboard."
(very minor) Probably no need for a space in between these either.
Comment #34
lotyrin commentedSuggestions from #33, check application against CVS.
Comment #35
carlos8f commentedAwesome... dashboard.test! A couple suggestions didn't make it into the patch...
should now refer to dashboard_block_list_alter() instead.
should end with a period.
fix those and it's RTBC.
Comment #36
lotyrin commentedOops. Missed those.
Comment #37
lotyrin commentedComment #38
catchComment #39
dries commentedIt is not clear why we fiddle with the theme?
Comment #40
David_Rothstein commentedI assume it's because the bug above only happens under those circumstances. And it's certainly the case that the test will (erroneously) pass even without the rest of the patch, if the code were taken out...
I rerolled with some code comments attempting to explain that, and also moved it into the test function itself since it's so intimately tied to that particular test. I also renamed the overall test case to "Dashboard access" since that's specifically what it's testing (and is what the description already said).
Comment #41
David_Rothstein commentedEr, scratch that - I only did the second of those two things, not the first :) I was going to do the first, but then realized the second would be better. Given that the test case is now specifically only for dashboard access, it is OK to leave this code in the setUp() method, since its purpose is to be able to correctly do dashboard access tests.
Comment #42
yoroy commentedI'm thinking that's a good enough explanation :)
Comment #43
webchickNice. This looks great, adds tests, has awesome comments, and nails a critical at the same time! What's not to love? :)
Committed to HEAD!
Comment #45
David_Rothstein commentedThe fact that the dashboard tests added here were never committed!! :)
These still pass when run locally and were already RTBC above as part of the original patch, so I'm boldly setting this directly to RTBC.
Comment #46
mcrittenden commentedSeems like if all that is left is tests then it's no longer critical, no?
Comment #47
webchickD'oh! My bad. :( Committed to HEAD for real this time. ;) Thanks, David!