NIFI-8230 Removed default Sensitive Properties Key#4857
NIFI-8230 Removed default Sensitive Properties Key#4857exceptionfactory wants to merge 7 commits intoapache:mainfrom
Conversation
...rk/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java
Outdated
Show resolved
Hide resolved
...rk/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java
Outdated
Show resolved
Hide resolved
|
Great job, @exceptionfactory ! |
Thanks for the helpful feedback @CefBoud! I made changes and pushed an update to address your comments. |
|
Excellent work, @exceptionfactory. Nicely refactored! |
|
I'll test this out |
|
Sorry just came back to this. I tested it out and found that it works as described. The issue I foresee is that we will likely have people asking questions on the email distro when they try to use their old configurations when this is put in place. Currently the error message directs the user as follows: I followed the steps given in that section and was able to update my configuration and get the flow working with a new password. I also provided empty configuration and a key was generated for me, and I verified the new key was then used to encrypt sensitive values. As far as backwards compatibility, this could be a hurdle for users who are upgrading. I wouldn't be surprised if the majority of users haven't used the encrypt-config.sh tool at all before. We might need to get some others to chime in to decide if this is a reasonable change to make for a minor version. That being said, I do think it's an important change to be making. Whilst I'm also raising a question about backwards compatibility, I'm at the same time wondering if we can go a step further and change the default sensitive properties algorithm if nothing in the flow is already encrypted and the algorithm property is empty (though I believe it's already populated by default)? Is it possible we could start using PBEWITHSHA256AND256BITAES-CBC-BC? I'll be honest, I'm not actually sure of how significant of a security benefit this might be or if it will have a negative performance impact, but removing the use of MD5 sounds like a good idea to me. Also, not sure if this algorithm is available in all regions so that would be something to check. The encrypt-config.sh tool appears to allow specifying an old and new flow encryption algorithm. Just a thought. |
Thanks for the testing and detailed feedback @thenatog! There are certainly tradeoffs when it comes to to backwards compatibility, but running with an empty sensitive properties key is a serious security risk, so it is important to move in this direction. Perhaps work could be done to make the encrypt-config.sh toolkit easier to use in this case, but that could be considered in a separate task if necessary. It would be worth noting in migration guidance that using the toolkit is necessary. Regarding the default algorithm, we should move away from all of the existing PBE values. NIFI-8246 addresses this issue explicitly and I am planning to submit a PR for that issue as soon as this PR is merged. The internal default sensitive properties key does not meet the length requirements of the secure key derivation functions, but once this is merged, changing the default sensitive properties algorithm should be straightforward. |
| final String message = String.format("Sensitive Properties Key [%s] not found: %s", NiFiProperties.SENSITIVE_PROPS_KEY, MIGRATION_INSTRUCTIONS); | ||
| throw new SensitivePropertyProtectionException(message); | ||
| } | ||
| setSensitivePropertiesKey(); |
There was a problem hiding this comment.
If we are setting up a cluster, I assume that this call is going to generate a different random key on each node, which I think would mean that when a node receives a fingerprint or flow from the cluster coordinator, there would be an issue since they don't have the same key.
Maybe it makes sense to also check if one of the clustering properties is set, and make it part of the error scenario above so that in a cluster, the user is required to enter a sensitive props key?
@markap14 do you have any thoughts?
There was a problem hiding this comment.
Thanks for the feedback @bbende! Calling NiFiProperties.isClustered() is a simple enough check in addition to checking whether a Flow Configuration already exists. Setting a sensitive properties key should be required for a clustered configuration, and that could be called out separately prior to checking for an existing Flow Configuration.
I will add the check and associated exception scenario.
88813e7 to
9d04b03
Compare
|
Just to summarize the latest changes, after some additional discussion with @markap14, he suggested that implementing a simplified command for setting the Sensitive Properties Key to make the migration path easier for current users with blank keys. The most recent commit includes an update to
The script passes the new key to the command class, which reads the current key from This approach required refactoring the PropertyEncryptor classes to a separate module named With these changes, the Admin Guide now includes a new section describing the |
…eneration - Retained legacy default Sensitive Properties Key in ConfigEncryptionTool to support migration
- Refactored PropertyEncryptor classes to nifi-property-encryptor - Added nifi-flow-encryptor - Refactored ConfigEncryptionTool to use FlowEncryptor for supporting AEAD algorithms - Added Admin Guide section Updating the Sensitive Properties Key
9d04b03 to
eacde34
Compare
|
@exceptionfactory I gave this a try. Loaded up a flow created on So then I tried to run the command update the key: So it appears there's an issue of some sort in the way that the arguments are passed in the |
…s-key - Changed minimum required key length to 12 aligning with StandardPropertySecretKeyProvider
Thanks for the feedback @markap14! I pushed an update to I also adjusted the minimum required key length to 12, aligning with the existing length requirement of 12 in |
|
@markap14 Do you have any additional feedback, or do the latest changes look good? Thanks! |
|
All looks good to me at this point @exceptionfactory. Thanks! I rebased against |
…eneration - Retained legacy default Sensitive Properties Key in ConfigEncryptionTool to support migration - Streamlined default file path and moved key generation conditional - Refactored with getDefaultProperties() - Cleared System Property in ConfigEncryptionToolTest - Added checking and error handling for clustered status - Added set-sensitive-properties-key command - Refactored PropertyEncryptor classes to nifi-property-encryptor - Added nifi-flow-encryptor - Refactored ConfigEncryptionTool to use FlowEncryptor for supporting AEAD algorithms - Added Admin Guide section Updating the Sensitive Properties Key This closes apache#4857. Signed-off-by: Mark Payne <markap14@hotmail.com>
Description of PR
NIFI-8230 Removes the default internal Sensitive Properties Key which provided fallback support when the value of
nifi.sensitive.props.keywas empty. NiFi used the default internal value on new installations where the administrator had not configured a sensitive properties key.To maintain ease of use, this PR includes an update to
NiFiPropertiesLoader.get()that checks for a null or blank sensitive properties key and generates a random key when the flow configuration file is not found. The random key generation process usesjava.util.SecureRandomto generate an array of 24 bytes, which is then encoded using Base64 without padding to produce a 32 character string. Using Base64 without padding avoids introducing unsupported property characters while also providing a reasonable range of potential random characters.This approach supports generating a random key for installations of NiFi while avoiding random generation when upgrading. Existing flow configurations may already contain sensitive properties encrypted with the default internal key. For upgrades of existing installations that do not have a sensitive properties key, NiFi logs and error and throws an exception referencing the Administration Guide section on Migrating a Flow with Sensitive Properties. To support migration, the
ConfigEncryptionToolretains the default internal value for reading existing flows.In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
main)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.