Storing Sensitive Password, URL and Database Credentials in AWS in Compliance with Security Auditing
Security, compliance and auditing are few of the very critical aspects for any organization to secure there SAP or Non-SAP landscape specially it is running in any Cloud Provider Datacenter.
Utilization and access to few of the user credentials are very sensitive and needs to be protected from any unauthorized access. Also whenever they need to be accessed then there must be some logging maintained somewhere so that the access can be audited in future.
In this Blog I am going to draft a process through which one can secure these credentials and it’s access in AWS by utilizing services provided by AWS itself. The cost is also minimum as the AWS services which has been utilized are either free or has very less cost.
- Access to AWS Console with IAM, Lambda, SMS, KMS and CloudWatch access
- Basic Knowledge of how to create Roles and assigning Policies
- Basic Knowledge of Lambda
- Basic Knowledge on how to monitor the logs in CloudWatch
- Create two users and assign the following inline policies through IAM
- One with all admin access for LAMBDA, System Manager, Parameter Store, KMS
- Second with only limited access of LAMBDA, System Manager and KMS
- Create KMS Customer Managed key for Data Encryption
- Create Parameter (SAP Credentials, URL and Database Credentials) in Parameter Store using KMS key to encrypt the detail
- Install AWS CLI on local desktop or Bastion Host and configure it for AWS access
- Use the User with limited access to the service System Manager and KMS to configure AWS CLI and access the detail through CLI commands
- Create LAMBDA function to access the credential
- Execute LAMBDA function for specific values to get required details
- Audit the CloudWatch for each execution of the LAMBDA function
In the above one can see there are two ways to get the necessary detail:
- AWS CLI
Through LAMBDA one can track the log in CloudWatch and thus help in auditing process.
Create user and assignation of Inline Policies:
- Create user with following Inline Policy:
Now verify that the above user has no access to KMS and Parameter Store through AWS Console. The screen of verification is as follows:
- Create second Lambda User with following Inline Policy
Verify that the above user has no additional access after login with AWS Console:
Create KMS Customer Managed Key for Data Encryption:
Go to KMS->Customer Managed Key->Create Key->Symmetric
Create Parameter (Credentials/URLs/Sensitive Details) in Parameter Store:
Go to Parameter Store and Create different credentials and URL whose detail is given in the following screen shot:
Please make sure that you plan for proper Hierarchy planned before maintaining your credential in the Parameter store. This is essential because based on this hierarchy your access through Lambda Code will be defined. Also it will give a standard approach of maintaining your credentials or URL. Please have a look into the following screen shot which will give you one such example:
Install AWS CLI and Configure to Access the Credentials:
If you are using AWS EC2 server as Bastion host and trying to access the parameters store then there is no need for fresh installation of AWS CLI as EC2 is already coming with default AWS CLI installed.
If the SAP admin team is using it’s own Laptop or Desktop then they need to install this tool separately. Please follow the following link to get this tool installed:
Once AWS CLI installed then use AWS Configure command to configure your Command line to communicate with your AWS account. Here you need to ask for “Access Key ID” and “Secret access Key” of the users which has been created above by your security team. The example of the credential file (.csv) is as follows:
AWS Configure command:
Now one can access the required details using the following commands:
aws ssm get-parameters –names <name of the parameter> –with-decryption –region <region_name>
EXAMPLE: aws ssm get-parameters –names /sap/abap/ecc/dev/ddic –with-decryption –region us-east-2
One can use the following command to get the detail of all the Credentials/URL which are available in a particular path:
aws ssm get-parameters-by-path –path <path_detail> –recursive –with-decryption –region <region_name>
EXAMPLE: aws ssm get-parameters-by-path –path /sap/ –recursive –with-decryption –region us-east-2
The above is one of the way through which the SAP Admin team can get the Desired Critical Information, if they need at any point of time during there support/work.
There is another way through which one can access these detail as well and which is LAMBDA function based. This is a serverless technology where access for the execution of this function has been given to SAP Admin team and they can invoke this whenever they need the detail. The best part of this method is, all such API calls are getting registered with CloudWatch and one can utilize this during Security Auditing.
Creation of Lambda Function:
As an example I have created the following code to get the required detail through LAMBDA:
ssm = boto3.client(‘ssm’, region_name=”us-east-2″)
abap_or_java = os.environ[‘ABAP_OR_JAVA’]
ecc_or_srm = os.environ[‘ECC_OR_SRM’]
sap_env = os.environ[‘DEV_OR_UAT_OR_PRD’]
sap_usr = os.environ[‘USER_NAME’]
def lambda_handler(event, context):
user_password = ssm.get_parameters(Names=[“/sap/” +abap_or_java+”/”+ecc_or_srm +”/”+sap_env +”/”+sap_usr], WithDecryption=True)
The process to create the Lambda function is shown in the following screen shot:
Now there a need to create Environment variable with the following detail in the Lambda Function:
The Value give an overview of all the value that might be possible and during execution one has to select one value (based on his requirement) by modifying the Value field and then function needs to be executed by clicking on TEST button.
The above step will create a lambda function as well as one AWS Role. That Role needs to be modified so that it has the access to KMS and Parameter Store.
Increase the Time-Out setting to at least 10-15 sec of the Lambda Function as Decryption will need some additional time.
Lambda Function Step is as follows:
Audit the CloudWatch for each execution of the LAMBDA function:
Everytime Lambda function getting executed it creates an entry in the CloudWatch
There are several Products in the market to maintain Critical Credentials like “KeyPass”. I have seen customers maintaining such details in password protected documents/excel-sheets as well.
But seeing the advantages (auditing, monitoring, maintenance and secured) and the TCO of using AWS Parameter Store, it is strongly recommended (advisable) to utilize this service from AWS to store all critical credentials and data.