Commit graph

1441 commits

Author SHA1 Message Date
Arne Welzel
540fe7aff7 http: Heuristic around rejecting malformed HTTP/0.9 traffic
oss-fuzz generated "HTTP traffic" containing 250k+ sequences of "T<space>\r\r"
which Zeek then logged as individual HTTP requests. Add a heuristic to bail
on such request lines. It's a bit specific to the test case, but should work.

There are more issues around handling HTTP/0.9, e.g. triggering
"not a http reply line" when HTTP/0.9 never had such a thing, but
I don't think that's worth fixing up.

Fixes #119
2022-11-18 18:19:58 +01:00
Tim Wojtulewicz
976caf61ba Merge remote-tracking branch 'jsoref/spelling-repetition'
* jsoref/spelling-repetition:
  spelling: repetitions
2022-11-18 09:40:43 -07:00
Josh Soref
186fe346ad spelling: repetitions
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-18 10:26:33 -05:00
Robin Sommer
d2585e21be
Merge remote-tracking branch 'origin/topic/robin/gh-2426-flipping'
* origin/topic/robin/gh-2426-flipping:
  Fixing productive connections with missing SYN still considered partial after flipping direction.
  Add some missing bits when flipping endpoints.
2022-11-18 11:50:28 +01:00
nadavkluger
dd849bc339 Added NTLM challenge and response 2022-11-17 18:38:49 +02:00
Robin Sommer
6fbebc5e94
Fixing productive connections with missing SYN still considered partial after flipping direction.
In https://github.com/zeek/zeek/pull/2191, we added endpoint flipping
for cases where a connection starts with a SYN/ACK followed by ACK or
data. The goal was to treat the connection as productive and go ahead
and parse it. But the TCP analyzer could continue to consider it
partial after flipping, meaning that app layers would bail out. #2426
shows such a case: HTTP gets correctly activated after flipping
through content inspection, but it won't process anything because
`IsPartial()` returns true. As the is-partial state reflects
whether we saw the first packets each in direction, this patch now
overrides that state for the originally missing SYN after flipping.

We actually had the same problem at a couple of other locations already
as well. One of that only happened to work because of the originally
inconsistent state flipping that was fixed in the previous commit. The
corresponding unit test now broke after that change. This commit
updates that logic as well to override the state.

This fix is a bit of a hack, but the best solution I could think of
without introducing larger changes.

Closes #2426.
2022-11-16 09:56:51 +01:00
Tim Wojtulewicz
a8fc63e182 Merge remote-tracking branch 'microsoft/master'
* microsoft/master: (71 commits)
  Clang formatting
  Mask ports before inserting them into the map
  Fix compiler warning from applied patch
  Remove statistics plugin in favor of stats bif
  Add EventHandler version of stats plugin
  Mark a few EventHandler methods const
  Changed implementation from std::map to std::unordered_map of Val.cc
  Removed const, Windows build is now working
  Added fixes suggested in PR
  Update src/packet_analysis/protocol/ip/IP.cc
  Apply suggestions from code review
  Clang format again but now with v13.0.1
  Rewrote usages of define(_MSC_VER) to ifdef _MSC_VER
  Clang format it all
  Fixed initial CR comments
  Add NEWS entry about Windows port
  Add a couple of extra unistd.h includes to fix a build failure
  Use std::chrono instead of gettimeofday
  Update libkqueue submodule [nomail]
  Don't call tokenize_string if the input string is empty
  ...
2022-11-11 15:23:21 -07:00
Tim Wojtulewicz
2739275b88 Merge remote-tracking branch 'jsoref/spelling-src'
* jsoref/spelling-src:
  Spelling src
2022-11-11 12:49:15 -07:00
Tim Wojtulewicz
cdae33fad8 Merge remote-tracking branch 'jsoref/spelling-pac'
* jsoref/spelling-pac:
  spelling: variation
  spelling: value
  spelling: session
  spelling: repetitions
  spelling: params
  spelling: further
  spelling: confirm
  spelling: channel
  spelling: announcement
2022-11-09 18:18:22 -07:00
Tim Wojtulewicz
a85f1044eb Merge remote-tracking branch 'jsoref/spelling-expr'
* jsoref/spelling-expr:
  spelling: successful
  spelling: deterministic
  spelling: canonicalize
  spelling: algorithm
2022-11-09 18:17:28 -07:00
Josh Soref
cd201aa24e Spelling src
These are non-functional changes.

* accounting
* activation
* actual
* added
* addresult
* aggregable
* aligned
* alternatively
* ambiguous
* analysis
* analyzer
* anticlimactic
* apparently
* application
* appropriate
* arithmetic
* assignment
* assigns
* associated
* authentication
* authoritative
* barrier
* boundary
* broccoli
* buffering
* caching
* called
* canonicalized
* capturing
* certificates
* ciphersuite
* columns
* communication
* comparison
* comparisons
* compilation
* component
* concatenating
* concatenation
* connection
* convenience
* correctly
* corresponding
* could
* counting
* data
* declared
* decryption
* defining
* dependent
* deprecated
* detached
* dictionary
* directional
* directly
* directory
* discarding
* disconnecting
* distinguishes
* documentation
* elsewhere
* emitted
* empty
* endianness
* endpoint
* enumerator
* essentially
* evaluated
* everything
* exactly
* execute
* explicit
* expressions
* facilitates
* fiddling
* filesystem
* flag
* flagged
* for
* fragments
* guarantee
* guaranteed
* happen
* happening
* hemisphere
* identifier
* identifies
* identify
* implementation
* implemented
* implementing
* including
* inconsistency
* indeterminate
* indices
* individual
* information
* initial
* initialization
* initialize
* initialized
* initializes
* instantiate
* instantiated
* instantiates
* interface
* internal
* interpreted
* interpreter
* into
* it
* iterators
* length
* likely
* log
* longer
* mainly
* mark
* maximum
* message
* minimum
* module
* must
* name
* namespace
* necessary
* nonexistent
* not
* notifications
* notifier
* number
* objects
* occurred
* operations
* original
* otherwise
* output
* overridden
* override
* overriding
* overwriting
* ownership
* parameters
* particular
* payload
* persistent
* potential
* precision
* preexisting
* preservation
* preserved
* primarily
* probably
* procedure
* proceed
* process
* processed
* processes
* processing
* propagate
* propagated
* prototype
* provides
* publishing
* purposes
* queue
* reached
* reason
* reassem
* reassemble
* reassembler
* recommend
* record
* reduction
* reference
* regularly
* representation
* request
* reserved
* retrieve
* returning
* separate
* should
* shouldn't
* significant
* signing
* simplified
* simultaneously
* single
* somebody
* sources
* specific
* specification
* specified
* specifies
* specify
* statement
* subdirectories
* succeeded
* successful
* successfully
* supplied
* synchronization
* tag
* temporarily
* terminating
* that
* the
* transmitted
* true
* truncated
* try
* understand
* unescaped
* unforwarding
* unknown
* unknowndata
* unspecified
* update
* usually
* which
* wildcard

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-09 12:08:15 -05:00
Tim Wojtulewicz
77c555a3a8 Fixing some issues from rebasing 2022-11-09 18:16:13 +02:00
Arne Welzel
6ef9423f3c analyzer/HTTP: Call TCP_ApplicationAnalyzer::Done() after RequestMade()/ReplyMade() 2022-11-08 16:44:42 -07:00
Josh Soref
6f30f8df7c spelling: successful
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:05:24 -05:00
Josh Soref
b79dfafefb spelling: algorithm
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:05:24 -05:00
Josh Soref
8995db4cd3 spelling: variation
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
711576c10f spelling: value
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
c22d4f5d8c spelling: session
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
4782193393 spelling: repetitions
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
683ef60823 spelling: params
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
e3d60ea268 spelling: further
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
015f27e345 spelling: confirm
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
075360773a spelling: channel
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Josh Soref
38d6cdeb89 spelling: announcement
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-07 20:04:58 -05:00
Tim Wojtulewicz
e8dbfc1cb0 Fix a bunch of variable shadowing issues from LGTM 2022-11-02 15:54:51 -07:00
Arne Welzel
4c00c3c4ca smb: Unify transaction_data_to_val() usage
the data/string handling in smb1-com-transaction.pcac was improved
with c75519ca88, re-use the added
functionality also for smb1-com-transaction-secondary.pac to avoid
buffer overflows.
2022-09-19 12:41:28 -07:00
Arne Welzel
6b6bd7e9f6 irc: Check parts.size() before removing the nick
...also, don't remove the nick twice.
2022-09-19 12:41:24 -07:00
Tim Wojtulewicz
4ed0acb006 Fix warning in modbus analyzer
This was introduced in 8d7a156109
2022-08-31 23:46:35 +00:00
Tim Wojtulewicz
8d7a156109 Fix potential overflow in modbus analyzer's bytestring_to_coils 2022-08-26 10:59:59 -07:00
Tim Wojtulewicz
519d0d810d Swap DNS EDNS field order to match script-land type 2022-08-26 10:59:21 -07:00
Tim Wojtulewicz
2abc82722f Fix a swath of AUTO_CAUSES_COPY issues reported by Coverity 2022-08-15 09:45:46 -07:00
Tim Wojtulewicz
f624c18383 Deprecate bro_int_t and bro_uint_t 2022-07-12 12:01:23 -07:00
Tim Wojtulewicz
15c0bd9b9d Fix signedness comparison warning in ssl analyzer 2022-07-05 13:33:34 -07:00
Johanna Amann
6e1e6fefe5 Merge remote-tracking branch 'origin/topic/johanna/2198'
* origin/topic/johanna/2198:
  SSL/GH-2211: Address review feedback, remove USE_FLIPPED
  SSL Analyzer: track connection direction by messages
2022-07-05 15:09:34 +01:00
Johanna Amann
2315d0344a SSL/GH-2211: Address review feedback, remove USE_FLIPPED
It turns out that we can just do this by using an argument.
2022-07-05 13:23:18 +01:00
Tim Wojtulewicz
77aa80033b Remove deprecated UDP, ICMP, and TCP analyzers 2022-06-30 19:11:59 +00:00
Tim Wojtulewicz
7c4fd382d9 Code modernization: Convert from deprecated C standard library headers 2022-06-27 09:47:31 -07:00
Johanna Amann
e14eddeb97 SSL Analyzer: track connection direction by messages
This PR changes the way in which the SSL analyzer tracks the direction
of connections. So far, the SSL analyzer assumed that the originator of
a connection would send the client hello (and other associated
client-side events), and that the responder would be the SSL servers.

In some circumstances this is not true, and the initiator of a
connection is the server, with the responder being the client. So far
this confused some of the internal statekeeping logic and could lead to
mis-parsing of extensions.

This reversal of roles can happen in DTLS, if a connection uses STUN -
and potentially in some StartTLS protocols.

This PR tracks the direction of a TLS connection using the hello
request, client hello and server hello handshake messages. Furthermore,
it changes the SSL events from providing is_orig to providing is_client,
where is_client is true for the client_side of a connection. Since the
argument positioning in the event has not changed, old scripts will
continue to work seamlessly - the new semantics are what everyone
writing SSL scripts will have expected in any case.

There is a new event that is raised when a connection is flipped. A
weird is raised if a flip happens repeatedly.

Addresses GH-2198.
2022-06-24 18:35:44 +01:00
Vern Paxson
847963e94d flip connections that begin with SYN-ACKs if subsequent acks or data seen 2022-06-15 14:01:32 -07:00
Tim Wojtulewicz
9964a46402 Fix hang in DNS analyzer with malformed packet
(cherry picked from commit dfc9f77b68f6d02d059ade322b9c132e32c26872)
2022-06-03 10:32:03 -07:00
Tim Wojtulewicz
d73f9a78dd Remove unnecessary uses of util::fmt() 2022-05-16 13:49:04 -07:00
Robin Sommer
d2e8c5e887
Allow analyzer violations to explicitly set tag.
We could already pass an overriding tag to
`Analyzer::AnalyzerConfirmation()`, but we didn't have that ability
for `AnalyzerViolation`, leading to the two potentially mismatching in
the analyzer they report.
2022-04-12 09:36:14 +02:00
Tim Wojtulewicz
ffb9ba1f26 GH-2009: Use auto to fix ZIP analyzer failure on some platforms 2022-04-03 16:48:51 -07:00
Johanna Amann
d38923cfcf Merge remote-tracking branch 'origin/topic/johanna/tls12-decryption'
Documentation is missing and will be added in the next couple of hours.

* origin/topic/johanna/tls12-decryption: (24 commits)
  TLS decryption: add test, fix small issues
  Address PR feedback
  TLS decryption: refactoring, more comments, less bare pointers
  Small code fix and test baseline update.
  SSL decryption: refactor TLS12_PRF
  SSL decryption: small style changes, a bit of documentation
  Deprecation and warning fixes
  Clang-format updates
  add missing call to EVP_KDF_CTX_set_params
  TLS decryption: remove payload from ssl_encrypted_data again.
  TLS 1.2 decryption: adapt OpenSSL 3.0 changes for 1.1
  ssl: adapt TLS-PRF to openSSL 3.0
  ssl/analyzer: potentially fix memory leaks caused by bytestrings
  analyzer/ssl: several improvements
  analyzer/ssl: defensive key length check + more debug logging
  testing: feature gate ssl/decryption test
  testing: add ssl/decryption test
  analyzer/ssl: handle missing <openssl/kdf.h>
  analyzer/ssl: silence warning in DTLS analyzer
  analyzer/ssl: move proc-{client,server}-hello into the respective analyzers
  ...
2022-03-02 08:20:39 +00:00
Johanna Amann
590d4aa13e TLS decryption: add test, fix small issues
Add a test loading keys from an external file. Make some debug messages
slightly better and remove unnecessary debug output.
2022-03-01 17:45:11 +00:00
Johanna Amann
1c9ea09d9f Address PR feedback
This addresses feedback to GH-1814. The most significant change is the
fact that the ChipertextRecord now can remain &transient - which might
lead to improved speed.
2022-02-23 11:31:21 +00:00
Robin Sommer
9b0d525728
Let our TCP-based application analyzers operate without any TCP parent analyzer.
Conceptually, a TCP-based application analyzer should not need any
knowledge about the underlying TCP analysis; it's supposed to just
process its reassembled input stream as it's handed over. But our
analyzers break that assumption at a few places because sometimes
knowledge about the TCP state of the connection can be helpful for
heuristics. This is fine as long as there actually *is* a TCP parent
analyzer available. Sometimes, however, there isn't: if the payload
stream is encapsulated inside another application-layer protocol, the
semantic link to TCP is broken. And if the outer connection is even
UDP, then we don't have a TCP analyzer at all.

We didn't handle this situation well so far. Most analyzers needing
TCP state would just crash if there's no TCP analyzer (in debug mode
with an `assert`, in release mode with a null pointer deref ...). Only
HTTP did the right thing already: check if TCP is available and adapt
accordingly.

We know extend that check to all other analyzers as well: all accesses
to `TCP()` are guarded, with reasonable defaults if not available.
It's actually a pretty small change overall, which is evidence for how
little this layering violation actually matters.

The existing behavior is what's causing
https://github.com/corelight/zeek-spicy-openvpn/issues/3.
2022-01-28 16:25:27 +01:00
Vern Paxson
d758585e42 updated Bro->Zeek in comments in the source tree 2022-01-24 14:26:20 -08:00
Johanna Amann
b78f30339f TLS decryption: refactoring, more comments, less bare pointers
This commit refactors TLS decryption, adds more comments in scripts and
in C++ source-code, and removes use of bare pointers, instead relying
more on stl data types.
2022-01-17 15:04:44 +00:00
Johanna Amann
543c992e66 Small code fix and test baseline update.
After this, tests hopefully should pass consistently.
2022-01-11 11:20:05 +00:00