Skip to content

Fixes XSS vulnerability in Profiler #1305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2012
Merged

Fixes XSS vulnerability in Profiler #1305

merged 1 commit into from
Oct 3, 2012

Conversation

nmalcolm
Copy link

@nmalcolm nmalcolm commented Oct 3, 2012

The profiler doesn't sanitize the queries on the SQL tab which can allow an attacker to forge specially crafted queries to attack other visitors, steal cookies, and perform unauthorized browser actions. It does depend on how the developer has developed the application but nevertheless it should be patched. Even if the attack fails it can still render as HTML so the full query doesn't always show.

At first it was hard for me to provide a working PoC (Proof of concept) as the system adds slashes to the quotes in order to, I assume, prevent SQL injection (I haven't check if that's the database or the profiler's doing) but I did manage to forge this:

$input = '<IFRAME SRC=http://www.mybb.com/></IFRAME>';
$query = DB::query("SELECT * FROM `mybb_users` WHERE `username` = ?", array($input));

This results in:

http://i.imgur.com/VA4r2.png

But should be:

http://i.imgur.com/hebkV.png

This pull request fixes an XSS vulnerability in the Profiler. It shouldn't affect any other functionality as far as I'm aware.

taylorotwell added a commit that referenced this pull request Oct 3, 2012
Fixes XSS vulnerability in Profiler
@taylorotwell taylorotwell merged commit 4f8a672 into laravel:develop Oct 3, 2012
@taylorotwell
Copy link
Member

Thank you!

@@ -148,6 +148,7 @@ public static function query($sql, $bindings, $time)
$binding = Database::connection()->pdo->quote($binding);

$sql = preg_replace('/\?/', $binding, $sql, 1);
$sql = htmlspecialchars($sql);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about HTML::encode() or the shortcut e() instead? htmlspecialchars() without the appropriate parameters will just cause other problems... e.g. with single quotes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about using HTML::entities() would be fine. What's the difference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML::entities(). That's what I meant. Brilliant. :)

Just look at the implementation of the function, the parameters are quite important.

@franzliedke
Copy link
Contributor

@taylorotwell htmlspecialchars() is not enough. See my diff comment.

zoe-edwards pushed a commit to zoe-edwards/laravel that referenced this pull request Oct 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants