Waraxe IT Security Portal
Login or Register
July 27, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 209
Members: 0
Total: 209
Full disclosure
CyberDanube Security Research 20240722-0 | Multiple Vulnerabilities in Perten/PerkinElmer ProcessPlus
[KIS-2024-06] XenForo <= 2.2.15 (Template System) Remote Code Execution Vulnerability
[KIS-2024-05] XenForo <= 2.2.15 (Widget::actionSave) Cross-Site Request Forgery Vulnerability
CVE-2024-33326
CVE-2024-33327
CVE-2024-33328
CVE-2024-33329
CyberDanube Security Research 20240703-0 | Authenticated Command Injection in Helmholz Industrial Router REX100
SEC Consult SA-20240627-0 :: Local Privilege Escalation via MSI installer in SoftMaker Office / FreeOffice
SEC Consult SA-20240626-0 :: Multiple Vulnerabilities in Siemens Power Automation Products
Novel DoS Vulnerability Affecting WebRTC Media Servers
APPLE-SA-06-25-2024-1 AirPods Firmware Update 6A326, AirPods Firmware Update 6F8, and Beats Firmware Update 6F8
40 vulnerabilities in Toshiba Multi-Function Printers
17 vulnerabilities in Sharp Multi-Function Printers
SEC Consult SA-20240624-0 :: Multiple Vulnerabilities allowing complete bypass in Faronics WINSelect (Standard + Enterprise)
[waraxe-2009-SA#070] - Multiple Vulnerabilities in MKPortal <= 1.2.1





Author: Janek Vind "waraxe"
Date: 15. January 2009
Location: Estonia, Tartu
Web: http://www.waraxe.us/advisory-70.html


Description of vulnerable software:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MKPortal is a free Portal/Content Management System (CMS) which seamlessly
integrates with the most popular forum softwares. It uses the forum user
management system and other features and adds many powerful modules to create
and manage a light but powerful web site. MKPortal has an intuitive user
interface and is very simple to install and administer.

Homepage: http://www.mkportal.it/


List of found vulnerabilities
===============================================================================

1. Insecure file upload in blog personal gallery
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: critical
Preconditions:
1. attacker must be registered user
2. attacker must have blog editing privileges

Registered users with blog keeping privileges can access personal gallery
functionality, example URL:

http://localhost/mkportal.1.2.1/index.php?ind=blog&op=p_gal

They can also upload image files to the server. File uploading can be
dangerous without proper security checks. So let's have a closer look
at the source code of "modules/blog/index.php" line ~2452:

---------------------[source code]---------------------
function upload_imm () {
global $mkportals, $DB, $mklib, $Skin, $_FILES;

...
$file = $_FILES['FILE_UPLOAD']['tmp_name'];
$file_name = $_FILES['FILE_UPLOAD']['name'];
//$file_type = $_FILES['FILE_UPLOAD']['type'];
$peso = $_FILES['FILE_UPLOAD']['size'];

if (!$file) {
$message = "{$mklib->lang['b_compfile']}";
$mklib->error_page($message);
exit;
}

//Validate file extension
$file_ext = preg_replace("`.*.(.*)`", "\1", $file_name);
$file_ext = substr ($file_name, (strlen($file_name)-3), 3);
$file_ext = strtolower($file_ext);

switch($file_ext)
{
case 'gif':
$ext = 'gif';
break;
case 'jpg':
$ext = 'jpg';
break;
case 'png':
$ext = 'png';
break;
case 'tif':
$ext = 'tif';
break;
case 'bmp':
$ext = 'bmp';
break;
default:
$ext = 'not_supported';
break;
}
if ($ext == "not_supported") {
$message = "{$mklib->lang['b_gnotsup']}";
$mklib->error_page($message);
exit;
}

--------------------[/source code]---------------------

So this piece of code suppose to be let in only files with specific extensions.
In reality it will pass through files like "foobar.agif" or "whatever.pbmp ...
Let's assume, that we have jpg picture named "pic.php.jjpg". This can be valid
picture file and in same time contain malicious php code inside.

What happens next:

---------------------[source code]---------------------
//Move file from server tmp directory to blog "tmp" directory
if (!move_uploaded_file("$file", "mkportal/blog/images/tmp/$file_name")) {
$message = "{$mklib->lang['b_nopermupl']}";
$mklib->error_page($message);
exit;
}
@chmod("mkportal/blog/images/tmp/$file_name", 0644);

//Validate by mime type
$tmpfilename = "mkportal/blog/images/tmp/$file_name";
$size = @getimagesize($tmpfilename);
//If getimagesize does not recognize file as an image delete file
if (!$size) {
@unlink($tmpfilename);
$message .= "{$mklib->lang['error_filetype']}";
$mklib->error_page($message);
exit;
}
--------------------[/source code]---------------------

As this image file is perfectly normal jpg picture, then it will bypass
"getimagesize()" successfully. And "chmod()" will not make any differents in
specific situation.

Next:

---------------------[source code]---------------------
$file_type = $size['mime'];

if (!$mklib->check_attach($file_type, $file_ext)) {
//Delete invalid file and display error
@unlink($tmpfilename);
$message .= "{$mklib->lang['b_gnotsup']}";
$mklib->error_page($message);
exit;
}

//Validate by file contents
$fcontents = file_get_contents ($tmpfilename);
$carray = array("html", "javascript", "vbscript", "alert",
"onmouseover", "onclick", "onload", "onsubmit");
foreach ($carray as $fch) {
if (strstr($fcontents, $fch)) {
@unlink($tmpfilename);
$message .= "{$mklib->lang['error_filetype']}";
$mklib->error_page($message);
exit;
}
}
if (preg_match("#script(.+?)/script#ies", $fcontents)) {
@unlink($tmpfilename);
$message .= "{$mklib->lang['error_filetype']}";
$mklib->error_page($message);
exit;
}
--------------------[/source code]---------------------

Again, MIME-type will be correct and html-code detection can't stop
malicious php code inside of that jpg file.

Finally:

---------------------[source code]---------------------
$image = $totr.$file_name;

//move file from "tmp" directory to "images" directory
@rename($tmpfilename, "mkportal/blog/images/$image");
--------------------[/source code]---------------------

What's the possibilities? Attacker can upload picture file with php code
inside with filename like "pic.php.pjpg" and it will be stored in remote
server as result. And when attacker issues direct request to uploaded
picture:

http://localhost/mkportal.1.2.1/mkportal/blog/images/1pic.php.pjpg"

... then in case of Apache webserver php code inside of picture will
be executed. Therefore it's basically remote php code execution.


2. Insecure file upload in Downloads module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: critical
Preconditions:
1. attacker must be registered user

Registered users can add new files in downloads module by default:

http://localhost/mkportal.1.2.1/index.php?ind=downloads&op=submit_file

Let's look at "mkportal/modules/Downloads/index.php" line ~662:

---------[source code]--------------------------
function add_file() {

global $mkportals, $DB, $_FILES, $mklib, $mklib_board;
...
//Replace illegal sub-extensions
$com_types = array('com', 'exe', 'bat', 'scr', 'pif', 'asp',
'cgi', 'pl', 'php');
foreach ($com_types AS $bad) {
$file_name = str_replace(".$bad", "_$bad", $file_name);
---------[/source code]--------------------------

At first look this seems to be good security measure. If we try to upload
trojanized file with php code inside named "test.php.zzz', then it will be
transformed to "test_php.zzz" and php code execution is not possible.
But wait a minute ... "str_replace()" is case sensitive, right? So, what if
we try to upload "test.Php.zzz"? Yes, code fragment above will not trigger and
we end up with potentially dangerous uploaded file on remote server. It's easy
to find out URL to that file. First, let's look at file's download link:

http://localhost/mkportal.1.2.1/index.php?ind=downloads&op=download_file&ide=3
&file=test.Php.zzz

Here we can determine, that "ide=3". And this is the direct file request URL:

http://localhost/mkportal.1.2.1/mkportal/modules/downloads/file/mk_3_test.Php.mk

And it appears, that Apache does not care, if it's "php" or "Php" or "PHP", it
will parse the file as php script anyway. And as result any registered user with
file adding rights in downloads block can have arbitrary php code execution
possibilities in remote server.


3. Race condition in multiple modules file upload functionality
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions:
1. attacker must be registered user
2. multiple tries needed for successful exploitation

Affected modules are Blog (gallery file upload), Reviews and Image Gallery.
For example let's look at Image Gallery's file upload code:

---------[source code]--------------------------
if (!$FILE_UPLOAD && $FILE_URL) {
//Copy file from remote server to gallery "tmp" directory
if (!copy("$file", "mkportal/modules/gallery/album/tmp/$file_name")) {
$message = "{$mklib->lang['ga_errorupl']}";
$mklib->error_page($message);
exit;
}
} else {
//Move file from local server tmp directory to gallery "tmp"
directory
if (!move_uploaded_file("$file", "mkportal/modules/gallery/album/
tmp/$file_name")) {
$message = "{$mklib->lang['ga_errorupl']}";
$mklib->error_page($message);
exit;
}
}
@chmod("mkportal/modules/gallery/album/tmp/$file_name", 0644);
...
//Validate by mime type
$tmpfilename = "mkportal/modules/gallery/album/tmp/$file_name";
$size = @getimagesize($tmpfilename);
//If getimagesize does not recognize file as an image delete file
if (!$size) {
@unlink($tmpfilename);
$message .= "{$mklib->lang['ga_notsup']}";
$mklib->error_page($message);
exit;
}
---------[/source code]--------------------------

So there exists timeframe, where temporary file is allready moved to "tmp"
directory, but it is not yet deleted. If attacker manages to issue request
like this

http://localhost/mkportal.1.2.1/mkportal/modules/Gallery/album/
tmp/pic.php.pjpg

... in right time, then remote php code execution may be possible.
It is classical race condition and success probability of single try is
very limited, but it's possible to make thousands of tries, until hitting
the jackpot. And by the way, "chmod(0644)" does not matter in specific case :)


4. Sql Injection in Blog module template editing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions:
1. attacker must be registered user
2. attacker must have blog editing privileges
3. magic_quotes_gpc=off (rare in real-world servers)

Let's look at source code of "modules/blog/index.php" line ~1441:

---------------------[source code]---------------------
function save_template () {
global $mkportals, $DB, $Skin, $mklib;
...
$idb = $mkportals->member['id'];
$template = $_POST['template'];
$template = $this->clean_template($template);
$template2 = $_POST['template2'];
$template2 = $this->clean_template($template2);

$DB->query("UPDATE mkp_blog SET template = '$template',
template2 = '$template2' WHERE id = '$idb'");
--------------------[/source code]---------------------

No "addslashes()" or "mysql_real_escape_string()" is used, so sql injection
is possible, if "magic_quotes_gpc" setting is "off".

Proof of concept:

a) Go to blog template editing interface:

http://localhost/mkportal.1.2.1/index.php?ind=blog&op=edit_template

b) Insert text into the "Home Template" textarea:

',template=@@version,template2='

... and hit "Update Template". As result MysSql version is shown instead
of blog content.



5. Reflected XSS in "handler_image.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions: none

Example:

http://localhost/mkportal.1.2.1/mkportal/modules/rss/handler_image.php
?i=<script>alert(123);</script>


6. Stored XSS in blog templates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions:
1. attacker must be registered user
2. attacker must have blog editing privileges

MKportal offers blog functionality to all registered users. Blog access and
creation is enabled by default. Quick search in Google reveals, that many
websites have enabled blog module.

Google dork: inurl:"index.php?ind=blog"

Any registered user with blog editing privileges can modify his own
blog templates. Templates are stored in database. Blog owner can manipulate
templates html source in arbitrary ways, but some security filtering is
in place, in order to prevent inserting potentially malicious content
(Javascript, VBScript, ...) into blog templates.

Let's look at source code of "modules/blog/index.php" line ~1441:

---------------------[source code]---------------------
function save_template () {
global $mkportals, $DB, $Skin, $mklib;
...
$idb = $mkportals->member['id'];
$template = $_POST['template'];
$template = $this->clean_template($template);
$template2 = $_POST['template2'];
$template2 = $this->clean_template($template2);

$DB->query("UPDATE mkp_blog SET template = '$template',
template2 = '$template2' WHERE id = '$idb'");
--------------------[/source code]---------------------

So we can see, that security filtering is handled by function
"clean_template()". Let's look inside of this function:

---------------------[source code]---------------------
function clean_template ($t="") {
...
while( preg_match( "#script(.+?)/script#ies", $t ) ) {
$t = preg_replace( "#script(.+?)/script#ies", "" , $t);
}
$t = preg_replace( "/javascript/i", "", $t );
//$t = preg_replace( "/about/i" , "", $t );
$t = preg_replace( "/vbscript/i" , "", $t );
$t = preg_replace( "/alert/i" , "", $t );
$t = preg_replace( "/onmouseover/i", "", $t );
$t = preg_replace( "/onclick/i" , "", $t );
$t = preg_replace( "/onload/i" , "", $t );
$t = preg_replace( "/onsubmit/i" , "", $t );

...
$t = preg_replace( "/ecmascript/i" , "", $t );
$t = preg_replace( "/about:/si" , "", $t );
$t = preg_replace( "/data:/si" , "", $t );
$t = preg_replace( "/onfocus/i" , "", $t );
$t = preg_replace( "/onblur/i" , "", $t );
$t = preg_replace( "/ondblclick/i" , "", $t );
$t = preg_replace( "/onmousedown/i" , "", $t );
$t = preg_replace( "/onmouseup/i" , "", $t );
$t = preg_replace( "/onmousemove/i" , "", $t );
$t = preg_replace( "/onmouseout/i" , "", $t );
$t = preg_replace( "/onkeypress/i" , "", $t );
$t = preg_replace( "/onkeydown/i" , "", $t );
$t = preg_replace( "/onkeyup/i" , "", $t );
$t = preg_replace( "/onunload/i" , "", $t );
$t = preg_replace( "/onabort/i" , "", $t );
$t = preg_replace( "/onerror/i" , "", $t );
$t = preg_replace( "/onchange/i" , "", $t );
$t = preg_replace( "/onreset/i" , "", $t );
$t = preg_replace( "/onselect/i" , "", $t );
$t = preg_replace( "/document./i" , "", $t );
$t = preg_replace( "/window./i" , "", $t );

...
return $t;
}

--------------------[/source code]---------------------

This kind of filtering is example of flawed-by-design implementation.
If someone wants insert javascript into blog template, then it's still
possible! Here are some working examples:

<body ononsubmitload=aleonsubmitrt(123);>

<salertcript>aalertlert(123);</salertcript>


7. Stored XSS in Reviews module comments functionality
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions:
1. attacker must be registered user
2. attacker must have Reviews comments editing privileges

There are some security measures against script injection in comments
text, but still it's possible to sneak through those filters. Example:

<marquee loop=1 onfinish=alert(document.cookie) width=0></marquee>

This script will be executed, when someone opens review with this comment.
As result, cookie theft and other attacks may be possible.


8. Stored XSS in News module comments functionality
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: medium
Preconditions:
1. attacker must be registered user
2. attacker must have news comments editing privileges

Same story, as in previous case - filtering exists, but can be bypassed.



9. Full path disclosure in "index.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Security risk: low
Preconditions: display_errors = Off

Example:

http://localhost/mkportal.1.2.1/?ind[]

Result:

Warning: Illegal offset type in isset or empty in
C:apache_wwwrootmkportal.1.2.1index.php on line 102


Greetings:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Greets to ToXiC, y3dips, Sm0ke, Heintz, slimjim100, pexli, mge, str0ke,
to all active waraxe.us forum members and to anyone else who know me!


Contact:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

come2waraxe@yahoo.com
Janek Vind "waraxe"

Waraxe forum: http://www.waraxe.us/forums.html
Personal homepage: http://www.janekvind.com/
---------------------------------- [ EOF ] ---------------------------------









Copyright © by Waraxe IT Security Portal All Right Reserved.

Published on: 2009-01-15 (32630 reads)

[ Go Back ]
Top members by posts
waraxe  waraxe - 2407
vince213333  vince213333 - 737
pexli  pexli - 665
Mullog  Mullog - 540
demon  demon - 485
shai-tan  shai-tan - 477
LINUX  LINUX - 404
Cyko  Cyko - 375
tsabitah  tsabitah - 328
y3dips  y3dips - 281
Cybercrime news
Global Cops Power Down World's Most Prolific DDoS Dealership
Malware Scammers Gearing Up For 2024 Summer Olympics
FIN7 Is Peddling EDR-Nerfing Malware To Ransomware Operators
Ransomware Continues To Pile On Costs For Critical Infrastructure Victims
Rite Aid Says Hack Impacts 2.2 Million People
State, Local Governments Facing Deluge Of Phishing Attacks
Avast Secretly Gave DoNex Ransomware Decryptors To Victims
Hackers Leak Alleged Taylor Swift Ticket Data To Extort Ticketmaster
Crypto Hacking Thefts Double To 1.4 Billion In First Half Of 2024
Ransomware Locks Credit Union Users Out Of Bank Accounts
Mac Users Served Info Stealer Malware Through Google Ads
Deadline Looms For Alleged LockBit Extortion Over Feds Of 33TB Of Data
Cyber Attack Compromised Indonesian Datacenter, Ransom Sought
CDK Global Begins To Restore Systems After Cyber Attack Hits Thousands Of Retailers
Ransomware Group Exploits PHP Vulnerability Days After Disclosure
GitHub Phishing Campaign Wipes Repos, Extorts Victims
Ransomware Gangs Are Adopting More Brutal Tactics Amidst Crackdowns
Security Industry Has RaaS Model Wrong, Says Expert
Ransomware Attack Disrupting London Hospitals
Cybercrooks Get Cozy With BoxedApp To Dodge Detection
OpenAI Report Reveals Threat Actors Using ChatGPT In Influence Operations
Law Enforcement Operation Takes Aim At An Often Overlooked Cybercrime Lynchpin
Best Buy / Geek Squad Most Impersonated By Scammers In 2023
New Ransomware Uses BitLocker To Encrypt Victim Data
London Drugs Waiting On LockBit's Next Move
Hacker news
Network Of 3,000 GitHub Accounts Used For Malware Distribution
KnowBe4 Hires Fake North Korean IT Worker, Catches New Employee Planting Malware
Hackers Bypass Windows SmartScreen Flaw To Launch Malware
Two Russians Sanctioned Over Cyberattacks On US Critical Infrastructure
Suspected Scattered Spider Suspect Arrested In UK
North Korea May Have Hacked Crypto Exchange WazirX
MarineMax Notifying 123,000 Of Data Breach
Malware Scammers Gearing Up For 2024 Summer Olympics
Vulnerability In Cisco Smart Software Manager Lets Attacker Change Any User Password
FIN7 Is Peddling EDR-Nerfing Malware To Ransomware Operators
Iran Phishes Israeli Orgs With Custom BugSleep Backdoor
Ransomware Continues To Pile On Costs For Critical Infrastructure Victims
Rite Aid Says Hack Impacts 2.2 Million People
APT Exploits Windows Zero-Day To Execute Code Via Disabled Internet Explorer
Trojan Source Flaw Could Result In Covert App Poisoning
Infoseccers Claim Squarespace Migration Linked To DNS Hijackings At Web3 Firms
5 Questions To Ask About The Latest News Surrounding The AT&T Breach
ZDI Shames MS For Yet Another Coordinated Vuln Disclosure Snafu
Data Of Millions Of mSpy Customers Leaked Online
OpenSSH Bug Leaves RHEL And RHELatives Vulnerable
China's APT41 Crew Adds A Stealthy Malware Loader And Fresh Backdoor To Its Toolbox
Millions Impacted By Breach At Advance Auto Parts
Gay Furry Hackers Say They Have Disbanded After Raiding Project 2025's Heritage Foundation
State, Local Governments Facing Deluge Of Phishing Attacks
Threat Actors Exploited Windows 0-Day For More Than A Year Before Microsoft Fixed It
Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.377 Seconds