mirror of
https://github.com/keycloak/keycloak.git
synced 2026-10-23 19:29:23 +03:00
Move tx_code and originating session validation before the singleUseStore.putIfAbsent() call in PreAuthorizedCodeGrantType. Previously, a wrong or missing tx_code would permanently burn the pre-authorized code with no rollback, allowing an attacker who only has the QR code to invalidate the credential offer without knowing the PIN. Now the code is consumed only after all validations pass. Also hardens the MessageDigest.isEqual comparison to use explicit UTF-8 encoding instead of the platform-dependent default charset. Closes #49787 AI Disclosure: This commit was authored with the assistance of an AI coding tool. All changes were reviewed and approved by the committer. Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>