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

5912 rfb skip v4 #9071

Closed
wants to merge 3 commits into from
Closed

5912 rfb skip v4 #9071

wants to merge 3 commits into from

Conversation

satta
Copy link
Contributor

@satta satta commented Jun 26, 2023

Previous PR: #9064

Link to redmine ticket: #5912

Describe changes to previous PR:

  • Add Redmine bug number to main commit with relevant changes.

We only try to parse a small subset of what is possible in
RFB. Currently we only understand some standard auth schemes
and stop parsing when the server-client handshake is complete.
Since in IPS mode returning an error from the parser causes
drops that are likely uncalled for, we do not want to return
errors when we simply do not understand what happens in the
traffic. This addresses Redmine OISF#5912.
@satta satta requested review from jasonish and a team as code owners June 26, 2023 07:21
@satta satta changed the title 912 rfb skip v4 5912 rfb skip v4 Jun 26, 2023
@satta satta mentioned this pull request Jun 26, 2023
Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

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

Thanks Sascha.

CI : green
Code : a few questions
Commits segmentation : ok for me
Commit messages : ok for me. @satta the ticket number should be on its own line as Ticket: #5912 cf git log | grep '#'
Git ID set : ok
CLA : ok
Doc update : none needed
Redmine ticket : ok
Rustfmt : ok
Tests : I wonder if the IPS app-layer.error-policy: drop-flow should be tested somehow
Dependencies added: none

@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Merging #9071 (d0dc924) into master (643e674) will decrease coverage by 0.09%.
The diff coverage is 40.17%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9071      +/-   ##
==========================================
- Coverage   82.35%   82.26%   -0.09%     
==========================================
  Files         969      969              
  Lines      273655   273721      +66     
==========================================
- Hits       225359   225173     -186     
- Misses      48296    48548     +252     
Flag Coverage Δ
fuzzcorpus 64.51% <38.26%> (-0.07%) ⬇️
suricata-verify 60.58% <24.34%> (-0.07%) ⬇️
unittests 62.89% <7.69%> (-0.02%) ⬇️

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

@satta
Copy link
Contributor Author

satta commented Jun 26, 2023

Thanks Sascha.

CI : green Code : a few questions Commits segmentation : ok for me Commit messages : ok for me. @satta the ticket number should be on its own line as Ticket: #5912 cf git log | grep '#'

Will keep this in mind for next time.

@victorjulien
Copy link
Member

Thanks Sascha.
CI : green Code : a few questions Commits segmentation : ok for me Commit messages : ok for me. @satta the ticket number should be on its own line as Ticket: #5912 cf git log | grep '#'

Will keep this in mind for next time.

Patched this up in staging.

@satta
Copy link
Contributor Author

satta commented Jun 27, 2023

[...]

Patched this up in staging.

Thanks!

This was referenced Jun 27, 2023
@victorjulien
Copy link
Member

victorjulien commented Jun 27, 2023

It gives more RFB flow and transactions, and fewer errors. W/o looking at the (private) traffic, does this seem plausible based on the changes?

See #9083 (comment)

@satta
Copy link
Contributor Author

satta commented Jun 27, 2023

I would say so. The point of this change was to reduce the amount of app-layer errors when technically there is no error but we just don't implement all of RFB's variety in the field.
Error should now be restricted to cases where we can't even see a proper handshake at the beginning of the flow.

@victorjulien
Copy link
Member

I would say so. The point of this change was to reduce the amount of app-layer errors when technically there is no error but we just don't implement all of RFB's variety in the field. Error should now be restricted to cases where we can't even see a proper handshake at the beginning of the flow.

Thanks Sascha!

@victorjulien
Copy link
Member

Merged in #9083, thanks!

@satta satta deleted the 912-rfb-skip-v4 branch June 27, 2023 18:21
@catenacyber
Copy link
Contributor

For information @satta the rfb error comes from a real RFB conversation, but the TCP client first sends Data: 0500040003c61ef656 before the RFB version...

@catenacyber
Copy link
Contributor

More important @satta, every time you self.state = parser::RFBGlobalState::Skip;, you should also current_transaction.complete = true;

Otherwise, the transaction does not get logged...

@catenacyber
Copy link
Contributor

catenacyber commented Jun 28, 2023

And it looks like the client can send its version first, which is not handled bu the current state machine

@satta
Copy link
Contributor Author

satta commented Jun 29, 2023

And it looks like the client can send its version first, which is not handled bu the current state machine

I can't see any indication of this being valid in the protocol [1][2] -- the server always advertises its version first AFAICS. Could we be seeing one-sided traffic or something like that there?

[1] https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#handshaking-messages
[2] https://datatracker.ietf.org/doc/html/rfc6143#section-7.1.1

@satta
Copy link
Contributor Author

satta commented Jun 29, 2023

For information @satta the rfb error comes from a real RFB conversation, but the TCP client first sends Data: 0500040003c61ef656 before the RFB version...

No idea what this could be. Can you share a pcap?

@satta
Copy link
Contributor Author

satta commented Jun 29, 2023

More important @satta, every time you self.state = parser::RFBGlobalState::Skip;, you should also current_transaction.complete = true;

Otherwise, the transaction does not get logged...

I guess we can still log whatever data we have so far then, right. I'll add that.

@catenacyber
Copy link
Contributor

These pcaps cannot be shared unfortunately

the server always advertises its version first AFAICS.

Both sides, TCP client first, then TCP server sends the RFB version

@satta
Copy link
Contributor Author

satta commented Jun 30, 2023

the server always advertises its version first AFAICS.

Both sides, TCP client first, then TCP server sends the RFB version

Where do you see this? The specs I linked in my previous message above as well as the pcaps I have recorded from my own traffic state that the server that is contacted via TCP sends its version to the connecting client first to make it possible for the client to check if a common protocol version can be found:

Handshaking begins by the server sending the client a ProtocolVersion message. This lets the 
client know which is the highest RFB protocol version number supported by the server. The 
client then replies with a similar message giving the version number of the protocol which 
should actually be used [...]

@catenacyber
Copy link
Contributor

I see this in private pcaps :-/

Is it a mismatch between TCP server and RFB server ?

@satta
Copy link
Contributor Author

satta commented Jun 30, 2023

I see this in private pcaps :-/

Is it a mismatch between TCP server and RFB server ?

Don't think so. All the pcaps I've seen agree with the spec. Could it be that the pcap you're seeing this in might have a collection artifact of some sort? Can you confirm the session is valid? Can Wireshark dissect the communication correctly?

@catenacyber
Copy link
Contributor

Wireshark dissects correctly but says Server protocol version for the first one which comes from the TCP client.

@satta satta mentioned this pull request Jul 13, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants