A role that doesn't have permission to create nodes of a given content type can still create them if the content type contains an underscore in its machine name.
Example:
Content type machine name: content_type1
User doesn't have permission to create/edit nodes of type content_type1, but there is a bug that allows him to create such nodes.
If the machine name is renamed to contenttype1, without the underscore in the machine name, everything works normally, and user cannot create nodes of contenttype1 if he doesn't have the permission.
Comments
Comment #1
mlachance commentedThis is a security flaw. Flagged as critical.
Comment #2
joachim commentedCould you explain how to reproduce this?
I made a content type called 'under_score' and as an anon user I get an access denied at node/add/under-score
Comment #3
odegard commentedI've got a site with users allowed to create node types of type A. I then created a new content type called test_test. I did not give permission to create test_test for this particular user. Tried to create a node by going to /node/add/test_test but that did not work.
So, can not reproduce I guess.
Comment #4
dunlop commentedInstead of using:
/node/add/test_test
for the test, the path should be:
/node/add/test-test
since underscores are converted to hyphens when used in a url.
Comment #5
joachim commentedI still can't reproduce this.
Comment #6
miiimoooIt's correct that you get an "access denied" on node/add/HYPHENATED-CONTENT-TYPE-NAME
The problem really is with menu_router but I can't exactly see where it is:
To reproduce:
1. (as before) create a content type with an underscore content_type1
2. go to permissions and remove the create permission for this content type from authenticated user (or admin)
3. create a menu entry node/add/content-type1 in a visible menu
4. result: although the role doesn't have permission to create content of type content_type1 the menu item is still shown. Clicking the link takes you to "access denied". Here the check is done correctly.
My suspicion is that the router access check for node/add/content-type1 somehow leads to a check for creating content in general but I can't see where this happens. It's linked to the underscore.
Maybe this should be in the menu component.
UPDATE: And just now as I clicked refresh the menu item disappeared. I guess it's a menu router rebuild issue then.
Comment #7
marcingy commentedThis is not critical as you can't actually do anything it gives a 403.
Comment #8
pasqualle- inaccessible menu items are not displayed, that's how it works
- nobody can reproduce the origin issue reported here