avatarTeri Radichel

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2271

Abstract

/p><p id="abd6">One foot after another, deep breath in and out, sometimes it can be difficult and sometimes it can be easy. You can’t question whether you are doing it right or wrong, you just have to keep going. The same is true with writing; you need to type one word after the other for the ideas to flow.</p><p id="042d"><b>3.“A problem with a piece of writing often clarifies itself if you go for a long walk.”<a href="https://en.wikipedia.org/wiki/Helen_Dunmore"></a></b><a href="https://en.wikipedia.org/wiki/Helen_Dunmore">Helen Dunmore</a></p><p id="d2e9">Stepping away from your copy helps you find new connections to ideas, to structure a thought differently and tighten sentences. As you are out running your mind is busy at work forming connections you might have missed as you were writing. Running acts as the catalyst to the ideas that were marinating in your mind.</p><p id="66dd"><b>4.“In long-distance running the only opponent you have to beat is yourself, the way you used to be.”― Haruki Murakami, <a href="https://www.goodreads.com/work/quotes/2475030">What I Talk About When I Talk About Running</a></b></p><p id="fa36">There is only one person you need to compete with: yourself. You need to compete with the version of you that showed up yesterday, to tweak the process and learn new ways of getting better. Each day is an opportunity to better yourself.</p><p id="86b1"><b>5</b>.<b>“The twin activities of running and writing keep the writer reasonably sane and with the hope, however illusory and temporary, of control.</b><a href="https://en.wikipedia.org/wiki/Joyce_Carol_Oates">Joyce Carol Oates</a></p><p id="78b1">Life can be unpredictable, messy and dark. Your best-laid plans might flop in ways you had not foreseen. But in between the stimuli and your response you get the choice to control your reaction. And therein lies your power. In writing and running you get to step away from the heat of the moment; to find solutions to the problems you are facing.</p><p id="f5a5"><b>6</b>.<b>“If you don’t acquire the discipline to push through a personal low point, you will miss the reward that comes with persevering. Running taught me the discipline I need as a writer”.</b> <a href="https://www.amazon.com/Wrecked-Broken-World-Slams-Co

Options

mfortable/dp/0802404928">Jeff Goins</a></p><p id="a41c">The challenges we face can feel insurmountable and we might be tempted to give up. But in pushing past the pain and discomfort, we are building resilience and patience. Through running, writers deepen their ability to focus on a single, consuming task and enter a new state of mind entirely. The deliberate act of moving forward each day reminds you that everything will work out in the end.</p><p id="9554"><b>7.“For me, running is both exercise and a metaphor. Running day after day, piling up the races, bit by bit I raise the bar, and by clearing each level I elevate myself. At least that’s why I’ve put in the effort day after day: to raise my level…The point is whether or not I improved over yesterday.</b><a href="https://www.amazon.com/What-Talk-About-When-Running/dp/0307389839">Haruki Murakami</a></p><p id="3fc7">Word by word, mile by mile. All you can do is trust the process and put in the work despite your doubts, excuses, and fears. Once you start the fear begins to dissipate. You realize that the only way to<b> <i>finish</i> </b>an article or a race is to start. Just take one step and keep at it.</p><p id="5e50"><b>Creation, self-awareness and freedom. </b>Running offers writers escape with purpose.</p><p id="c042">You start with a blank page or a blank trail and end up with a creation of your own.</p><p id="6b50">You might also like:</p><div id="9b5a" class="link-block"> <a href="https://readmedium.com/building-a-writing-habit-for-beginners-by-a-beginner-e50a88508099"> <div> <div> <h2>How To Build A Writing Habit For Beginners, By A Beginner</h2> <div><h3>The world is still hungry for more great work</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*IzL6kfk468UzxQeqT3OO_g.jpeg)"></div> </div> </div> </a> </div><p id="64b4">As always thanks for reading. Keep the comments and corrections coming.</p><p id="6a86">Stay in the loop. <a href="https://rb.gy/0bfahg">Join my newsletter for more articles.</a></p></article></body>

Creating Automation Credentials Without Exposing Them To Users

ACM.35: Creating Secrets in AWS Secrets Manager with CloudFormation

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Check out my series on Automating Cybersecurity Metrics. The Code.

🔒 Related Stories: AWS Security | Security Architecture | IAM

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~

Update: Looks like AWS is now offering this approach for RDS passwords. :)

~~~

In the last post, we looked at how to prevent the confused deputy attack by leveraging resource policies.

Now we’re going to look at how we can create some credentials for automation without exposing them to users.

Let’s review the dependencies for this post we created in prior posts.

We created a role for automated credential deployments to be used by a batch job.

We created an AWS IAM user that is allowed to assume the batch job role:

We passed the batch job role into our KMS key policy:

We added a policy to our batch job role:

We refactored the role to work with an IAM Administrator User.

We fixed a problem that could lead to a confused deputy security weakness:

Now we can finally deploy our credentials using our new deployment role. We’re going to start by getting the role working and fix the permissions a bit more in subsequent posts.

CloudFormation Template to Create Credentials

The first thing we need is a CloudFormation template that will create credentials for our batch job admin. Recall that we created this user in a previous post and assign virtual MFA to the user, and both the user policy and the batch job assume role policy require MFA. The user doesn’t have permission to do anything without MFA so the credentials alone shouldn’t do anyone any good.

Even so we want to limit credential exposure so we’ll create them in an automated way and store them in AWS Secrets Manager without letting anyone see them.

Let’s take a look at the CloudFormation documentation for an access key.

Serial is not required and used for rotation. We may revisit that later.

Status: is not required. The allowed values are Active and Inactive. Since the documentation doesn’t specify a default we’ll pass in Active.

UserName is required. We will pass in our batch admin username which is the output of our Batch Job Admin stack:

Create the template in the cfn directory for the batch job. I named the file:

credentials_batch_job_admin.yaml

Now how can be get access to the credentials? If you created these credentials in the console you would be able to access them at the point of creation, but after you leave that screen there’s no way to get them again. Head over to the documentation and look for Ref and GetAtt.

We can get our access key id and secret access key using those constructs. In this case we definitely do NOT want to use a CloudFormation output. That would expose our credentials in the AWS Console to anyone who has access to CloudFormation.

In order to avoid that we’ll have to immediately create our Secrets Manager Secret here and add our secrets directly from Ref and GetAtt into our new secret.

CloudFormation for a Secret Manager Secret

Review the CloudFormation documentation for a Secret.

No fields are required but the documentation says:

Either GenerateSecretString or SecretString must have a value, but not both.

We will use these fields: Description, Name, KmsKeyId and SecretString.

We can pass in key-value pairs for our secret as shown in this example and we’ll use that format to pass in our two secret values.

We will pull the KMSKeyId from the outputs of our key stack as we did when we tested the DescribeKey command above. So here’s what our CloudFormation looks like for our secret:

Now run the command with the correct profile. Instead of letting the script use the default profile we’ll pass in our new batch job profile:

./deploy.sh batch

Turns out I got the following error:

For more about what causes this error check out this blog post.

I feel like this is a bug but for now we have to add both encrypt and decrypt permissions in the key policy for our IAM user.

Other changes to the KMS key policy

Note that I had to make some other changes to the key policy while figuring this all out I had some other errors.

After removing the current user and root user as administrators, I couldn’t view the key or the key policy in the console with my current user.

Since I was logged in as an administrator, I added the root user to the DescribeKey statement.

After doing that, I also need the GetKeyPolicy action:

To disallow non-admins from viewing the policy I created a separate statement in the policy for administrators to view the key policy.

Now our policy allows admin users to view but not modify keys via the KMS Key resource policy.

Prior post on IAM, Resource, and Trust policies if you are not familiar:

Our policy:

Note that with these changes, the KMS user needs to create, update and schedule keys for deletion. No one else will be able to do that. I added a script to schedule key deletion into the kms folder which can be called using the kms AWS CLI profile we created in a prior post:

Access to KMS is not allowed

I had one other case of the KMS is not allowed error I had to resolve.

When I look at the key policy I see the following condition:

"Condition": {
                "StringEquals": {
                    "kms:ViaService": "secretsmanager.${AWS::Region}.amazonaws.com",
                    "kms:CallerAccount": "${AWS::AccountId}"
                }
            }

I added that condition in this prior post:

Oops. Our pseudo parameters did not resolve correctly. I was trying to use them to set defaults for parameters but apparently that doesn’t work.

I decided to remove the Account ID because we’ll be using keys in a cross-account scenario. If I want to pass in an account ID later I’ll add it back in.

I also moved the current region pseudo parameter instead of passing in the region and we’ll assume for now that everyone in our accounts will use the current region where the key is deployed. In an environment that requires failover to a different region or a cross-account scenario you’ll need to test this to make sure it works.

After fixing that problem, the CloudFormation deploys successfully. The outputs show the resources that have been deployed.

Attempting to view the secret as an admin fails, as expected, because only the role that triggers batch jobs can retrieve and view the secret.

We can try to turn this into a batch job later, but it looks like we’re going to have to use our KMS batch job role and user to deploy the KMS key and we’ll leave that until we finalize moving management of KMS keys to a separate account.

Now we need to revise our role to give it only the permissions it requires — or in other words, a zero trust IAM policy. We’ll work on that next.

Follow for updates.

Teri Radichel | © 2nd Sight Lab 2022

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 Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow 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
Secrets Manager
Aws Access Key
Automation
Cloudformation
AWS
Recommended from ReadMedium