JAX-RS is designed to create a REST API, which should be stateless. The cross-reference request routine is NOT a problem when using stateless applications.
How Cross Site Request Forgery works, someone can trick you into clicking a link or opening a link in your browser that will direct you to the site where you are logged in, for example, to some online forum. Since you are already logged in on this forum, an attacker can create a URL, let's say something like this: someforum.com/deletethread?id=23454
This forum program, poorly designed, will recognize you based on the session cookie and confirm that you have the option to delete the stream and actually delete this stream.
That's because the program authenticated you based on the cookie of the session (even based on the cookie "remember me")
There is no cookie in the RESTful API, state is not supported between requests, so there is no need to protect against session hijacking.
As you usually authenticate with the RESTFul api, you send some extra headers. If someone tricks you into clicking on a URL pointing to a soothing API, the browser is not going to send additional headers, so there is no risk.
In short, if the REST API is designed the way it should be - stateless, then there is no risk of faking cross-sites and there is no need to protect CSRF.
source share