zowe-cli: [Secrets SDK] Running firewall check fixes keystore error
Describe the bug
At work, when users first install v3.1.1 of ZE, they will get the following error when filtering a data set after entering their credentials:
The workaround is to run a powershell script that on its own does nothing, but just searches the firewall for a rule that doesn’t exist. This somehow refreshes something and causes the error to go away, allowing Windows credential manager to store the credentials.
Get-NetFirewallRule |
Where-Object -Property DisplayName -eq 'somethingrandom' |
Disable-NetFirewallRule
To clarify, we use autoStore: true and vscode://settings/zowe.security.secureCredentialsEnabled as true.
It could very well be an org-specific rule we have somewhere that causes this issue and allows this fix to work, but no one knows why.
The workaround was found by complete accident. We already had a similar script that used to disable a firewall rule that allowed IBM Debug Tools to get through our firewall. Even though this rule no longer exists on our systems, someone thought to try it in the hopes it would work anyway and somehow it did…
Expected and actual results
I expect this error to not appear and us to not require every user to run this script the first time they use ZE v3.x to get their credentials to be stored.
Describe your environment
- Zowe CLI version installed (run command
zowe --version): N/A - users don’t have Zowe CLI installed - Zowe Explorer versions: v3.x
- Occurs on both Win10 & Win11
Additional context
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 28 (27 by maintainers)
I can already hear everyone shouting and screaming “please no not another one!”
… but I wonder if the zowe config file would actually need to contain the setting for the cred store option 💀
My reasoning for this, is this type of config would be typically set by a company rather than by individual user. So having it in the config file that is distributed by the company already is much easier than either telling users to set that setting when installing vscode.
Thanks for confirming. The username test should rule out whether the issue is coming from the vault or ZE.
Yeah, that’s fine - we won’t use the credentials until you go to make a search on the profile or interact w/ the virtual filesystem
Thanks for verifying. Looking over the Secrets SDK code, it seems that either
CredReadWorCredWriteWis failing, but the error code does not match to a “formal error message” when the error handling is performed. Regardless, I’m still concerned that the API could be misbehaving at your company site, and am wondering if its related to the behavior you’re seeing with the Intune Portal environment.I plan to send a debug build of Zowe Explorer (in the next day or so) with more diagnostic information for the Secrets SDK. If you don’t mind, please test the same steps again once I’ve attached the debug build and provide a screenshot of the new Secrets SDK error that you encounter.
Quick question: Did you run the Zowe CLI commands through the Intune Portal or locally through PowerShell?
Sorry for the delay @JWaters02! Thanks again for reporting this issue and providing the interesting PowerShell workaround (
Disable-NetFirewallRule). This is definitely unusual behavior.Here’s how the Secrets SDK interacts with the Windows Credential Manager:
CredWriteWwith the flagsCRED_TYPE_GENERICandCRED_PERSIST_ENTERPRISE.CredReadWlooking forCRED_TYPE_GENERICcredentials.My main theory revolves around the use of the
CRED_PERSIST_ENTERPRISEflag when writing credentials. While this allows credentials to persist across logins and machines (associating the credentials with the networked user), it can sometimes involve more complex system interactions or have slightly different propagation timings compared to other persistence levels. It’s possible that in your specific environment, the credential isn’t immediately available for reading after being written with this flag, and the PowerShell command interaction somehow forces a system state refresh that makes it accessible.Can you please try these two tests and report back with results? I can provide a build with more verbose logging or a different persistence flag, but would like to rule out some possibilities first.
Test 1 (more straightforward): Instead of running the
Disable-NetFirewallRulecommand, try to run a simple command such asStart-Sleep -Seconds 5to see if it has the same effect. This solely rules out whether the issue is attributed to a delay in credential propagation.Test 2: Note: this test is a bit destructive as it deletes existing Zowe secure credentials from your Windows account.
cmdkey /list:Zowe/secure_config_props.Zowe/secure_config_props, runcmdkey /delete:Zowe/secure_config_propsto delete it from the credential store.<profile>” is shown from Zowe Explorer, go back to your command prompt and entercmdkey /list:Zowe/secure_config_propsZowe/secure_config_propscredential is listed after running the lastcmdkeycommand.