Skip to main content

More Info:

Ensure that all active sessions in the AWS Session Manager do not exceed the period of time set in the rule settings. Sessions that are active for longer than expected could be the result of suspicious activity. Session manager gives users the ability to open a shell into EC2 instances or execute commands on containers running in ECS.

Risk Level

High

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of SSM Session Length Should Be Minimum in AWS using AWS console, you can follow the below steps:
  1. Login to your AWS console.
  2. Go to the AWS Systems Manager console.
  3. Click on the ‘Managed Instances’ option from the left navigation pane.
  4. Select the instance for which you want to remediate the misconfiguration.
  5. Click on the ‘Actions’ button and select ‘Edit Managed Instance Settings’.
  6. In the ‘Edit Managed Instance Settings’ page, scroll down to the ‘SSM Agent Settings’ section.
  7. In the ‘SSM Session Length’ field, enter the minimum session length you want to set.
  8. Click on the ‘Save Changes’ button.
Once you have followed the above steps, the SSM Session Length will be set to the minimum value you have specified. This will help you remediate the misconfiguration of SSM Session Length Should Be Minimum in AWS.

The SSM Session Length should be set to a minimum for security reasons. To remediate this for AWS using AWS CLI, follow these steps:
  1. Open the AWS CLI and run the following command to update the SSM Document:
  1. This command will update the SSM Document with a new session length of 3600 seconds (1 hour). If you want to set a different session length, change the value of the sessionLength parameter in the command.
  2. After the SSM Document is updated, you can use it to start an SSH session to an instance with the new session length. To start an SSH session, run the following command:
  1. Replace instance-id with the ID of the instance you want to connect to.
  2. This command will start an SSH session with a session length of 3600 seconds (1 hour). If you want to set a different session length, change the value of the sessionLength parameter in the command.
  3. After the SSH session is started, you can use it to perform any necessary actions on the instance.
By following these steps, you can remediate the SSM Session Length misconfiguration in AWS.
To remediate the misconfiguration of SSM session length being minimum in AWS using Python, you can follow the below steps:
  1. Open the AWS Management Console and navigate to the EC2 service.
  2. Select the instance for which you want to remediate the SSM session length.
  3. Click on the “Actions” button and select “Instance Settings” and then “Modify IAM Role”.
  4. In the “Modify IAM Role” window, select the IAM role that has the required permissions to modify the SSM session length.
  5. Once you have selected the IAM role, click on the “Save” button to save the changes.
  6. Now, open your Python IDE and import the required libraries.
  1. Create a boto3 session object and specify the region where your instance is located.
  1. Create an SSM client object using the session object.
  1. Use the modify_instance_information() method to modify the SSM session length.
  1. In the above code, replace the ‘instance-id’ with the ID of your instance and ‘activation-id’ and ‘activation-code’ with the activation ID and activation code of your SSM agent.
  2. Also, modify the ‘SsmSessionDurationSeconds’ according to your requirement.
Once you execute the above code, it will remediate the SSM session length misconfiguration for your AWS instance.
Terraform cannot terminate an active SSM Session Manager session; the aws_ssm provider resources only manage configuration, not runtime sessions.To remediate this finding you must use the AWS CLI or console as per the verified fix:
WARNING: This immediately terminates the active session; ensure this will not disrupt legitimate operations.In the console, go to Systems Manager → Session Manager → Sessions, identify the long‑running session, and choose “Terminate session.” There is no Terraform argument or resource that can perform this runtime action.

Additional Reading: