Skip to content

[13.x] Validate MAC across all decryption keys#59742

Merged
taylorotwell merged 2 commits intolaravel:13.xfrom
ma32kc:fix-encrypter-mac-validation-timing
Apr 18, 2026
Merged

[13.x] Validate MAC across all decryption keys#59742
taylorotwell merged 2 commits intolaravel:13.xfrom
ma32kc:fix-encrypter-mac-validation-timing

Conversation

@ma32kc
Copy link
Copy Markdown
Contributor

@ma32kc ma32kc commented Apr 17, 2026

This PR addresses #59363.

When multiple decryption keys are configured, Encrypter::decrypt() currently stops MAC validation as soon as a matching key is found. That means the amount of work depends on where the matching key appears in the rotation list.

This change makes MAC validation run across all configured keys, remembers the first matching key, and then decrypts only once with that key.

The behavior stays the same, but the implementation no longer short-circuits based on key position.

This is also intentionally narrower than #59366. It only changes Encrypter, keeps the fix focused on #59363, and avoids the extra array-building logic from that earlier attempt.

A regression test was added to cover decryption when multiple previous keys are configured.

@ma32kc
Copy link
Copy Markdown
Contributor Author

ma32kc commented Apr 17, 2026

NOT AI!!!

@taylorotwell taylorotwell merged commit e20a330 into laravel:13.x Apr 18, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants