OBLYTECH Logo
OBLYTECH Logo

ServiceNow External Credential Storage: How Vault Lookups Work

External credential storage lets a ServiceNow instance keep the usernames and passwords used by Discovery, Orchestration and Service Mapping in an external vault. The instance keeps a credential identifier and the credential type. At run time, the MID Server passes the identifier to a resolver, which fetches the real login from the vault.

What stays on the instance

By default, a credential record holds the user name and password for one login. When a credential uses external storage, those two fields are replaced by a single Credential ID field. The MID Server passes that identifier to the resolver to find the matching secret. The credential type, such as SSH, SNMP or Windows, stays on the record, along with any credential affinities.

Both methods can run side by side. The External credential store check box on each record decides the source: ticked means the vault, cleared means the MID Server downloads the credential from the instance.

Each MID Server downloads the instance-stored credential records and keeps them in its own non-external credentials cache. Changing the Enable External Credential Storage property tells it to refresh that cache. For the wider access design, see Discovery security and access design.

How a credential is resolved during a run

The lookup takes place on the MID Server, in four steps.

  1. The MID Server downloads credential objects from the Credentials table. Each external credential carries the identifier that points to its vault entry.
  2. When a Discovery or Orchestration probe or pattern runs, the MID Server passes the credential ID, the target IP address and the credential type to the Credential Resolver Java JAR file.
  3. The resolver works out which vault object is correct and retrieves the user name, password and any other elements.
  4. The MID Server runs the probe with the credential it received.
Component Where it runs What it contributes
Credentials table (discovery_credentials) ServiceNow instance Credential ID and credential type for each record
MID Server Customer environment Downloads credential objects and calls the resolver
Credential Resolver JAR MID Server Maps the ID and type to the correct vault object
Vendor application (optional) Same machine as the MID Server Caches credentials and refreshes them when they change in the vault
Vault Outside the instance Holds the user name, password and other secret values

The CyberArk resolver that ships with the platform keeps a retrieved credential in encrypted process memory for up to several seconds, so one device discovery can request the same credential several times. Credential affinity still applies. After Discovery or Orchestration identifies working credentials for a device, it records the pairing in the Credential Affinity table, dscy_credentials_affinity, and later activities try matching credentials first.

Setting up the feature

Requesting and activating the plugin

The External Credential Storage plugin, plugin ID com.snc.discovery.external_credentials, is requested through the Activate Plugin form on Now Support. That form is reached from Automation Store > Service Catalog, or from All > System Applications > All Available Applications > All, where you select Request plugin. The platform installs the plugin in the maintenance window, and it then appears on the Installed tab of Application Manager.

Building and importing the resolver JAR

Building the resolver needs the agent_admin or admin role. ServiceNow publishes open source template resolvers for HashiCorp and CyberArk, plus a sample Java class that reads values from a properties file. The sample is a template and needs changes for your environment before production use.

Name Direction What it holds
id Passed in The credential identifier configured on the instance
ip Passed in The target system’s IPv4 address
type Passed in The credential type, such as ssh or snmp
mid Passed in The MID Server making the request
user, pswd Returned The user name and password
pkey, passphrase Returned The private key and its passphrase
authprotocol, authkey, privprotocol, privkey Returned Authentication and privacy protocol and key values

Copy the properties file to the MID Server. Then open MID Server > JAR Files, select New, complete the Name, Version, Source and Description fields, attach the JAR and select Submit. Restart the MID Server service. For a custom vault, create a record in Vault Configurations named for the imported JAR.

Configuring the instance and credentials

The plugin must be active, and the Enable External Credential Storage property for Discovery must be enabled. Then open Discovery > Credentials or Orchestration > Credentials, select New, choose a credential type and tick External credential store. The User name and Password fields give way to Credential ID and Credential storage vault. The vault menu offers None, the CyberArk vault or a custom vault record. ServiceNow supports two external vaults at a time: one default CyberArk credential resolver and one custom external resolver built from a JAR file.

With the CyberArk vault selected, a Lookup key menu offers Credential ID, IP Address, FQDN and All of the above. The last choice can slow discovery, because it reads the vault several times for each credential.

The CyberArk integration

With this integration, Orchestration, Discovery and Service Mapping no longer need credentials held on the instance. The MID Server reads the credential identifier, credential type and IP address from the instance, then uses the CyberArk vault to turn those into a usable login.

The integration has these requirements:

  • The External Credential Storage plugin is active, found under System Definitions > Plugins.
  • The MID Server and the CyberArk AIM or API client are installed on the same machine.
  • The integration supports CyberArk Application Access Manager Credential Providers version 12.0.1 and later.
  • One MID Server cannot manage credentials in CyberArk and in a custom vault at the same time.

The resolver can also use reverse DNS to find the FQDN of a target. The supported ServiceNow credential types are GCP, Azure, CIM, JMS, SNMP and SNMPv3, Basic Auth, SSH key pair, SSH private key, VMware, Windows and Applicative Credentials. CyberArk returns the decrypted private key, so an SSH private key credential does not need a passphrase. GCP credentials need a change to the external credential storage JAR first.

How Windows accounts are matched

For Windows credentials, the lookup first tries the credential ID against the Name field in the vault. If nothing matches, it tries the IP address. When one IP address matches more than one credential, such as Windows and Tomcat on the same server, the lookup fails. Setting ext.cred.type_specifier to true in the MID Server config.xml file makes CyberArk return credentials that match both the type and the IP address.

Switching the feature on and off

The on and off switch is the system property com.snc.use_external_credentials, labeled Enable External Credential Storage. It sits in Discovery Definition > Properties and in Orchestration > MID Server Properties, and it is enabled when the plugin is activated.

Changing the property runs a business rule. It switches the Credentials list to an External Storage view, with a Credential ID column, and tells the MID Server to refresh its cache.

Turning the property off sets each external credential to inactive. Turning it back on does not reactivate them, so each record has to be reactivated by hand. When a vault lookup fails, the MID Server log entry begins with Problem with client’s CredentialResolver:, which makes failed lookups easy to search for.

Credential order, aliases and default sources

Order is the sequence in which the platform tries credentials, and a smaller number places a credential higher. If no credential has an order value, the platform tries them in random order until one works. Order pays off in two cases. The first is a large table where a few credentials do most of the work; giving those few low order numbers lets discovery and Orchestration reach them first. The second is a lockout policy: set a low order value on any credential where the target locks out users after three failed login attempts.

A Windows MID Server can run as a specific Windows user or domain account. Windows credentials must provide sufficient permissions on each target host: a domain user with local administrator access works, as does a local account with administrator privileges and User Account Control disabled on that host. If User Account Control is enabled, administrator tasks can fail, so disabling it is the recommended fix.

A Connection & Credential alias holds connection details and credential data together. A child alias inherits its parent’s properties but keeps its own connection and credential details, so one parent can serve several connections to the same application.

OAuth 2.0 client credentials in the vault

An OAuth 2.0 client ID and client secret can be stored in CyberArk instead of on the instance. The MID Server fetches the pair when it needs a token, while the OAuth scope and token URL stay on the instance. The MID Server keeps the issued token in memory and refreshes it on expiry. The feature supports the Client Credentials grant type.

Frequently asked questions

Does the instance still hold a password when external storage is on for a credential?

No. With the External credential store check box ticked, the User name and Password fields are replaced by a Credential ID. The instance keeps that identifier and the credential type, and the MID Server retrieves the secret from the vault when a probe runs.

How many external vaults can one instance use?

Two at a time: the built-in CyberArk resolver and one custom resolver built from a JAR file.

What happens to credentials if the feature is switched off and then back on?

Switching the property off sets each external credential to inactive. Switching it back on does not reactivate them, so each credential record has to be reactivated by hand.

Can one MID Server manage credentials in both CyberArk and a custom vault?

No. A MID Server can manage credentials in one of those two vaults, not both at the same time.