libfprint-CS9711 icon indicating copy to clipboard operation
libfprint-CS9711 copied to clipboard

Thanks for your work! And some Security Vulnerability in source code, found by AI

Open kenzed opened this issue 5 months ago • 1 comments

The driver works on ubuntu 26.04 and 24.06 with latest kernel, thanks!

Here are 3 memory safety issues found by the AI review; I think they’re worth reading:


2. Security Vulnerability Analysis

🟡 Low Risk — Memory Safety

# Issue File Severity Description
1 sigfm/binary.hpp:110 uses raw malloc() instead of new, while sigfm_free_info uses delete sigfm/binary.hpp:110 / sigfm/sigfm.cpp:208 Medium malloc() + delete is undefined behavior (UB) and may cause heap corruption. Should consistently use either new[]/delete[] or g_malloc()/g_free().
2 sigfm/binary.hpp copy_buffer() allocates with raw malloc and requires manual free() by the caller sigfm/binary.hpp:109-112 Low Mixing raw malloc with GLib memory management conventions; potential for leaks at boundaries.
3 sigfm/sigfm.cpp:110 memcpy(img.data, pix, width * height) — no explicit bounds validation before copy sigfm/sigfm.cpp:110 Low width * height could theoretically overflow, but cv::Mat::create() performs basic size validation before this point.

Suggested Fix (Priority)

  1. Fix malloc/delete mismatch in sigfm/binary.hpp:110:
    • Option A: Replace malloc(store_.size()) with g_malloc(store_.size()) and have the caller use g_free().
    • Option B: Change sigfm_free_info() to properly delete[] or wrap SigfmImgInfo in a GObject with a proper finalizer.

kenzed avatar Jun 08 '26 23:06 kenzed

here is a fix: https://github.com/kenzed/libfprint-CS9711 tested on ubuntu 24.04 6.17.0-35-generic

kenzed avatar Jun 09 '26 04:06 kenzed