Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple stream bypass from TLS encrypted bypass v9.2 #12655

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lukashino
Copy link
Contributor

Following up on #12573

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/6788

Describe changes:
v9.2:

  • rebased

v9.1:

  • separated mixed changes into their respective commits

v9:

  • changed mutex to atomicu8 for SSH encryption handling choice
  • rebased

v8.1:

  • specify the correct SV test

v8:

v7

  • Style guide changes as suggested in the prev PR
  • Encryption Handling has now three states, similar to TLS
  • rebased

v6

  • rebased

v5

  • rebased
  • added upgrade section
  • fixed docs - Thanks Juliana
  • SV tests should pass now

v4

  • rebased
  • changed SSH bypass defaults to hopefully be in sync with the previous settings

v3

  • added SSH app-layer option encryption-handling allowing to choose whether to continue inspection on SSH once it turns encrypted
  • added SV tests
  • minor docs updates

SV_BRANCH=OISF/suricata-verify#2315

Lukas Sismis and others added 4 commits February 22, 2025 10:11
Decouple app.protocols.tls.encryption-handling and stream.bypass.
There's no apparent reason why encrypted TLS bypass traffic should
depend on stream bypass, as these are unrelated features.

Ticket: 6788
@lukashino
Copy link
Contributor Author

digging up a comment from PR #12388 :

@catenacyber wrote:

@victorjulien could I review this ? (asking since you self-assigned yourself)

I want to dig into the QA diff and the explanation of it in the previous version especially...

Copy link

codecov bot commented Feb 22, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.77%. Comparing base (3bc2a14) to head (0008355).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12655   +/-   ##
=======================================
  Coverage   80.77%   80.77%           
=======================================
  Files         932      932           
  Lines      259517   259549   +32     
=======================================
+ Hits       209629   209661   +32     
  Misses      49888    49888           
Flag Coverage Δ
fuzzcorpus 56.97% <42.50%> (-0.02%) ⬇️
livemode 19.36% <12.50%> (-0.01%) ⬇️
pcap 44.15% <42.50%> (-0.01%) ⬇️
suricata-verify 63.51% <82.05%> (+<0.01%) ⬆️
unittests 58.31% <42.50%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 637 670 105.18%
.flow.end.state.local_bypassed 26015 17671 67.93%
IPS_AFP_stats_chk
.flow.end.state.local_bypassed 1080 0 -
.flow_bypassed.local_pkts 25920 0 -
.flow_bypassed.local_bytes 2833920 0 -

Pipeline 24863

@catenacyber
Copy link
Contributor

Are QA results expected ? (should we set label requires-baseline ? )

@@ -203,13 +224,24 @@ impl SSHState {
parser::MessageCode::NewKeys => {
hdr.flags = SSHConnectionState::SshStateFinished;
if ohdr.flags >= SSHConnectionState::SshStateFinished {
unsafe {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing the default ?

SSH by default did like SSH_HANDLE_ENCRYPTION_BYPASS here : APP_LAYER_PARSER_NO_INSPECTION | APP_LAYER_PARSER_NO_REASSEMBLY | APP_LAYER_PARSER_BYPASS_READY

# hassh: no

# What to do when the encrypted communications start:
# - default: keep tracking but stop inspection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be named default but how it behaves like stop_inspect_only, right ?

@@ -55,6 +55,8 @@

/* HASSH fingerprints are disabled by default */
#define SSH_CONFIG_DEFAULT_HASSH false
/* Bypassing the encrypted part of the connections */
#define SSH_CONFIG_DEFAULT_ENCRYPTION_BYPASS SSH_HANDLE_ENCRYPTION_DEFAULT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : why do we need this define instead of reusing SSH_HANDLE_ENCRYPTION_DEFAULT directly ?


static mut ALPROTO_SSH: AppProto = ALPROTO_UNKNOWN;
static HASSH_ENABLED: AtomicBool = AtomicBool::new(false);

static ENCRYPTION_BYPASS_ENABLED: AtomicU8 = AtomicU8::new(SshEncryptionHandling::SSH_HANDLE_ENCRYPTION_DEFAULT as u8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jasonish is this the good rust way ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and no. Its the recommended way for a global static mutable, just making it a static mutable results in a compiler warning:

But perhaps not the best Suricata way if only modified on initialization, see:
#12665

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html#no_std-one-time-initialization looks pretty similar to what we do now, except adding a wrapper function to return a const (instead of mut)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uses atomics right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still uses atomics right?

Not really, atomics are here not used for static mut STATE

They just want to add checks for the initialization of the global, but in our cases, it is done right I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems as simple as this: b486d55

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

}

#[no_mangle]
pub extern "C" fn SCSshEncryptionBypassMode() -> SshEncryptionHandling {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused, should be removed, right ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants