Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed heap-overflow if compiled with --enable-tls-sigs. #2038

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/lib/protocols/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2250,10 +2250,13 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
tot_signature_algorithms_len = ndpi_min((sizeof(ja3.client.signature_algorithms) / 2) - 1, tot_signature_algorithms_len);

#ifdef TLS_HANDLE_SIGNATURE_ALGORITMS
flow->protos.tls_quic.num_tls_signature_algorithms = ndpi_min(tot_signature_algorithms_len / 2, MAX_NUM_TLS_SIGNATURE_ALGORITHMS);
size_t size = ndpi_min(tot_signature_algorithms_len / 2, MAX_NUM_TLS_SIGNATURE_ALGORITHMS);

memcpy(flow->protos.tls_quic.client_signature_algorithms,
&packet->payload[s_offset], 2 /* 16 bit */*flow->protos.tls_quic.num_tls_signature_algorithms);
if (s_offset + 2 * size <= packet->payload_packet_len) {
flow->protos.tls_quic.num_tls_signature_algorithms = size;
memcpy(flow->protos.tls_quic.client_signature_algorithms,
&packet->payload[s_offset], 2 /* 16 bit */ * size);
}
#endif

for(i=0; i<tot_signature_algorithms_len && s_offset+i<total_len; i++) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ossfuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fi
cd ndpi
# Set LDFLAGS variable and `--with-only-libndpi` option as workaround for the
# "missing dependencies errors" in the introspector build. See #8939
LDFLAGS="-lpcap" ./autogen.sh --enable-fuzztargets --with-only-libndpi
LDFLAGS="-lpcap" ./autogen.sh --enable-fuzztargets --with-only-libndpi --enable-tls-sigs
make -j$(nproc)
# Copy fuzzers
ls fuzz/fuzz* | grep -v "\." | while read i; do cp $i $OUT/; done
Expand Down
Loading