enhancement
major
major
major
#29788
Configuration: the error for an undecodable encrypted property echoes the value (e.g. a plain-text password) into the log
Scenario
A password property annotated with @Encrypted (e.g. <login user="..." password="%API_PASSWD%"/> of an OpenAPI server secret, or a password property of a service configuration) is configured with a plain-text value, without the unencrypted: prefix, e.g. through an alias set from an environment variable.
The application fails to start with:
ConfigurationException: "Unable to decode '<the plain-text password>' as value for property 'password'. For temporary configuration of unencoded values use 'unencrypted:' as prefix."
The secret itself ends up in clear text in the startup log, in the console of the build/deployment job and in every place the exception is forwarded to.
Analysed in tl-engine 8.0.0-alpha9 / master.
Analysis
EncodingConfigurationValueProvider.handleUndecryptableValue builds the message with the complete encodedValue. Since the value failed to decrypt, it is in practice almost always a plain-text secret.
In addition, ConfigurationReader wraps every invalid property value into its own message Invalid value '<value>' for property ... (attribute and element form), so the value appears a second time.
The same applies to XMLProperties: an <entry ... encrypt="true"/> whose value cannot be decrypted is reported as Unable to decode '<value>' as value for key ....
The cause exceptions (IllegalArgumentException: Text already decrypted? wrapping EOFException: Stream size too small. from SymmetricEncryption.decrypt) do not contain the value.
Expected
The message names the property, but never the value:
Unable to decode the value of property 'password' (not encrypted). For temporary configuration of unencoded values use 'unencrypted:' as prefix.
Lösung
- EncodingConfigurationValueProvider meldet einen nicht entschlüsselbaren Wert über den I18N-Schlüssel ERROR_UNDECODABLE_ENCRYPTED_VALUE__PROPERTY_PREFIX, der nur den Property-Namen und den Hinweis auf das Präfix unencrypted: enthält. Weder die Meldung noch ConfigurationException.getPropertyValue() tragen den Wert.
- PropertyDescriptor.isEncrypted() ist öffentlich. ConfigurationReader lässt in seiner Meldung Invalid value ... for property ... den Wert einer verschlüsselten Property weg (Attribut- und Element-Form).
- XMLProperties meldet einen nicht entschlüsselbaren Eintrag mit Schlüssel und Position in der Datei, ohne den Wert. XMLProperties.ENCRYPT_ATTR ist öffentlich wie die übrigen Attributnamen.
- Tests: TestTypedConfiguration liest einen Klartext-Wert in eine @Encrypted-Property (als Attribut und als Element), TestXMLPropertiesEncryption lädt einen Klartext-Wert in einen Eintrag mit encrypt="true"; beide prüfen, dass die Fehlermeldungen den Wert nicht enthalten.
Nicht in diesem Ticket
Die Konfigurationsverschlüsselung (AES/OFB/NoPadding) hat keine Integritätsprüfung. Der Fehler tritt daher nur auf, wenn der Base64-dekodierte Klartext kürzer als der 16-Byte-IV ist. Ein längerer Klartext-Wert wird stillschweigend zu einem unsinnigen Wert "entschlüsselt"; die Anwendung scheitert dann erst später, z.B. mit einem fehlgeschlagenen Login. Siehe #29849.