Skip to content

Commit 54cc752

Browse files
catenacybervictorjulien
authored andcommitted
ssh: hassh can be truly disabled
Rules will not re-enable it Ticket: 8223
1 parent 458211d commit 54cc752

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

doc/userguide/configuration/suricata-yaml.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,14 @@ present, and ``encryption-handling`` is not, ``false`` is interpreted as
19891989
``encryption-handling: track-only`` and ``true`` is interpreted as
19901990
``encryption-handling: bypass``.
19911991

1992+
SSH
1993+
~~~
1994+
1995+
Besides ``encryption-handling``, ssh parser offers the ``hassh`` option
1996+
with 3 values
1997+
- yes : enables hassh logging
1998+
- auto : hassh be enabled if rules use hassh keywords
1999+
- no : disables hassh and will refuse to load rules that use hassh keywords
19922000

19932001
Modbus
19942002
~~~~~~

doc/userguide/upgrade.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ Other Changes
7373
See :ref:`Hyperscan caching configuration
7474
<hyperscan-cache-configuration>` for more information.
7575

76+
- The ``no`` option in ``app-layer.protocols.ssh.hassh`` is now
77+
really enforced and there will be no hassh computation
78+
even if rules try to use it.
79+
80+
7681
Upgrading to 8.0.1
7782
------------------
7883

rust/src/ssh/ssh.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use suricata_sys::sys::{
3333

3434
pub(super) static mut ALPROTO_SSH: AppProto = ALPROTO_UNKNOWN;
3535
static HASSH_ENABLED: AtomicBool = AtomicBool::new(false);
36+
static HASSH_DISABLED: AtomicBool = AtomicBool::new(false);
3637

3738
static mut ENCRYPTION_BYPASS_ENABLED: EncryptionHandling =
3839
EncryptionHandling::ENCRYPTION_HANDLING_TRACK_ONLY;
@@ -585,14 +586,21 @@ pub unsafe extern "C" fn SCRegisterSshParser() {
585586

586587
#[no_mangle]
587588
pub extern "C" fn SCSshEnableHassh() {
588-
HASSH_ENABLED.store(true, Ordering::Relaxed)
589+
if !HASSH_DISABLED.load(Ordering::Relaxed) {
590+
HASSH_ENABLED.store(true, Ordering::Relaxed)
591+
}
589592
}
590593

591594
#[no_mangle]
592595
pub extern "C" fn SCSshHasshIsEnabled() -> bool {
593596
hassh_is_enabled()
594597
}
595598

599+
#[no_mangle]
600+
pub extern "C" fn SCSshDisableHassh() {
601+
HASSH_DISABLED.store(true, Ordering::Relaxed)
602+
}
603+
596604
#[no_mangle]
597605
pub extern "C" fn SCSshEnableBypass(mode: EncryptionHandling) {
598606
unsafe {

src/app-layer-ssh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void RegisterSSHParsers(void)
9696
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
9797
} else if (SCConfValIsFalse(strval)) {
9898
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
99+
SCSshDisableHassh();
99100
} else if (SCConfValIsTrue(strval)) {
100101
enable_hassh = true;
101102
}

suricata.yaml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ app-layer:
993993
#enabled: yes
994994
ssh:
995995
enabled: yes
996-
# hassh: no
996+
# hassh: auto
997997

998998
# What to do when the encrypted communications start:
999999
# - track-only: keep tracking but stop inspection (default)

0 commit comments

Comments
 (0)