corelight / pycommunityid

A Python implementation of the Community ID flow hashing standard
BSD 3-Clause "New" or "Revised" License
23 stars 10 forks source link

FlowTupleError port invalid for specific ports #3

Closed mintos5 closed 3 years ago

mintos5 commented 3 years ago

Hi, I started to experiment with community ID and pycommunityid and I think that I found a bug in function in_nbo(): https://github.com/corelight/pycommunityid/blob/b4467350446dde632eef59004a6b4e49cc55a85f/communityid/algo.py#L194-L213

You can test it with your sample application: $ community-id tcp 10.0.0.1 10.0.0.2 10 11569

Number 11569 in hex is 0x2D31 and that is '-1' in ASCII. I think the problem is with this line in function is_port(val): https://github.com/corelight/pycommunityid/blob/b4467350446dde632eef59004a6b4e49cc55a85f/communityid/algo.py#L249

I hope somebody will check this bug and will found a solution.

ckreibich commented 3 years ago

Thanks for the report! I'll take a look.

ckreibich commented 3 years ago

@mintos5 I love this find, thank you. Are you able to try out my fix in the fix-type-confusion branch? I'm hoping it'll resolve it.