ir-benspunkt opened a new issue, #9423:
URL: https://github.com/apache/hop/issues/9423

   ### Apache Hop version?
   
   2.19 and 2.20
   
   ### Java version?
   
   Eclipse Adoptium jdk-21.0.11.10-hotspot
   
   ### Operating system
   
   Windows
   
   ### What happened?
   
   Hi Apache Hop team,
   
   While upgrading from Apache Hop 2.18.1 to 2.19 and later 2.20, I noticed a 
change in how the AES2 password encoder handles externally configured Windows 
environment variables.
   
   I'm not entirely sure whether this is an unintended regression or a change 
in how password encoders are configured, but I wanted to share my findings.
   
   We currently configure AES2 using the following Windows environment 
variables:
   
   ```text
   HOP_PASSWORD_ENCODER_PLUGIN=AES2
   HOP_AES_ENCODER_KEY=<secret-key>
   ```
   
   This worked as expected up to Apache Hop 2.18.1.
   
   Starting with version 2.19, however, I've observed the following behavior:
   
   - `hop-encrypt.bat` still correctly generates AES2-encrypted values.
   - The Hop GUI's **Encode value** function generates values with the default 
`Encrypted` prefix instead of `AES2`.
   - Existing AES2-encrypted passwords no longer seem to be decrypted correctly 
when used in database connection password fields.
   - **When I explicitly set `HOP_PASSWORD_ENCODER_PLUGIN=AES2` inside the Hop 
environment, everything works as expected again.**
   
   It seems that the AES2 encoder itself is working correctly, but the 
externally configured encoder setting might not be picked up by the Hop GUI or 
runtime.
   
   ## Steps to Reproduce
   
   ### 1. Configure AES2 using Windows environment variables
   
   Set the following variables at the operating system level:
   
   ```text
   HOP_PASSWORD_ENCODER_PLUGIN=AES2
   HOP_AES_ENCODER_KEY=<secret-key>
   ```
   
   Leave these variables undefined in the Hop project and Hop environment.
   
   Start Apache Hop GUI.
   
   ### 2. Test encryption using the CLI
   
   Run:
   
   ```bat
   hop-encrypt.bat -hop MyPassword222
   ```
   
   **Result:**
   
   The command generates an AES2-encrypted value as expected:
   
   ```text
   AES2 <encrypted-value>
   ```
   
   So the AES2 encoder seems to work correctly when used through the command 
line.
   
   ### 3. Test encryption in the Hop GUI
   
   1. Open Apache Hop GUI.
   2. Activate a Hop environment.
   3. Open the environment variable configuration.
   4. Create or edit a variable containing a password.
   5. Click **Encode value**.
   
   **Actual result:**
   
   The GUI generates a value using the default password encoder:
   
   ```text
   Encrypted <encoded-value>
   ```
   
   **Expected result:**
   
   Since AES2 is configured through the Windows environment variables, I would 
expect the GUI to generate:
   
   ```text
   AES2 <encrypted-value>
   ```
   
   ### 4. Test AES2 decryption at runtime
   
   1. Store an existing AES2-encrypted password in a Hop environment variable.
   2. Reference this variable in a database connection password field.
   3. Execute a pipeline or workflow using that connection.
   
   **Actual result:**
   
   The AES2-encrypted value does not appear to be decrypted.
   
   Instead, it looks like the value, including the `AES2` prefix, is passed to 
the connection unchanged, resulting in authentication failure.
   
   I also tried using the **Hop Password Variable Resolver**, but unfortunately 
this did not change the behavior.
   
   **Expected result:**
   
   The AES2-encrypted password should be decrypted using the externally 
configured AES2 key, as it was in Apache Hop 2.18.1.
   
   ## Workaround / Additional Findings
   
   After some additional testing, I found a workaround.
   
   If I explicitly define the following variable **inside the Hop 
environment**, AES2 works correctly again:
   
   ```text
   HOP_PASSWORD_ENCODER_PLUGIN=AES2
   ```
   
   With this setting, both AES2 encryption and decryption work as expected.
   
   So it seems that the issue is specifically related to how the encoder 
configuration is picked up from the external Windows environment.
   
   While this workaround is helpful, we would prefer to keep the encoder 
configuration external, as we did in previous versions.
   
   This allows us to manage the configuration centrally without having to 
define it separately in each Hop environment.
   
   ## Expected Behavior
   
   Ideally, when `HOP_PASSWORD_ENCODER_PLUGIN=AES2` is defined as a Windows 
environment variable and no project- or environment-specific override exists, 
Apache Hop would continue to use that setting.
   
   This would allow the CLI, Hop GUI, and runtime password handling to behave 
consistently.
   
   ## Environment
   
   | Component | Details |
   |---|---|
   | Apache Hop versions affected | 2.19 and 2.20 |
   | Last working version | 2.18.1 |
   | Operating system | Windows |
   | Java version | Java 21 |
   | Password encoder | AES2 |
   | Configuration source | Windows environment variables |
   | CLI AES2 encryption | Working |
   | GUI AES2 encryption (external config) | Uses default encoder |
   | Runtime AES2 decryption (external config) | Not working as expected |
   | AES2 configured inside Hop environment | Working |
   
   ## Impact
   
   For our setup, we intentionally manage the AES2 configuration through 
Windows environment variables rather than defining it separately in each Hop 
environment.
   
   This worked well up to version 2.18.1.
   
   With versions 2.19 and 2.20, existing pipelines and workflows that rely on 
AES2-encrypted database credentials may fail because the passwords are no 
longer decrypted as expected.
   
   Although defining the encoder inside each Hop environment provides a 
workaround, it would be great if the previous external configuration approach 
could continue to work.
   
   ## Possibly Related Changes
   
   While looking into this, I came across the following issues and changes:
   
   - #7176 – Password encoder configuration per project/environment
   - #7497 – Related implementation
   
   I was wondering whether the behavior might be related to the changes in how 
password encoders are initialized when activating a project or environment.
   
   Perhaps the externally configured `HOP_PASSWORD_ENCODER_PLUGIN` value is no 
longer considered when no environment-specific encoder is defined.
   
   Of course, this is just a guess based on my observations.
   
   
   Thanks for taking a look!
   
   Could you please clarify whether configuring the AES2 password encoder 
through external Windows environment variables is still expected to work in Hop 
2.19 and 2.20?
   
   If so, this might be a regression. If the configuration behavior has 
intentionally changed, I'd appreciate any guidance on the recommended way to 
configure AES2 centrally without defining the encoder in each Hop environment.
   
   Thanks for your help!
   
   
   ### Issue Priority
   
   Priority: 3
   
   ### Issue Component
   
   Component: Hop Config


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to