1

I make a web service and I'm going to use a React. A data for the service will be fetch from my API.

But there is a simple way to find out which endpoints I'm using, and what data I'm sending. This knowledge gives a lot options to make bots for my service.

Is there any option to prevent this?

I know, I can require a signing all requests, but it's also easy to get to know.

0

2 Answers 2

1

This cannot be done. Whatever is done in client-side JavaScript, can be reverse-engineered and simulated.

Efforts should be focused on preventing API from being abused, i.e. throttling or blacklisting clients based on their activity or available information (user agent, suspicious request, generated traffic). If the use of API allows captcha, suspicious clients can be asked for proving their humaneness.

There are half-measures that can be applied to client side application and make it less advantageous for abuse (and also for development).

Prevent unauthorized access to unminified/unobfuscated JS AND source maps. There may be a need to authorize them on per user basis. This will make debugging and bug reporting more difficult

Hard-code parts that are involved in request signing to browser APIs, e.g.:

apiKey = hash(NOT_SO_SECRET_KEY + document.querySelector('.varyingBlock').innerHTML)

This requires bots to emulate browser environment and makes their work much less efficient. This also affects the design of the application in negative way. Obviously, there will be additional difficulties with SSR and it won't translate to native platforms easily.

Sign up to request clarification or add additional context in comments.

Comments

1

here two basic preventive measures that you can use.

  1. Captcha
    Use a captcha service like recaptcha. so that user can use your website only after passing the captcha test. Its highly difficult for bots to pass the captchas.

  2. Rate Limit Api usage.
    Add rate limiting to your api. so that a logged in user can only make 100 requests in 10 minutes, the numbers will depend on you use case

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.