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:

Image

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)

Most upvoted comments

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.

Can I just put any random username in (even if it’s not valid creds on mainframe side) and check logs?

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 CredReadW or CredWriteW is 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:

  • When setting credentials, we use CredWriteW with the flags CRED_TYPE_GENERIC and CRED_PERSIST_ENTERPRISE.
  • When reading credentials, we use CredReadW looking for CRED_TYPE_GENERIC credentials.

My main theory revolves around the use of the CRED_PERSIST_ENTERPRISE flag 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-NetFirewallRule command, try to run a simple command such as Start-Sleep -Seconds 5 to 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.

  • In a local command prompt, run cmdkey /list:Zowe/secure_config_props.
  • If a credential is found with the target Zowe/secure_config_props, run cmdkey /delete:Zowe/secure_config_props to delete it from the credential store.
  • Open Zowe Explorer and right click on a profile -> select “Manage Profile” -> “Add/Update Credentials”.
  • Enter in your username and password. Once the notification “Credentials were successfully updated for <profile>” is shown from Zowe Explorer, go back to your command prompt and enter cmdkey /list:Zowe/secure_config_props
  • Please let me know whether the Zowe/secure_config_props credential is listed after running the last cmdkey command.