Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

CSRF token is only validated if there are @FormParams #79

Open
mvcbot opened this issue Oct 23, 2015 · 1 comment
Open

CSRF token is only validated if there are @FormParams #79

mvcbot opened this issue Oct 23, 2015 · 1 comment
Labels

Comments

@mvcbot
Copy link

mvcbot commented Oct 23, 2015

Original issue OZARK-63 created by Christian Kaltepoth:

The CSRF page token validation works fine in this case:

@Controller
@Path("/foobar")
public class TweetController {

  @POST
  @CsrfValid
  public String post( @FormParam("text") String text ) {
    System.out.println("CSRF page token valid!");
    return ....;
  }

}
{code}

But if I remove the controller method parameter, the check seems to get skipped and the controller method is always executed. Even if the page token is missing.

{code:java}
@Controller
@Path("/foobar")
public class TweetController {

  @POST
  @CsrfValid
  public String post( /** empty **/ ) {
    System.out.println("CSRF page token valid!");
    return ....;
  }

}
@mvcbot
Copy link
Author

mvcbot commented Oct 23, 2015

Comment by Santiago Pericas-Geertsen:

This is because the verification is done in a ReaderInterceptor. If there is no entity to read, the verification is skipped. This is a bit of an edge case in that regard, but perhaps we need to address it too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant