Skip to content

Commit 079bb45

Browse files
committed
Add Encryptors Preparation Steps
Issue gh-8980
1 parent 9195521 commit 079bb45

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: docs/modules/ROOT/pages/migration.adoc

+28
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,34 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
26052605
----
26062606
====
26072607

2608+
=== Stop using `Encryptors.queryableText`
2609+
2610+
`Encryptors.queryableText(CharSequence,CharSequence)` is unsafe since https://tanzu.vmware.com/security/cve-2020-5408[the same input data will produce the same output].
2611+
It was deprecated and will be removed in 6.0; Spring Security no longer supports encrypting data in this way.
2612+
2613+
To upgrade, you will either need to re-encrypt with a supported mechanism or store it decrypted.
2614+
2615+
Consider the following pseudocode for reading each encrypted entry from a table, decrypting it, and then re-encrypting it using a supported mechanism:
2616+
2617+
====
2618+
.Java
2619+
[source,java,role="primary"]
2620+
----
2621+
TextEncryptor deprecated = Encryptors.queryableText(password, salt);
2622+
BytesEncryptor aes = new AesBytesEncryptor(password, salt, KeyGenerators.secureRandom(12), CipherAlgorithm.GCM);
2623+
TextEncryptor supported = new HexEncodingTextEncryptor(aes);
2624+
for (MyEntry entry : entries) {
2625+
String value = deprecated.decrypt(entry.getEncryptedValue()); <1>
2626+
entry.setEncryptedValue(supported.encrypt(value)); <2>
2627+
entryService.save(entry)
2628+
}
2629+
----
2630+
====
2631+
<1> - The above uses the deprecated `queryableText` to convert the value to plaintext.
2632+
<2> - Then, the value is re-encrypted with a supported Spring Security mechanism.
2633+
2634+
Please see the reference manual for more information on what xref:features/integrations/cryptography.adoc[encryption mechanisms Spring Security supports].
2635+
26082636
== Reactive
26092637

26102638
=== Use `AuthorizationManager` for Method Security

0 commit comments

Comments
 (0)