I have a question about how to develop my web application security. Assuming that all the javascript code is public and that anyone can make any AJAX call directly, with parameters that seem convenient, then any call that directly modify the status of the database is highly dangerous.
That is, calls as "changePoints" or "updateUserState" allow a malicious user to break the logic of, for example, a game and obtain unlimited money or points.
My intuitive solution to this problem is to desing calls that communicate client with server so through its parameters could not be possible breaking the app logic. In the example of a game, a call like "buySomething" would be safe because the server would be responsible for adding that "something" and subtract the money it costs. Two calls "addSomething" "changeMoney" could accomplish the same task but would be unsafe, for obvious reasons.
My doubts arise from the conclusions that this reasoning leads me: The model part of MVC pattern in client side seems so dangerous, especially if we apply "active record" because AJAX calls have a direct correlation to the database server. Also, my intuitive solution generates a tendency for much of the application logic to be developed on the server side, which can become tedious.
Is there something I'm missing? Are there smarter solutions? Does using models and active record in client side is just insecure?
Thank you for your attention and help.