Project: ovs (openvswitch/ovs), language: c++
Vulnerability instance: openvswitch.cve-2024-22563
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/openvswitch/ovs-issues/issues/315
## Description:
Issue: openvswitch/ovs-issues#315
Title: memory leak exists in the function ovs_pcap_open
State: closed
Created by: ccccgb
Created at: 2023-12-28 12:45:15+00:00

Issue Body:
# project
https://www.openvswitch.org/download/
version:2.17.8
# os info
Ubuntu18.04 TLS
# poc
[poc.zip](https://github.com/openvswitch/ovs-issues/files/13786555/poc.zip)
# build
wget https://www.openvswitch.org/releases/openvswitch-2.17.8.tar.gz
./configure CFLAGS="-g -O2 -fno-omit-frame-pointer -fno-common"
make
./tests/ovstest test-flows ./poc @@
# ASAN Info
./tests/ovstest test-flows ./poc @@
2023-12-18T07:25:24Z|00001|pcap|WARN|@@: failed to open pcap file for reading (No such file or directory)
test-flows: failed to open @@ (No such file or directory)

=================================================================
==3820990==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x499dcd in malloc (/home/ubuntu/ovs/tests/ovstest+0x499dcd)
    #1 0x826df7 in xmalloc__ /home/ubuntu/ovs/lib/util.c:137:15
    #2 0x826df7 in xmalloc /home/ubuntu/ovs/lib/util.c:172:12
    #3 0x7ab6e3 in ovs_pcap_open /home/ubuntu/final/ovs/lib/pcap-file.c:83:14
    #4 0x509c18 in test_flows_main /home/ubuntu/ovs/tests/test-flows.c:51:12
    #5 0x509c18 in ovstest_wrapper_test_flows_main__ /home/ubuntu/ovs/tests/test-flows.c:101:1
    #6 0x57a2ba in ovs_cmdl_run_command__ /home/ubuntu/ctf_comp/ovs/lib/command-line.c:247:17
    #7 0x4c9fb1 in main /home/ubuntu/ovs/tests/ovstest.c:133:9
    #8 0x7ffff78d2082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).


Comments:
Comment by igsilya on 2024-01-02 16:20:23+00:00:
Hi, @dddduge .  Are you sure you're running OVS 2.17?  The issue you described supposed to be fixed long ago in commit https://github.com/openvswitch/ovs/commit/3168f328c78cf6e4b3022940452673b0e49f7620.

---

Comment by risicle on 2024-01-21 19:15:20+00:00:
FWIW CVE-2024-22563 has been assigned to this issue.

---

Comment by igsilya on 2024-01-22 14:10:05+00:00:
@risicle what is the reason for requesting this CVE?  The issue was fixed in 2021, and it doesn't affect users, since it was present in a test-related code only.  It is not reproducible with 2.17.8 or earlier versions of OVS 2.17.

FWIW, the process [1] for security related issues is to send a report to [security@openvswitch.org](mailto:security%40openvswitch.org) instead of reporting publicly on GitHub; OVS security team then can asses the issue and decide if it is indeed a security issue and request a CVE allocation for it.

[1] https://docs.openvswitch.org/en/latest/internals/security/

---

Comment by igsilya on 2024-01-22 16:33:06+00:00:
Closing this issue, as it doesn't actually exist in any supported version of Open vSwitch.  (And it doesn't exist in 2.17.8.)

---

Comment by risicle on 2024-01-22 21:16:38+00:00:
I did not request the CVE, I'm merely telling you that there is a CVE pointing here. I have nothing else to do with it.

---

Comment by igsilya on 2024-01-22 21:26:32+00:00:
@risicle Ack.  Sorry, I assumed you were a requester.  Thanks for the information.

Will try to get some clarification from a CNA.

Attachments:
https://github.com/openvswitch/ovs-issues/files/13786555/poc.zip

Commit References:
3168f328c78cf6e4b3022940452673b0e49f7620

Build script:
#!/bin/bash
# Default build script template for C/C++ projects
set -eu

# Define configuration options
CONFIG_OPTS="--disable-shared"
CMAKE_OPTS="-DCMAKE_BUILD_TYPE=Debug"
MAKE_OPTS="-j$(nproc)"
BUILD_DIR="build"

# 1. Run build preparation scripts if they exist
for prep_script in buildconf autogen.sh bootstrap; do
  if [ -x "$prep_script" ]; then
    echo "Running $prep_script..."
    ./$prep_script
    break
  elif [ -f "$prep_script" ]; then
    echo "Found $prep_script but it's not executable, setting permissions..."
    chmod +x $prep_script
    ./$prep_script
    break
  fi
done

# 2. Handle different build systems
if [ -f "configure" ]; then
  echo "Found configure script, running with options: $CONFIG_OPTS"
  ./configure $CONFIG_OPTS

  echo "Building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "CMakeLists.txt" ]; then
  echo "Found CMakeLists.txt, using CMake build system"
  mkdir -p $BUILD_DIR
  cd $BUILD_DIR
  cmake $CMAKE_OPTS ..
  make $MAKE_OPTS
elif [ -f "Makefile" ] || [ -f "makefile" ]; then
  echo "Found Makefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "meson.build" ]; then
  echo "Found meson.build, using Meson build system"
  mkdir -p $BUILD_DIR
  meson setup $BUILD_DIR .
  cd $BUILD_DIR
  ninja
elif [ -f "GNUmakefile" ]; then
  echo "Found GNUmakefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -d ".git" ] && [ -f "Makefile.am" ]; then
  echo "Found Makefile.am, running autoreconf"
  autoreconf -i
  ./configure $CONFIG_OPTS
  make $MAKE_OPTS
else
  echo "WARNING: No recognized build system found!"
  echo "Trying generic approach:"
  
  # Try to detect common source patterns and compile them
  if ls *.c >/dev/null 2>&1 || ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
    echo "Found C/C++ source files, attempting direct compilation"
    if ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
      CXX=${CXX:-g++}
      echo "Compiling C++ sources with $CXX"
      $CXX -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.cpp *.cc 2>/dev/null || true
    elif ls *.c >/dev/null 2>&1; then
      CC=${CC:-gcc}
      echo "Compiling C sources with $CC"
      $CC -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.c 2>/dev/null || true
    fi
  fi
fi

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool python python3-pip libz-dev libssl-dev libssl1.1 wget
RUN git clone https://github.com/openvswitch/ovs ovs
RUN git -C ovs checkout 275be1eb959322891607cb9baacf3dc41895d2a0
WORKDIR $SRC/ovs
COPY build.sh $SRC/

Additional files: