Closed
Bug 638359
Opened 15 years ago
Closed 15 years ago
Arbitrary PHP Execution via preg_replace in getpersonas.com
Categories
(Websites Graveyard :: getpersonas.com, defect)
Websites Graveyard
getpersonas.com
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: neal, Assigned: chenba)
Details
(Keywords: reporter-external, Whiteboard: [infrasec:osinject][ws:critical])
Attachments
(2 files, 1 obsolete file)
|
633 bytes,
text/plain
|
Details | |
|
1.60 KB,
patch
|
clouserw
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Build Identifier:
The following code comes from templates/persona_detail.php:
$desc = preg_replace('/(https?\:\/\/[^ ]+[A-Za-z0-9\/])/e',
'"<a href=\"".external_link(\'\\1\')."\">\\1</a>"',
htmlspecialchars($persona['description']));
There is similar code in template/persona_detail_delete.php:
$desc = preg_replace('/(https?\:\/\/[^ ]+[A-Za-z0-9\/])/e', '"<a href=\"".external_link(\'\\1\')."\">\\1</a>"', $persona['description']);
Both of these pieces of code are vulnerable to arbitrary code execution. They're vulnerable because the second reference to \\1 is included in double quotes: through a judicious use of braces, it's possible to cause arbitrary functions to be executed when viewing the page. I'll attach a proof of concept that demonstrates what I'm talking about.
My suggestion would be to replace these preg_replace calls with calls to preg_replace_callback.
Reproducible: Always
| Reporter | ||
Comment 1•15 years ago
|
||
This example, when run, will make a call to preg_replace using the code from getpersonas.com on specially formed input. This input will cause PHP to execute the function named in $_GET['cmd'] (defined at the top of the script to be phpinfo).
Updated•15 years ago
|
Attachment #516507 -
Attachment mime type: application/octet-stream → text/plain
Comment 3•15 years ago
|
||
Possible fix would be to remove the /e modifier from the regex then construct the url after the replace.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [infrasec:osinject][ws:critical]
Comment 5•15 years ago
|
||
Proposed patch with Neal's suggestion for preg_replace_callback(). Also added missing htmlspecialchars() to persona_detail_delete
| Assignee | ||
Comment 6•15 years ago
|
||
There were a couple of trailing commas in the arguments to create_function(), otherwise dchan's patch worked for me.
Thanks, Neal and David.
Attachment #516659 -
Attachment is obsolete: true
Attachment #517083 -
Flags: review?
Comment 7•15 years ago
|
||
Comment on attachment 517083 [details] [diff] [review]
dchan's preg_replace_callback patch with trailing commas remove
Oh getpersonas. What would we do at 10:30pm on a friday if it weren't for you.
Barry - go ahead and land, let's verify on stage.
Attachment #517083 -
Flags: review? → review+
| Assignee | ||
Comment 8•15 years ago
|
||
It's in r84047.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•15 years ago
|
Group: websites-security
Status: RESOLVED → VERIFIED
Updated•13 years ago
|
Product: Websites → Websites Graveyard
Updated•13 years ago
|
Flags: sec-bounty+
Updated•2 years ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•