#5487 closed defect (bug) (fixed)
query.php mistakenly uses is_admin() to check for admin privileges
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | high | Milestone: | 2.3.2 |
| Component: | Security | Version: | 2.3.1 |
| Severity: | major | Keywords: | query is_admin has-patch dev-feedback |
| Cc: |
Description (last modified by lloydbudd)
- Create a draft post
- Log out
- Visit http://yourblog.com/index.php/wp-admin/
- is_admin() spots the wp-admin in the request and returns true
- query.php uses is_admin() to decide to return future, draft or pending posts
- Future, draft and pending posts are displayed.
This doesn't require the ' in the request string as reported on Bugtraq.
See http://www.securityfocus.com/archive/1/485252/30/0/threaded
12/22 additional disclosure, with trivial, popular example: http://www.blackhatdomainer.com/how-to-know-today-what-shoemoney-is-going-to-post-tomorrow/
Attachments (2)
Change History (20)
- Keywords has-patch dev-feedback added
Attached patch replaces is_admin() check with current_user_can('level_10'). Perhaps we could explicitly check the user's capabilities but I wasn't sure from the documentation which capabilities we should be looking at. Instead I've just checked if the user is the administrator or not.
What I did (Wordpress 2.3.1):
- Logged into wp-admin with Firefox.
- Created a new post called "DRAFT", with text "DRAFT"
- I saved it (but did not publish it)
- I opened another browser (Opera).
- I tried using the URL you had above (modified for my site) and it does not show me drafts.
- I tried adding the p=<post number> get argument, but I just get a blank page.
I cannot reproduce this problem.
Will the current_user_can() allow the author (possibly a non-admin) to view the draft post that he/she just wrote?
Ciao!
We do a current_user_can() check in the block of code already. is_admin() is used to see what context the user is in. Is the user in the admin? I think we need to retain is_admin() and have it check a constant set in admin.php to determine admin context.
Hmm, the current_user_can() check is just for private posts. I think we need both an is admin user and is in the admin checks.
Actually, edit-pages.php and edit.php filter the results of the is_admin() query. So I think all we need is a proper is_admin() check and not any cap checks.
New patch improves is_admin().
Old patch was confused over why is_admin() was used in the first place.
Thanks to Austin Matzko from wp-hackers for the idea.
comment:10
ryan — 5 years ago
- Resolution set to fixed
- Status changed from assigned to closed
comment:11
in reply to:
↑ 4
docwhat — 5 years ago
Replying to docwhat:
What I did (Wordpress 2.3.1):
Finally, someone posted what was missing. The unposted drafts have a date of something really old (1969 or 1999). You have to search back into the archive to find it.
Ciao!
comment:12
ryan — 5 years ago
comment:13
lloydbudd — 5 years ago
- Milestone changed from 2.4 to 2.3.2
comment:14
lloydbudd — 5 years ago
- Description modified (diff)
comment:15
markjaquith — 5 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
$wp_query->is_admin (the var) is checked in some places and is still using the old logic instead of the is_admin() function. Shouldn't we fix that too? See patch.
comment:16
ryan — 5 years ago
comment:17
ryan — 5 years ago
comment:18
ryan — 5 years ago
- Resolution set to fixed
- Status changed from reopened to closed

See line 1172 of query.php for the misuse of is_admin()