Conjur Enterprise evoke restore --preview does not work
Symptom
When attempting to restore a database using "evoke restore --accept-eula --preview" in Conjur Enterprise 12.5+, evoke fails to connect to the database. Please note that when one does not specify the --preview switch, it does restore without issue. The --preview switch not functional.
Environment
12.4;12.5 Conjur Server Server Other
Cause
This error was found during an upgrade process between 12.4 and 12.5.
Conjur Enterprise 12.5 introduced a new "--preview" argument for the "evoke restore" command. When this command is run on 12.5+, it fails with "error: Database is still unavailable. Aborting!". It is not supported on earlier versions of Conjur Enterprise.
This argument was introduced to enable customers to discern whether or not they may be impacted by a security issue covered by
the following security bulletin: https://community.cyberark.com/s/article/Cyberark-Security-Bulletin-CA22-07
Resolution
This resolution offers a workaround for receiving this same report without the use of the "evoke restore --preview" command.
Attached below (as well as to this KB Article) is a shell script that must be
executed from the Conjur Leader docker host. It should be used prior to
upgrading to Conjur Enterprise 12.5 to verify if the customer is affected by
the aforementioned security bulletin.
The script will output the following:
- Any Credentials that exist in the database without an associated Role
- Any Roles that exist in the database without an associated Resource
The onus is on the customer to determine if the Credentials or Roles that are output are still in use, and to either re-introduce policy to manage them, or to follow through with the Conjur Enterprise 12.5 upgrade, which will automatically delete them.
VERY IMPORTANT: an upgrade to Conjur Enterprise 12.5 will automatically delete these records output by this script!
The bash script (get-undeleted-roles-and-api-keys.sh) is provided both below, and attached to this KB article as a downloadable artifact:
#!/bin/bash -e
CONTAINER_NAME=$1
SQL_ROLES_WITHOUT_RESOURCES=$(cat <<EOF
SELECT
account(role_id) as Account,
kind(role_id) as Kind,
identifier(role_id) as ID
FROM roles
WHERE role_id NOT IN (SELECT resource_id FROM resources)
AND policy_id IS NOT NULL;
EOF
)
SQL_CREDENTIALS_WITHOUT_ROLES=$(cat <<EOF
SELECT
account(role_id) as Account,
kind(role_id) as Kind,
identifier(role_id) as ID
FROM credentials
WHERE role_id NOT IN (SELECT role_id from roles);
EOF
)
echo -e "Roles that will be removed because the parent policy has been removed:\n"
docker exec --user conjur "$CONTAINER_NAME" psql -c "$SQL_ROLES_WITHOUT_RESOURCES"
echo -e "Credentials that will be removed because the associated role has been removed:\n"
docker exec --user conjur "$CONTAINER_NAME" psql -c "$SQL_CREDENTIALS_WITHOUT_ROLES"
Sample Usage and Output:
[conjur-leader.mycompany.com] $ ./get-undeleted-roles-and-api-keys.sh <appliance_container_name> Roles that will be removed because the parent policy has been removed: account | kind | id ---------+------+----------------- demo | user | sasha@myDemoApp (1 row) Credentials that will be removed because the associated role has been removed: account | kind | id ---------+------+--------------- demo | host | myDemoApp/app (1 row)