Menu enable and disable act on a GET request (which they shouldn't). More importantly, this makes it vulnerable to cross site request forgeries; meaning that when you are logged in as admin and visit a malicious site, they can enable/disable your menu items.

This either needs a confirmation form, or a token in the URL.

Note, this concerns a vulnerability in Drupal 6.x-dev only. Report vulnerabilities in released versions by sending an email to security@drupal.org.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

since all enable/disable does is show/hide items, this seems more like a potential annoyance than any kind of security threat.

Heine’s picture

Annoyance is not the word.

People won't like it when their ecommerce site suddenly has no menu.

pwolanin’s picture

ok, so if we want to avoid another annoying confirm form, what would a URL token solution look like?

Heine’s picture

I'm not convinced taking actions on GET is a good idea. What you could do however;

Get a token via drupal_get_token (eg drupal_get_token("menu") or drupal_get_token("menu-{$id}")), simply add it to the link.

In the receiving function, simply verify the token eg: drupal_valid_token($token, "menu-{$id}").

Heine’s picture

Priority: Normal » Critical
pwolanin’s picture

here's a patch that adds tokens to those links as you suggest.

pwolanin’s picture

Status: Active » Needs review
pwolanin’s picture

for preventing both GET and POST CSFR, it's not clear to me that it can be prevented if the "bad" site or script can send an initial GET request to get the page source containing the token/form token? Obviously this requires a more thorough knowledge of the target and more code, but why is this not possible?

moshe weitzman’s picture

pwolanin - the bad site would have to have your session id in order to get a valid token on the url. otherwise they have to send your browser to the drupal site twoce (once to get token and once to send to destination url). if they can do that they really own you.

Heine’s picture

While a script can post to a certain URL, reading the token is prevented by the browser's cross domain security policy. See http://msdn2.microsoft.com/en-us/library/ms533028.aspx.

pwolanin’s picture

ok, thanks for the clarification. So, is this token solution sufficient, or would it still be better to go for a confirm form? Or something else (e.g. we could turn this page into a form and enable/disable could be buttons rather than links)?

Heine’s picture

Status: Needs review » Needs work

The access denied is a bit to harsh; a message about a validation error and the tip to refresh the menu might prevent panic on cached pages.
I'd put the token as a url part, not in a separate querystring, but that's a detail.

Gábor Hojtsy’s picture

I think it would be better consistency wise too to make this page a form. It looks quite pointlessly repetitive to output dozens of tokenized links.

anders.fajerson’s picture

This page is becoming a form due to the drag and drop work: http://drupal.org/node/181126. An enable checkbox seems like a good option here.

chx’s picture

Assigned: Unassigned » chx
Status: Needs work » Needs review
FileSize
9.67 KB

I took quicksketch's patch and simplified the form and added a submit handler. I am not 100% that quicksketch's D&D will get in D6 but if it does, it's quite trivial to augment my patch to become his. The submit function shows the sheer power of FAPI3 :) If you want to test do not forget to rebuild your menu.

brenda003’s picture

Status: Needs review » Needs work

With this patch applied, if I add a node and use the "Menu settings" option, the link shows up on the actual navigation but not under admin/build/menu settings anywhere.

chx’s picture

I did a fresh install and I am unable to reproduce this.

brenda003’s picture

It was an issue w/ pager not showing up.

chx’s picture

Status: Needs work » Needs review
FileSize
11.8 KB

Added pager. Got tons of notices. Fixed notices at its core -- menu_tree_data was no prepared that it might not start at root. Removed a helper variable there as there was little point. Now works well.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Installed this. Created menu items from both the node/edit node/add and admin/build menu forms. All seems to be fine.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Generally loooks good, but:

- I don't understand why we complicate our code with an empty output first:

+  $output = '';
+  $output .= theme('table', $header, $rows, array('id' => 'menu-overview'));

- This patch gives menu_overview_form() a multiline function comment, which does not fit coding standards.

These are not big issues though.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
11.8 KB

If these are not big issues then why not commit and reopen as minor? Grr.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

OK tested the patch:

- I would put the enabled checkboxes to the left of the table, as it is in the module listing (or the language listing, or...).
- It looks quite strange to see the "expanded" information, but not being able to modify it (need to go to edit). Why don't make a checkbox out of it?
- Empty menus show an empty table and a Submit button, instead of a friendly note that there are no menu items yet.
- We removed "Submit" buttons and used "Save" "Save settings" etc. labels instead to be more to the point. Here "Save configuration" seems to be fit for the purpose.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
12.21 KB

Changes as requested. I would like to draw attention to this submit function which utilizes quite some form API 3 goodies to achieve simplicity.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs review

Testers welcome.

brenda003’s picture

Status: Needs review » Reviewed & tested by the community

Tested and looks good.

chx’s picture

FileSize
12.29 KB
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Active
FileSize
28.76 KB
27.66 KB

Although chx did not mention, he implemented my suggestion to move the Enabled checkbox column before the Expanded column and add align=center to the checkbox cells for consistency with other such forms throughout Drupal. Tested the new patch again, and everything seems to work fine, so committed. (I did remove "sortable drag and drop" from the comment "Theme the menu overview form into a sortable drag and drop table." though, as it is not what's happening here :)

However, there is a UI problem here still, which should be solved in a follow up patch. See the attached images. The UI looks as good as it can be when the window is not wide. But when the window is wider, big gaps appear. Actually, the enabled and expanded columns should not expand in size, but the menu item column should take up the space (or the table should not expand at all). Let's get this solved, and we can close this issue.

quicksketch’s picture

Rock! Thanks chx! This'll make the Drag and Drop patch for menus (http://drupal.org/node/181126) much smaller and easier. Note that I'll probably switch the column order if that's acceptable to use the title first, then checkboxes. That way the drag handle will be on the left side next to the title, rather than a bunch of checkboxes.

Gábor Hojtsy’s picture

OK, we will discuss checkbox placement there then.

chx’s picture

Goba, if you think the other issue will get in, then please set this to fixed.

Gábor Hojtsy’s picture

Sure, will do as soon as this turns out.

Gábor Hojtsy’s picture

Status: Active » Fixed

Looked into http://drupal.org/node/181126, so I am closing this in the hopes that the UI issues will be fixed with the menu DND. These UI issues are not critical anyway.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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