Skip to content

Comments

rust/sip: register parser for tcp v10#9909

Closed
glongo wants to merge 8 commits intoOISF:masterfrom
glongo:dev-sip-tcp-v10
Closed

rust/sip: register parser for tcp v10#9909
glongo wants to merge 8 commits intoOISF:masterfrom
glongo:dev-sip-tcp-v10

Conversation

@glongo
Copy link
Contributor

@glongo glongo commented Nov 28, 2023

Make sure these boxes are signed before submitting your Pull Request -- thank you.

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/3351

Describe changes:

  • Documentation updated
  • SIP version parser fixed
  • Probing parser functions removed

Provide values to any of the below to override the defaults.

To use a pull request use a branch name like pr/N where N is the
pull request number.

Alternatively, SV_BRANCH may also be a link to an
OISF/suricata-verify pull-request.

SV_REPO=
SV_BRANCH=pr/1499
SU_REPO=
SU_BRANCH=
LIBHTP_REPO=
LIBHTP_BRANCH=

Accepts valid characters as defined in RFC3261.
The `is_version_char` function incorrectly allowed characters that are not
part of the valid SIP version "SIP/2.0".

For instance, 'HTTP/1.1' was mistakenly accepted as a valid SIP version,
although it's not.

This commit fixes the issue by updating the condition to strictly
check for the correct version string.
This patch lets the parser to work over tcp protocol, taking care of handling
data before calling the request/response parsers.

Ticket OISF#3351.
This patch permits to set a direction when a new transaction is created in order
to avoid 'signature shadowing' as reported by Eric Leblond in commit
5aaf507
This permits to detect the SIP protocol using pattern matching instead of
probing parser.

Since it is no longer used, the respective probing functions have been removed.
@glongo glongo changed the title rust/sip: register parser for tcp v9 rust/sip: register parser for tcp v10 Nov 28, 2023
@codecov
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Merging #9909 (3278556) into master (9c3ab36) will decrease coverage by 0.02%.
The diff coverage is 90.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9909      +/-   ##
==========================================
- Coverage   82.35%   82.33%   -0.02%     
==========================================
  Files         972      972              
  Lines      273060   273220     +160     
==========================================
+ Hits       224870   224949      +79     
- Misses      48190    48271      +81     
Flag Coverage Δ
fuzzcorpus 64.13% <69.91%> (-0.02%) ⬇️
suricata-verify 61.06% <90.70%> (-0.04%) ⬇️
unittests 62.91% <33.05%> (-0.01%) ⬇️

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


#[no_mangle]
pub unsafe extern "C" fn rs_sip_register_parser() {
let default_port = CString::new("[5060,5061]").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about 55216df ?

fn parse_version(i: &[u8]) -> IResult<&[u8], &str> {
map_res(take_while1(is_version_char), std::str::from_utf8)(i)
fn parse_version(i: &[u8]) -> IResult<&[u8], String> {
let (i, prefix) = map_res(tag("SIP/"), std::str::from_utf8)(i)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the utf8 here ?

Copy link
Contributor

@jufajardini jufajardini left a comment

Choose a reason for hiding this comment

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

Documentation changes look good to me :)

@suricata-qa
Copy link

ERROR:

ERROR: QA failed on ASAN_TLPR1_suri.

Pipeline 16804

@catenacyber
Copy link
Contributor

ERROR:

ERROR: QA failed on ASAN_TLPR1_suri.

Pipeline 16804

QA failure is triggered assertion
app-layer-detect-proto.c:1434: AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *, Flow *, const uint8_t *, uint32_t, uint8_t, uint8_t, _Bool *): Assertion !((pm_matches > 1))' failed.`

Can you investigate if one pattern registered for protocol detection is a duplicate ? (or a prefix maybe )

@glongo
Copy link
Contributor Author

glongo commented Nov 30, 2023

ERROR:
ERROR: QA failed on ASAN_TLPR1_suri.
Pipeline 16804

QA failure is triggered assertion app-layer-detect-proto.c:1434: AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *, Flow *, const uint8_t *, uint32_t, uint8_t, uint8_t, _Bool *): Assertion !((pm_matches > 1))' failed.`

Can you investigate if one pattern registered for protocol detection is a duplicate ? (or a prefix maybe )

Where is this error coming from? Is it reproducible?

@catenacyber
Copy link
Contributor

Yes but not sure we can share the pcap

@catenacyber
Copy link
Contributor

OPTIONS is also a HTTP method...

@glongo
Copy link
Contributor Author

glongo commented Nov 30, 2023

OPTIONS is also a HTTP method...

This is exactly what I was fearing. Initially, I thought that using the same method between SIP and HTTP could lead to conflicts.
Please share the pcap file if possible, so I can confirm this.
Otherwise, feel free to debug it yourself if you are unable to share it (and if you want, obviously).

@catenacyber
Copy link
Contributor

Please share the pcap file if possible, so I can confirm this.
Otherwise, feel free to debug it yourself if you are unable to share it (and if you want, obviously).

TL;DR let's remove the OPTIONS method for SIP recognition

If you want a pcap, you can try to create one by sending a OPTIONS request to a HTTP server (like curl -X OPTIONS 127.0.0.1:8080/

@glongo
Copy link
Contributor Author

glongo commented Dec 5, 2023

Replaced by #9967

@glongo glongo closed this Dec 5, 2023
@victorjulien
Copy link
Member

So OPTIONS could be a nice candidate for a PM+PP setup both in HTTP and SIP, where the PP would do the additional validation of the protocol?

@catenacyber
Copy link
Contributor

So OPTIONS could be a nice candidate for a PM+PP setup both in HTTP and SIP, where the PP would do the additional validation of the protocol?

Indeed.

The current behavior is to recognize it as HTTP.
So, I would have it as a separate issue.

@glongo glongo deleted the dev-sip-tcp-v10 branch February 28, 2024 14:11
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.

6 participants