#community-help

Validating Client Side Search Adapter Effectiveness and Tips

TLDR Keith asked Jason about enumeration attacks and IP blocking. Jason suggested using Cloudflare for IP-blocking, using limited API keys, and shared a method to proxy through Cloudflare to Typesense. Keith also shared a resource about Cloudflare workers.

Powered by Struct AI
13
19mo
Solved
Join the chat
Feb 04, 2022 (19 months ago)
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
04:42 PM
Hey Jason weird question, we’re trying to validate how effective the client side search adapter is against enumeration attacks; question is it possible to white list domains/ip?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:49 PM
Keith For enumeration attacks specifically, you can use the limit_hits search parameter embedded in a scoped search API Key to limit the total number of records that can be fetched with that API key
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
04:50 PM
Is that done when the API key is created or client side?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:50 PM
When the API key is created
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
04:51 PM
Interesting, okay, we’ll give that a test on the new cluster. Thanks!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:51 PM
We don't track IPs / domains, so we don't have a way to block based on that. If you need IP-based blocking, I'd recommend setting up something like Cloudflare (free) in front of your Typesense endpoints and use the Cloudflare domains from the client-side.

So for eg:

ts1.yourdomain.com -> xxx-1.a1.typesense.net
ts2.yourdomain.com -> xxx-2.a1.typesense.net
ts3.yourdomain.com -> xxx-3.a1.typesense.net

Where tsx.yourdomain.com is hosted on Cloudflare and set to proxy to Typesense
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
04:52 PM
Yea that’s actually what we’re talking about right this second haha
04:52
Keith
04:52 PM
That’s a great example though
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:53 PM
And as a bonus you get DDOS protection!
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
04:55 PM
YEa exactly
04:56
Keith
04:56 PM
We have Cloudflare Business so we can even go further than that and use Workers to hide the API key
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:58 PM
Very interesting! Thank you for sharing. I'll start recommending this approach to others in the future.