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

memcache.go has possible hash collisions, leading to wrong values saved/retrieved from cache #168

Open
dbardbar opened this issue Oct 12, 2022 · 0 comments

Comments

@dbardbar
Copy link
Contributor

In memcache.go there's TemplatesShard which has a map with uint32 as key.
The key is computed as a hash of the sender's IP and template ID.

It is possible to have multiple senders or multiple template IDs that will result in in the same hash.
In such a case, they will overwrite each-other in the cache, leading to incorrect parsing of the traffic from the other sender.
In the best case scenario, the incorrectly parsed packets would cause some error and the packet would be ignored. In the worst case scenario, the parsing would succeed, but would result in garbage values.

I do not understand the motivation of making this map with a key of uint32 and going through the trouble of manually computing the hash. If the code would use a map with a struct holding the IP and ID, then the code would be much simpler and the problem described here would never happen.

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

No branches or pull requests

1 participant