-
Notifications
You must be signed in to change notification settings - Fork 3k
Quarkus REST CSRF: inform users in DEV mode when token size changed that previously generated tokens are invalid #51433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quarkus REST CSRF: inform users in DEV mode when token size changed that previously generated tokens are invalid #51433
Conversation
michalvavrik
commented
Dec 5, 2025
- Closes CSRF custom size of CSRF token doesn't work #51334
38a9abe to
6ba5ee7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
which doesn't seem related. |
|
Hi Michal, thanks for taking care of it, appreciated, so it is a dev mode situation. The log message is useful, my only proposal is not to create devmode specific check against the previous cookie size, but warn the cookies sizes do not match and only log the extra advice to The reason I suggest is that that any property that impacts the cookie presentation, when changed in devmode, will lead to 400 in this case - signature key is another case, so if we write a size specific processing then it would be only natural to expect also keep the previous signature key value for devmode to suggest why the signature verification might've failed... And then we have quarkus-oidc, form authentication with similar situations... Something like This is much less precise, I agree, but it should give a good enough hint. By the way, I think having a static int solution might not really work if you change both a cookie name and size in devmode at the same time before saving. So let's you have |
That is not quite correct. When signature key changes and you use HTTP method that doesn't require token, like GET when Quarkus serves the form with token, a new cookie is generated. Therefore you do not get 400. Idea that users go directly to paths/methods that require cookie after DEV more restart, that doesn't fit form flow, when you go to a page, fill form and click to submit. While if the token size changes, it will always lead to 400, thus we need to inform this is the token size consequence.
OK, I'll tell you directly personally I think my version is more useful to users, but it is really unimportant matter. I'll do it.
If you change the cookie name, you have no related issue. I think it wouldn't be confusing because that log message I added:
but I think it is a good point, I should have improved it with remembering cookie name. Anyway, it doesn't matter anymore as I'll update this PR with your suggestion. |
|
On the other hand, I like the idea to have logging in non-dev mode as you suggest. I think there are not many normal situations that this should happen, so it will be useful. |
6ba5ee7 to
b02c437
Compare
b02c437 to
48f96e9
Compare
|
@sberyozkin so I pushed slightly different version because there already was debug logging, so I just made sure that users can see it in the DEV mode and add your suggestion about deleting cache. I think it should be enough and it solves the issue. Let me know if you want some tweaks. |
I suppose users don't need to know about previous token size. It was more about knowing that issues are unintentional. More I think about it, users are unlikely to test bad cookies in DEV mode, so it is good. |
Status for workflow
|
Status for workflow
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agreed your original message was more useful, my concern was about the necessity of having to introduce a dedicated static property to handle this specific dev-mode only situation, that would more or less require us to keep adding more such properties (signature key).
Sorry, the token name update case was not a good example, with respect to the original code
Thanks for your help
