Facing CSRF issue While form submission

45 Views Asked by At

Hi I'm facing CSRF issue for my application while submitting form. I'm using struts 1 and i don't want to update struts, can anyone help me how to implement CSRF protection. I tried tokens but not solving the issue.

I tried tokens.

1

There are 1 best solutions below

2
SHresTho12 On

Some methods on top of my head I can think of

Use Synchronized Tokens: When generating tokens, ensure they are synchronized with the session and invalidated after a single use. This ensures that each request can use only one valid token.

Token Placement: Ensure that the token is placed in both the form as a hidden field and in the session. When a request is submitted, you can compare the token in the form with the one in the session

Double-Submit Cookies: If possible, use double-submit cookies in addition to tokens. This involves sending the token in both a cookie and a request parameter. The server can then compare both values to validate the request.