TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.57k stars 1.07k forks source link

[TT-1988] - Security: Policy Controlled API Key Creates Colliding Murmur32 Additional Key In Redis #3044

Open calabdean opened 4 years ago

calabdean commented 4 years ago

v2.9.1 and v2.9.4

Describe the bug The bug occurs when using security policies to restrict APIs. I was avoiding the hash collision by using RSA256 and noticed that the keys were still colliding when using this hash. upon further investigation, I found that once a successful call was made to Tyk using the key, a second key (murmur32 by the looks of it) is created in redis and opens my API up to similar but not exactly correct keys, this issue is documented in https://github.com/TykTechnologies/tyk/issues/2516.

Reproduction steps Steps to reproduce the behavior:

Actual behavior A new key (suspect murmur32 somehow) is created in redis, and API keys that did not match the key created were being allowed access to the API. The behaviour seems similar to https://github.com/TykTechnologies/tyk/issues/2516 in the resulting behaviour, but I'm unsure how the key is being added into redis.

Expected behavior I expected that there should be no collision using a hash algorithm other than murmur32, as I have seen it documented that this collides easily. I expect that the API should be restricted only to the exact key created

Screenshots/Video NA

Logs (debug mode or log file): see attached file [Uploading tyk-policy-bug-debug.log…]

Configuration (tyk config file): see attached file (top section covers env, lower section describes what i saw) tyk-bug.txt

Additional context This problem doesn't occur when defining the key restrictions using the access_rights field in the key creation, only when using policies

calabdean commented 4 years ago

tyk-policy-bug-debug.log debug log didn't originally upload

mcandre commented 4 years ago

Does this happen with too-short keys as well, e.g. 3 that have exactly one matching real key in use?