Keeping Sessions Short With AWS Assume-Role
ACM.364 Deploying resources with a job that requires MFA in a container with a short-lived session
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Part of my series on Automating Cybersecurity Metrics. The Code.
🔒 Related Stories: AWS Organizations. IAM. Deploying a Static Website
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I’m inserting this post where I skipped a number earlier. Also, I should have written about it earlier :)
Prior post:
Next post:
I’m adding this to my deployment script in my container that requires MFA on each run to deploy resources:
I’ve been showing you how to create sessions and use MFA in prior posts but I should have written about this a long time ago. I am running a quick command and ending it. How long do you think that command should take? It depends on the command but likely not over a minute in most cases. If I compile a bunch of commands together perhaps it takes a bit longer.
Let’s say the longest a command will take is one minute but I can override that if I have something that takes longer.
I can set the maximum length of a session using the assume-role command:

One minute is 60 seconds so I can add that to deployment script:

However, upon testing the minimum session length is 15 minutes or 900 seconds. Unfortunate. But we can end a session using the method I wrote about in another post.
I can add that to my call to obtain short term (really short term!) credentials to deploy a resource:

Use with MFA for best protection as explained in prior posts.
I can incorporate a question at the top of the script to see if the user wants to override the session length:

I added a function to validate the entry is numeric in my validation script:

The last thing I’ll mention is a feature request for AWS STS.
I wish AWS STS had a describe-sessions or list-sessions command like they do for other services like SSM that would show all the active STS sessions in an organization, an account, or for as specific user or role. #awswishlist

Follow for updates.
Teri Radichel | © 2nd Sight Lab 2023
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight LabNeed Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for PresentationFollow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
