Commit Graph

265 Commits (65b863b087d8f6d7c0800700f89ca33f06ad861f)

Author SHA1 Message Date
Victor Julien 471bde4426 tls: more permissive empty data eof check
If not all data is ACK'd during the FIN session shutdown, the last calls
to the parser can be with a non-NULL data pointer, but a input length of
0. This wasn't considered by the EOF check, which then lead to it being
seen as an error. No event was raised, but the tls error stats were
incremented.

Bug: #7554.
2 years ago
Philippe Antoine b02557ac7d app-layer: track modified/processed txs
To optimize detection, and logging, to avoid going through
all the live transactions when only a few were modified.

Two boolean fields are added to the tx data: updated_tc and ts
The app-layer parsers are now responsible to set these when
needed, and the logging and detection uses them to skip
transactions that were not updated.

There may some more optimization remaining by when we set
both updated_tc and updated_ts in functions returning
a mutable transaction, by checking if all the callers
are called in one direction only (request or response)

Ticket: 7087
2 years ago
Jason Ish d4a3ee163d misc: remove unneeded headers
Remove unneeded headers from worked on in previous commits, just
simple ones flagged by clangd.
2 years ago
Jason Ish ab6dcb3fc1 app-layer: use uint8_t consistent for event IDs
Introduce a common function for mapping names to IDs that performs
bounds checking.

Note: For event IDs in the enum that are larger than a uint8_t, -1
will be returned instead of -4. -4 has special meaning during
signature parsin that means requirements were not met. -4 has no
special handling prior to requirements, or the meaning has been lost.
2 years ago
Philippe Antoine 1d32f11745 ssl/ja3: better check for ja3 being enabled
Ticket: 6634

Completes commit 84735251b5

Avoids error log in Ja3BufferAddValue about NULL buffer
2 years ago
Philippe Antoine 84735251b5 tls/ja3: do not append to ja3 str once ja3 hash is computed
Ticket: 6634

That means take only the first client hello into account.
This way, we do not end with ja3 string with 9 commas...
2 years ago
Philippe Antoine 0d4efe0c0f app-layer: fix -Wshorten-64-to-32 warnings
Ticket: #6186

Warnings about downcast from 64 to 32 bits
2 years ago
Victor Julien 0b37654578 tls: store all ALPN records in the state
For later logging and detection.
2 years ago
Philippe Antoine 20423fdd38 style: remove some useless return
and remove empty line before end of function
2 years ago
Philippe Antoine ce9bfba76a ci: fix and test with Wunused-macros
Ticket: 6937
2 years ago
Shivani Bhardwaj 3a1c12414a tls: store list of subject alternative names
So far, the SANs were available as a part of IssuerDN via x509_parser
crate but SANs were not available to the SSLState* to be directly used
to setup and match against a sticky buffer.
Expose it to SSLStateConnp.

Feature 5234
2 years ago
Sascha Steinbiss 120313f4da ja4: implement for TLS and QUIC
Ticket: OISF#6379
3 years ago
Sascha Steinbiss 9d0db71ebf ja3: make feature compile time configurable 3 years ago
Juliana Fajardini cea917c38c app-layer: fix minor typo and formatting in LogInfo
Also update copyright years.
3 years ago
Jeff Lucovsky 193e0ea1a9 memory/alloc: Use SCCalloc instead of malloc/memset 3 years ago
Victor Julien 9a4231d737 src: various comment spelling fixes
Thanks to Josh Soref.
4 years ago
Victor Julien f28459ed78 app-layer: spelling 4 years ago
Jason Ish 6344501dba tls: fix date logging for dates before 1970
The Rust time crate used by the x509-parser crate represents dates
before 1970 as negative numbers which do not survive the conversion to
SCTime_t and formatting with the current time formatting functions.

Instead of fixing our formatting functions to handle such dates,
create a Rust function for logging TLS dates directly to JSON using
the time crate that handles such dates properly.

Also add a FFI function for formatting to a provided C buffer for the
legacy tls-log.

Issue: 5817
4 years ago
Victor Julien b31ffde6f4 output: remove error codes from output 4 years ago
Philippe Antoine b5147189ae tls: fix off by one in supported versions extension
Ticket: #5663
4 years ago
Victor Julien 8f0d820218 ssl: add debug validation checks for recent changes
Make sure the assumptions are correct.
4 years ago
Philippe Antoine 3fbcba8ab7 tls: fix buffer overread
Recently introduced by commit 4bab6e24e5

Ticket: #5564
4 years ago
Philippe Antoine 5a0d07b13f clean: remove useless * sizeof(char) 4 years ago
Victor Julien c27df6304d app-layer: introduce common AppLayerStateData API
Add per state structure for storing flags and other variables.
4 years ago
Philippe Antoine ae6abd8ca3 ssl: fix compiler warning
implicit conversion loses integer precision: 'int' to 'uint16_t'
because C shifts << translates automatically to signed integers
4 years ago
Victor Julien 1701a6b14c tls: handle incomplete header sooner
Make sure to exit the parser early on incomplete header data.

Additionally, make sure to not create duplicated tls frames in this
case.

Add a debug validation check for the header parser parsing too much
data, which should never happen.
4 years ago
Victor Julien 9053c49178 ssl: add debug validation check for incomplete api 4 years ago
Victor Julien 69be41b241 tls: improve record checks
Improve unknown record handling. Inspired by Wireshark 'unknown record'
handling, we take a best effort approach for records with unknown content
types in TLS versions 1.0, 1.1 and 1.2.

Improve record length check and set 'invalid_record_length' event instead
of 'invalid_tls_header'.
4 years ago
Victor Julien c028800ae1 tls: improve versions extension logic
Skip over unusable versions like GREASE.
4 years ago
Victor Julien 599791fa33 tls: make version and size checks stricter
This way bad records won't buffer lots of stream data.
4 years ago
Victor Julien c73d812026 tls: store cert data in heap buffer
Cert chain is a list of pointers into this buffer, so can't use a
stream slice approach.
4 years ago
Victor Julien e817a8f968 tls: parse client certificates
Parse client cerificates and store them in the state similar to how
this is done for server certificates.

Update "progress" handling to not consider the TLS handshake complete
if the server indicated a client cert was needed.
4 years ago
Victor Julien 10f5e6cb66 tls: prepare for client cert parsing 4 years ago
Victor Julien 14b2e04b58 tls: make cert handling more generic
In preparation for client cert handling.
4 years ago
Victor Julien cf4c201acb tls: avoid tls.invalid_handshake_message FP
Don't set TLS_DECODER_EVENT_INVALID_HANDSHAKE_MESSAGE event on encrypted
handshake messages.
4 years ago
Victor Julien e9d63f3355 tls: don't set 2 events for a single exception
Keep the more specific ones.
4 years ago
Victor Julien 214e466b29 tls: remove incomplete tests
These tests are incompatible with the incomplete API usage and should
have been pcap based tests in the first place.
4 years ago
Victor Julien 82e03bd8fc tls: set event if record size exceeds limit 4 years ago
Victor Julien e857c864ca tls: support server hello done message 4 years ago
Victor Julien 4bab6e24e5 tls: support handshake fragmentation
Implement TLS record defrag for handshake messages.

Ticket: #5183.
4 years ago
Victor Julien bcaf0f6f7d tls: remove certificate buffering code
TCP Buffering is now done in the app-layer using the incomplete API, on
the SSL/TLS record level. TLS level fragmentation will be implemented
separately.
4 years ago
Victor Julien 0839317ea7 tls: parse handshake protocol records in single pass 4 years ago
Victor Julien 9f0ea5e70c sslv2: use version from client hello
Remove streaming code that is now unused.

Incomplete handling makes this record parsing work on full data.
4 years ago
Victor Julien c8d79fb81f ssl: implement 'incomplete' handling for SSLv2 4 years ago
Victor Julien 6076a51511 tls: streaming mode for application records
To avoid overhead of stream buffering for records we don't do
much with anyway, pass through application records instead of
buffering the entire record in the stream engine.
4 years ago
Victor Julien 129fcb5c72 tls: use incomplete API to get full TLS records
The TLS record header is parsed in streaming mode still, but once the
record size is known we tell the app-layer API to give us the full
record.

Ticket: #5481
4 years ago
Victor Julien dbf3d1e977 tls: make SSLSetEvent a macro to help debugging 4 years ago
Victor Julien e250ef6402 debug: remove empty header 4 years ago
Shivani Bhardwaj 42c3f418c6 tls: add tls.random* keywords
Add tls.random keyword that matches on the 32 bytes of the TLS
random field for client as well as server.
Add tls.random_time keyword that matches on the first 4 bytes of the TLS
random field for client as well as server.
Add tls.random_bytes keyword that matches on the last 28 bytes of the TLS
random field for client as well as server.

All these are sticky buffers.

Feature 5190
4 years ago
Philippe Antoine 02f2602dde src: rework includes as per cppclean 4 years ago