While implementing Azure OAuth flow I have used state
parameter, Azure docs says about state
param:
A value included in the request that is also returned in the token response. It can be a string of any content that you wish. A randomly generated unique value is typically used for preventing cross-site request forgery attacks. The value can also encode information about the user's state in the app before the authentication request occurred. For instance, it could encode the page or view they were on.
So, My web application is already generating such unique string and that is a CSRf token (UUID). So I used the same CSRF token (UUID) and passed to state
parameter. When response comes from OAuth provider I have crossed with the CSRF token from session.
But, recently security team in my company said CSRF token should not used in this way. According to them
A CRSF token is a secret that should not be shared. Using it as a state value is therefore improper use of the CSRF token and introduces a (small) security risk.
But, if I look closely at other normal (non-Oauth) requests then the same CSRF token is passed in request header, so I asked them that if CSRF token is secret then why it is being passed in request header that could also "introduces a (small) security risk." the answer I received is not convincing. Hence asking this question on this large forum:
Can we use CSRF token as a value for state
parameter in OAuth request? Is there any security risk involve if we use CSRF token as state
parameter?