Skip to content

Bug: Stack-buffer-overflow on RTSPServer::RTSPClientConnection::handleRequestBytes(int) in RTSPServer.cpp #56

@Fanny-wen

Description

@Fanny-wen

seed.zip

Build

  1. Modify the config.linux:
COMPILE_OPTS =          $(INCLUDES) -I/usr/local/include -I. -O2 -DSOCKLEN_T=socklen_t -DNO_STD_LIB -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DALLOW_RTSP_SERVER_PORT_REUSE=1
C =                     c
C_COMPILER =             **/path/to**/aflnet/afl-clang-fast
C_FLAGS =               $(COMPILE_OPTS) $(CPPFLAGS) $(CFLAGS)
CPP =                   cpp
CPLUSPLUS_COMPILER =    **/path/to**/aflnet/afl-clang-fast++
CPLUSPLUS_FLAGS =       $(COMPILE_OPTS) -Wall -DBSD=1 $(CPPFLAGS) $(CXXFLAGS)
OBJ =                   o
LINK =                   **/path/to**/aflnet/afl-clang-fast++ -o
LINK_OPTS =             -L. $(LDFLAGS)
CONSOLE_LINK_OPTS =     $(LINK_OPTS)
LIBRARY_LINK =          ar cr
LIBRARY_LINK_OPTS =
LIB_SUFFIX =                    a
LIBS_FOR_CONSOLE_APPLICATION = -lssl -lcrypto
LIBS_FOR_GUI_APPLICATION =
EXE =
  1. Generate Makefile
    ./genMakefiles linux
  2. Compile the source
    make clean all

Attack

  1. Starting the testOnDemandRTSPServer with valgrind
    valgrind ./testOnDemandRTSPServer
  2. Sending the Packet
    /path/to/aflnet/aflnet-replay seed1 RTSP 8554

Description
Here is the valgrind report:

==626== Conditional jump or move depends on uninitialised value(s)
==626==    at 0x40C98A: RTSPServer::RTSPClientConnection::handleRequestBytes(int) (RTSPServer.cpp:843)
==626==    by 0x4AD05B: GenericMediaServer::ClientConnection::incomingRequestHandler() (GenericMediaServer.cpp:323)
==626==    by 0x4E8EF2: BasicTaskScheduler::SingleStep(unsigned int) (BasicTaskScheduler.cpp:171)
==626==    by 0x4ED2EB: BasicTaskScheduler0::doEventLoop(char volatile*) (BasicTaskScheduler0.cpp:87)
==626==    by 0x40541D: main (testOnDemandRTSPServer.cpp:462)
==626== 
==626== Conditional jump or move depends on uninitialised value(s)
==626==    at 0x40CAC2: RTSPServer::RTSPClientConnection::handleRequestBytes(int) (RTSPServer.cpp:864)
==626==    by 0x4AD05B: GenericMediaServer::ClientConnection::incomingRequestHandler() (GenericMediaServer.cpp:323)
==626==    by 0x4E8EF2: BasicTaskScheduler::SingleStep(unsigned int) (BasicTaskScheduler.cpp:171)
==626==    by 0x4ED2EB: BasicTaskScheduler0::doEventLoop(char volatile*) (BasicTaskScheduler0.cpp:87)
==626==    by 0x40541D: main (testOnDemandRTSPServer.cpp:462)
==626== 
^C==626== 
==626== Process terminating with default action of signal 2 (SIGINT)
==626==    at 0x502819A: select (select.c:41)
==626==    by 0x4E878F: BasicTaskScheduler::SingleStep(unsigned int) (BasicTaskScheduler.cpp:90)
==626==    by 0x4ED2EB: BasicTaskScheduler0::doEventLoop(char volatile*) (BasicTaskScheduler0.cpp:87)
==626==    by 0x40541D: main (testOnDemandRTSPServer.cpp:462)
==626== 
==626== HEAP SUMMARY:
==626==     in use at exit: 25,450 bytes in 368 blocks
==626==   total heap usage: 25,870 allocs, 25,502 frees, 47,852,551 bytes allocated
==626== 
==626== LEAK SUMMARY:
==626==    definitely lost: 0 bytes in 0 blocks
==626==    indirectly lost: 0 bytes in 0 blocks
==626==      possibly lost: 0 bytes in 0 blocks
==626==    still reachable: 25,450 bytes in 368 blocks
==626==         suppressed: 0 bytes in 0 blocks
==626== Rerun with --leak-check=full to see details of leaked memory
==626== 
==626== Use --track-origins=yes to see where uninitialised values come from
==626== For lists of detected and suppressed errors, rerun with: -s
==626== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions