Skip to content
Disclosed report

Arbitrary PHP Execution via preg_replace in getpersonas.com

Neal Poole Follow

Originally disclosed on Mozilla

  • Fixed in 2 days
  • Paid in 2.7 years
  • Disclosed after 2 days
Text
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

The original report as published on Mozilla's Bugzilla, by Neal Poole. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A security bug in getpersonas.com. Mozilla made it public on 5 March 2011.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

More by Neal Poole

View all

7 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.