Skip to content

Commit

Permalink
rust: implement JA4 fingerprints for TLS and QUIC
Browse files Browse the repository at this point in the history
Ticket: #6379
  • Loading branch information
satta committed Feb 11, 2024
1 parent 7e4dba7 commit ac56999
Show file tree
Hide file tree
Showing 33 changed files with 1,241 additions and 52 deletions.
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,27 @@
fi
fi

AC_ARG_ENABLE(ja3,
AS_HELP_STRING([--disable-ja3], [Disable JA3 support]),
[enable_ja3="$enableval"],
[enable_ja3=yes])
if test "$enable_ja3" = "yes"; then
AC_DEFINE([HAVE_JA3],[1],[JA3 enabled])
enable_ja3="yes"
fi
AM_CONDITIONAL([HAVE_JA3], [test "x$enable_ja3" != "xno"])

AC_ARG_ENABLE(ja4,
AS_HELP_STRING([--disable-ja4], [Disable JA4 support]),
[enable_ja4="$enableval"],
[enable_ja4=yes])
if test "$enable_ja4" = "yes"; then
AC_DEFINE([HAVE_JA4],[1],[JA4 enabled])
enable_ja4="yes"
fi
AM_CONDITIONAL([HAVE_JA4], [test "x$enable_ja4" != "xno"])


# Check for lz4
enable_liblz4="yes"
AC_CHECK_LIB(lz4, LZ4F_createCompressionContext, , enable_liblz4="no")
Expand Down Expand Up @@ -2669,6 +2690,8 @@ SURICATA_BUILD_CONF="Suricata Configuration:
LUA support: ${enable_lua}
libluajit: ${enable_luajit}
GeoIP2 support: ${enable_geoip}
JA3 support: ${enable_ja3}
JA4 support: ${enable_ja4}
Non-bundled htp: ${enable_non_bundled_htp}
Hyperscan support: ${enable_hyperscan}
Libnet support: ${enable_libnet}
Expand Down
15 changes: 12 additions & 3 deletions doc/userguide/output/eve/eve-json-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,9 @@ If extended logging is enabled the following fields are also included:
* "notafter": The NotAfter field from the TLS certificate
* "ja3": The JA3 fingerprint consisting of both a JA3 hash and a JA3 string
* "ja3s": The JA3S fingerprint consisting of both a JA3 hash and a JA3 string
* "ja4": The JA4 client fingerprint for TLS

JA3 must be enabled in the Suricata config file (set 'app-layer.protocols.tls.ja3-fingerprints' to 'yes').
JA3 and JA4 must be enabled in the Suricata config file (set 'app-layer.protocols.tls.ja3-fingerprints'/'app-layer.protocols.tls.ja4-fingerprints' to 'yes').

In addition to this, custom logging also allows the following fields:

Expand Down Expand Up @@ -2915,11 +2916,14 @@ Fields
* "cyu": List of found CYUs in the packet
* "cyu[].hash": CYU hash
* "cyu[].string": CYU string
* "ja3": The JA3 fingerprint consisting of both a JA3 hash and a JA3 string
* "ja3s": The JA3S fingerprint consisting of both a JA3 hash and a JA3 string
* "ja4": The JA4 client fingerprint for QUIC

Examples
~~~~~~~~

Example of QUIC logging with a CYU hash:
Example of QUIC logging with CYU, JA3 and JA4 hashes (note that the JA4 hash is only an example to illustrate the format and does not correlate with the others):

::

Expand All @@ -2931,7 +2935,12 @@ Example of QUIC logging with a CYU hash:
"hash": "7b3ceb1adc974ad360cfa634e8d0a730",
"string": "46,PAD-SNI-STK-SNO-VER-CCS-NONC-AEAD-UAID-SCID-TCID-PDMD-SMHL-ICSL-NONP-PUBS-MIDS-SCLS-KEXS-XLCT-CSCT-COPT-CCRT-IRTT-CFCW-SFCW"
}
]
],
"ja3": {
"hash": "324f8c50e267adba4b5dd06c964faf67",
"string": "771,4865-4866-4867,51-43-13-27-17513-16-45-0-10-57,29-23-24,"
},
"ja4": "q13d0310h3_55b375c5d22e_cd85d2d88918"
}

Event type: DHCP
Expand Down
2 changes: 1 addition & 1 deletion doc/userguide/output/eve/eve-json-output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ YAML::
extended: yes # enable this for extended logging information
# custom allows to control which tls fields that are included
# in eve-log
#custom: [subject, issuer, serial, fingerprint, sni, version, not_before, not_after, certificate, chain, ja3, ja3s]
#custom: [subject, issuer, serial, fingerprint, sni, version, not_before, not_after, certificate, chain, ja3, ja3s, ja4]

The default is to log certificate subject and issuer. If ``extended`` is
enabled, then the log gets more verbose.
Expand Down
1 change: 1 addition & 0 deletions doc/userguide/rules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Suricata Rules
tls-keywords
ssh-keywords
ja3-keywords
ja4-keywords
modbus-keyword
dcerpc-keywords
dhcp-keywords
Expand Down
30 changes: 30 additions & 0 deletions doc/userguide/rules/ja4-keywords.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
JA4 Keywords
============

Suricata comes with a JA4 integration (https://github.com/FoxIO-LLC/ja4). JA4,
as part of the larger JA4+ suite of fingerprints, is used to fingerprint TLS
clients.

We might in the future consider adding raw and original order strings (JA4_r,
JA4_o, JA4_ro) as non-hashed versions.

JA4 support must be enabled in the Suricata config file (set
``app-layer.protocols.tls.ja4-fingerprints`` to ``yes``). If it is not
explicitly disabled (``no``) , it will enabled if a loaded rule requires it.
It also needs to be enabled at compile time (``--enable-ja4``).

ja4.hash
--------

Match on JA4 hash (e.g. ``q13d0310h3_55b375c5d22e_cd85d2d88918``).

Example::

alert quic any any -> any any (msg:"match JA4 hash"; \
ja4.hash; content:"q13d0310h3_55b375c5d22e_cd85d2d88918"; \
sid:100001;)

``ja4.hash`` is a 'sticky buffer'.

``ja4.hash`` can be used as ``fast_pattern``.

6 changes: 6 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3012,6 +3012,9 @@
},
"additionalProperties": false
},
"ja4": {
"type": "string"
},
"sni": {
"description": "Server Name Indication",
"type": "string"
Expand Down Expand Up @@ -5405,6 +5408,9 @@
}
},
"additionalProperties": false
},
"ja4": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lua_int8 = ["lua"]
strict = []
debug = []
debug-validate = []
ja4 = []

[dependencies]
nom7 = { version="7.0", package="nom" }
Expand Down
4 changes: 4 additions & 0 deletions rust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if HAVE_LUA
RUST_FEATURES += lua $(LUA_INT8)
endif

if HAVE_JA4
RUST_FEATURES += ja4
endif

if DEBUG
RUST_FEATURES += debug
endif
Expand Down
Loading

0 comments on commit ac56999

Please sign in to comment.