Commit graph

18601 commits

Author SHA1 Message Date
Tim Wojtulewicz
c8363743a5 Merge remote-tracking branch 'security/topic/awelzel/205-x509-sct-leak'
* security/topic/awelzel/205-x509-sct-leak:
  X509Common/SCT parsing: Fix memory leak in error case
2023-10-27 11:03:44 -07:00
Arne Welzel
ab4576369f Merge remote-tracking branch 'origin/topic/awelzel/3398-protocol-analyzer-packet-fuzzing'
* origin/topic/awelzel/3398-protocol-analyzer-packet-fuzzing:
  fuzzers: Add DTLS fuzzer
  generic-analyzer-fuzzer: Support NextPacket() fuzzing
2023-10-27 19:20:32 +02:00
Arne Welzel
0b6832b1b4 fuzzers: Add DTLS fuzzer
Not sure it adds a lot over the SSL analyzer as they share code, but it
provides a distinct entry point at least.
2023-10-27 18:51:36 +02:00
Arne Welzel
5d781e54bd generic-analyzer-fuzzer: Support NextPacket() fuzzing
A number of analyzers that we've been fuzzing with the generic-analyzer-fuzzer
setup do not implement DeliverStream() and instead only work with DeliverPacket()
(ntp, syslog, sip, radius, ...). Calling DeliverStream() on those is
pretty much a noop and fuzzing not effective.

This change adds support to fuzz DeliverPacket(). Whether to use packet
or stream fuzzing is configured through a define via CMake.

This is still a bit limited in that for analyzers that support both,
DeliverPacket() and DeliverStream(), only one code path is fuzzed.

Closed #3398
2023-10-27 18:50:56 +02:00
Benjamin Bannier
4d3e9de3d3 Merge remote-tracking branch 'origin/topic/bbannier/monterey-truncate' 2023-10-26 17:02:09 +02:00
Benjamin Bannier
2b44cea141 Require truncate for a test using it
It looks like older versions of macOS like Monterey do not ship with
`truncate`. Make a recently added test require it to suppress spurious
failures.
2023-10-26 16:23:37 +02:00
Benjamin Bannier
05e4d1cfde Bump outdated baseline
This fixes an outdated baseline added with
caaffd0324.
2023-10-26 15:59:04 +02:00
Benjamin Bannier
48af171110 Merge remote-tracking branch 'origin/topic/bbannier/bump-spicy' 2023-10-26 15:51:12 +02:00
Benjamin Bannier
08d9a1934f Merge branch 'origin/topic/bbannier/fix-core.mmdb-tests' 2023-10-26 15:34:40 +02:00
Benjamin Bannier
caaffd0324 Fix tests so they work both with GNU and BSD tools
The GNU and BSD versions of `touch` and `truncate` allow slightly
different arguments, change the tests so they work in both versions.
2023-10-26 15:33:14 +02:00
Benjamin Bannier
dfba2d6df7 Install libmaxminddb in macOS CI 2023-10-26 14:47:59 +02:00
Benjamin Bannier
9a77f71808 Bump auxil/spicy to latest release 2023-10-26 14:08:33 +02:00
Arne Welzel
d999b74b99 Merge remote-tracking branch 'origin/topic/awelzel/generic-fuzzer-ux'
* origin/topic/awelzel/generic-fuzzer-ux:
  fuzzer-setup: Allow customization without recompiling
2023-10-25 17:02:44 +02:00
Arne Welzel
f0c2a7812a Merge remote-tracking branch 'origin/topic/awelzel/subdir-build-dir'
* origin/topic/awelzel/subdir-build-dir:
  subdir-btest: Allow setting build_dir
2023-10-25 17:01:48 +02:00
Arne Welzel
8b89f1cf8d Merge remote-tracking branch 'origin/topic/awelzel/3043-supervisor-safe-write-error'
* origin/topic/awelzel/3043-supervisor-safe-write-error:
  Supervisor: Handle EAGAIN error on stem pipe
2023-10-25 12:56:04 +02:00
Arne Welzel
92565d4739 Supervisor: Handle EAGAIN error on stem pipe
util::safe_write() calls abort() in case of EAGAIN errors. This is
easily observed when starting clusters with 32 workers or more.

Add a custom write_message() function handling EAGAIN by retrying
after a small sleep. It's not clear a more complicated poll() would be
much better: The pipe might be ready for writing, but then our message
might not actually fit in, resulting in another EAGAIN error. And even
poll() would introduce blocking/sleeping code.

Take some precautions against the stem and the supervisor dead-locking
when both pipes are full by draining the other end on EAGAIN errors.

Closes #3043
2023-10-25 12:53:37 +02:00
Arne Welzel
9530f73ec4 fuzzer-setup: Allow customization without recompiling
This change allows to invoke a reproducer with different script options
and extra scripts to ease debugging and investigation. For example, enabling
the DPD debug stream and adding misc/dump-events can be done as follows after
this change:

    ZEEK_DEBUG_LOG_STDERR=1 ../../build/src/fuzzers/zeek-pop3-fuzzer <test-case> -- -B dpd misc/dump-events
2023-10-25 12:28:44 +02:00
Arne Welzel
560f8a4a84 ssl: Prevent unbounded ssl_history growth
The ssl_history field may grow unbounded (e.g., ssl_alert event). Prevent this
by capping using a configurable limit (default 100) and raise a weird once reached.
2023-10-25 09:35:45 +02:00
Arne Welzel
c960d279a2 ssl: Cap number of alerts parsed from SSL record
Limit the number of events raised from an SSL record with content_type
alert (21) to a configurable maximum number (default 10). For TLS 1.3,
the limit is set to 1 as specified in the RFC. Add a new weird cases
where the limit is exceeded.

OSS-Fuzz managed to generate a reproducer that raised ~660k ssl_plaintext
and ssl_alert events given ~810kb of input data. This change prevents this
with hopefully no negative side-effect in the real-world.
2023-10-25 09:35:10 +02:00
Arne Welzel
8f9d4a296b subdir-btest: Allow setting build_dir
We have that functionality in btest.cfg and it's actually nice to use
it for toggling between a debug/asan and release build.
2023-10-25 09:17:11 +02:00
Arne Welzel
ddcf75e934 Merge remote-tracking branch 'origin/topic/timw/verbose-cluster-testing-btests'
* origin/topic/timw/verbose-cluster-testing-btests:
  CI: Pass -A flag to btest for cluster-testing builds
2023-10-25 09:15:31 +02:00
zeek-bot
21814e144f Update doc submodule [nomail] [skip ci] 2023-10-25 01:30:08 +00:00
Tim Wojtulewicz
ac7685c679 CI: Pass -A flag to btest for cluster-testing builds 2023-10-24 15:42:21 -07:00
Tim Wojtulewicz
e0182e17bf Merge remote-tracking branch 'origin/topic/neverlord/cmake-submodule-update'
* origin/topic/neverlord/cmake-submodule-update:
  Update CMake submodule for caching fix
2023-10-24 13:06:04 -07:00
Arne Welzel
a0ad0f6871 Update doc submodule [nomail] [skip ci] 2023-10-24 20:32:03 +02:00
Arne Welzel
22fb445a7f Merge remote-tracking branch 'origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix'
* origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix:
  event: Reinitialize EventMgr's flare after fork() from stem
2023-10-24 19:35:35 +02:00
Arne Welzel
a9b65cc6d9 Update baselines 2023-10-24 19:10:11 +02:00
Arne Welzel
ce4cbac1ef ftp: Do not base seq on number of pending commands
Previously, seq was computed as the result of |pending_commands|+1. This
opened the possibility to override queued commands, as well as logging
the same pending ftp reply multiple times.

For example, when commands 1, 2, 3 are pending, command 1 may be dequeued,
but the incoming command then receives seq 3 and overrides the already
pending command 3. The second scenario happens when ftp_reply() selected
command 3 as pending for logging, but is then followed by many ftp_request()
events. This resulted in command 3's response being logged for every
following ftp_request() over and over again.

Avoid both scenarios by tracking the command sequence as an absolute counter.
2023-10-24 19:10:07 +02:00
Arne Welzel
631b30f5bb btest/Files/mmdb: golang-ci suggested fixes
Thanks Benjamin for the hint.
2023-10-24 15:08:58 +02:00
Arne Welzel
44b67894ac Merge remote-tracking branch 'origin/topic/awelzel/mmdb-fix-and-tests'
* origin/topic/awelzel/mmdb-fix-and-tests:
  base/frameworks/spicy: Do not load base/misc/version
  btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests
  btest/files: Add mmdb testing databases and generator code
  zeek.bif: Switch mmdb stale check to network_time
  Fix mmdb pointer destruction
2023-10-24 14:13:37 +02:00
Arne Welzel
54a08a74da base/frameworks/spicy: Do not load base/misc/version
Unsure what it's used for today and also results in the situation that on
some platforms we generate a reporter.log in bare mode, while on others
where spicy is disabled, we do not.

If we want base/frameworks/version loaded by default, should put it into
init-bare.zeek and possibly remove the loading of the reporter framework
from it - Reporter::error() would still work and be visible on stderr,
just not create a reporter.log.
2023-10-24 13:15:21 +02:00
Arne Welzel
baf30288ca btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests 2023-10-24 13:15:18 +02:00
Arne Welzel
05922132b3 btest/files: Add mmdb testing databases and generator code 2023-10-24 11:11:02 +02:00
Arne Welzel
688d68cbf6 zeek.bif: Switch mmdb stale check to network_time
Makes testing easier and aligns better with log rotation and timer
expiration. Should not have an effect in practice. Also, log detail
about whether inode or modification time changed, too.
2023-10-24 11:11:00 +02:00
Benjamin Bannier
254d7ebfa2 Merge remote-tracking branch 'origin/topic/bbannier/bump-spicy' 2023-10-24 10:10:54 +02:00
zeek-bot
c0e982f5d9 Update doc submodule [nomail] [skip ci] 2023-10-24 00:25:50 +00:00
peter.cullen
c391bdba5d Fix mmdb pointer destruction
The mmdb references needs to use reset() instead of release()
so that the destructor gets called and the stale DB is actually
cleaned up. Otherwise, the pointer is leaked and the stale DB
remains in memory.
2023-10-23 23:29:19 +02:00
Dominik Charousset
6451a4e750 Update CMake submodule for caching fix 2023-10-23 18:04:48 +02:00
Benjamin Bannier
603308f324 Bump auxil/spicy to latest development snapshot 2023-10-23 17:05:30 +02:00
Arne Welzel
ab157777e3 X509Common/SCT parsing: Fix memory leak in error case
Failed to free the copy of the OCSP extension's value the inner
octet string couldn't be parsed.
2023-10-23 16:57:15 +02:00
Benjamin Bannier
d3eaf587e7 Merge remote-tracking branch 'origin/topic/robin/gh-3370' 2023-10-23 11:30:12 +02:00
zeek-bot
1aa9de2811 Update doc submodule [nomail] [skip ci] 2023-10-21 00:23:06 +00:00
Arne Welzel
ebb8780d6a quic: Skip new test if have-quic is false 2023-10-20 20:57:19 +02:00
Tim Wojtulewicz
bf75f56ef7 Merge remote-tracking branch 'origin/topic/awelzel/quic-longer-but-configurable-history-max-length'
* origin/topic/awelzel/quic-longer-but-configurable-history-max-length:
  quic: Bump maximum history length, make configurable
2023-10-20 11:45:04 -07:00
Arne Welzel
6604010a05 quic: Bump maximum history length, make configurable
From zeek/spicy-quic#15
2023-10-20 20:42:30 +02:00
Arne Welzel
d8a0822221 event: Reinitialize EventMgr's flare after fork() from stem
Because EventMgr is defined globally as an object (rather than a global
pointer to an EventMgr object), its pipe is created even before main()
is entered. This further means that in the fork-based supervisor setup,
all Zeek processes created from the top-level supervisor process share
the same pipe object for the EventMgr. In turn, whenever any of the
processes enqueued an event, the flare was fired and ready for reading
on all other processes in the cluster, causing much contention and
unneeded overhead.

Closes #3190
2023-10-20 17:52:48 +02:00
zeek-bot
16a51218a5 Update doc submodule [nomail] [skip ci] 2023-10-20 00:24:08 +00:00
Arne Welzel
e632131e9e Merge remote-tracking branch 'origin/topic/awelzel/add-ssl-fuzzer'
* origin/topic/awelzel/add-ssl-fuzzer:
  fuzzers: Add SSL fuzzer
2023-10-19 20:00:04 +02:00
Arne Welzel
043f3216f7 fuzzers: Add SSL fuzzer
Corpus was generated from a few btest pcaps, fuzzing for 60 seconds
locally and minimizing afterwards as in the documentation.

List of pcaps:

    certificate-request-failed.pcap
    certificate-with-sct.pcap
    cert-no-cn.pcap
    chrome-34-google.trace
    chrome-63.0.3211.0-canary-tls_experiment.pcap
    heartbleed-encrypted.pcap
    heartbleed-encrypted-short.pcap
    heartbleed-encrypted-success.pcap
    heartbleed.pcap
    heartbleed-success.pcap
    ssl-v2.trace
    ssl.v3.trace
    tls1_1.pcap
    tls-1.2-handshake-failure.trace
    tls1.2-protocol-violation.pcap
    tls1.2.trace
    tls13_wolfssl.pcap
    tls-early-alert.trace
2023-10-19 18:20:49 +02:00
Arne Welzel
ee827a0a63 Merge remote-tracking branch 'origin/topic/robin/gh-3383'
* origin/topic/robin/gh-3383:
  Fix missing version number in `spicyz`.
2023-10-19 16:26:05 +02:00