Cloud command lines: reading identity, not touring production

The AWS, Azure, and Google Cloud CLIs are how you ask a cloud account what it believes. In a lab account, that question is the whole assessment.

Lesson 11 of 26 · 12 min read · practice only with authorization

Diagram

From the identity printout to three findings or none

Follow the path. One example at a time.

Step 1 of 4

Who

Print the identity first. A production administrator is the wrong shell.

Illustration: Who
# Who
# Print the identity first. A production administrator is
# the wrong shell.

The example on the open step is one illustration, or the fix you can paste into an application you own.

Start with who you are

Every cloud CLI has a way to print the identity the current credentials belong to, and the account or project those credentials can touch. Run that first. If the identity is a production administrator, you are in the wrong shell. Lab work happens in a throwaway account with a budget alarm and no keys copied from work.

The next questions are inventory. Which storage is public. Which security groups allow the world. Which roles can do everything. Which keys are older than your policy. Those are read calls. They are also sensitive, because the answers are a map. Keep the output with the engagement, not in a personal gist.

Reading a policy like a reader

A policy document is a list of allowed actions on resources, sometimes with conditions. Look for actions that mean “all,” resources that mean “all,” and principals that are broader than the job. A role attached to a build job should not be the role attached to a human, and neither should be able to delete the only audit log.

Public storage and open management ports are the findings that show up in real incidents because they are easy to create and easy to miss. The control is an organization rule that blocks public access, with a named exception process. The CLI is how you check the rule is actually on.

Identity: lab-reader@throwaway-project
Account:  training-0001
Storage:  one bucket, public access blocked
Role:     reader, list and get on the training project only

Reading the sample

This identity can look and cannot change. The account is a training project. Public access is blocked. That is a healthy lab. If the same printout showed a long-lived key for a human, an Administrator role, and a bucket with public listing, you would have three findings and a recommendation to start over in a new project rather than “be careful.”

Practice by creating the healthy version yourself in a personal training account, printing the identity, and saving the output next to a one-paragraph description. Do not use an employer account as the sandbox.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

The first command in a cloud lab should answer what?

Go deeper

Specific techniques, exercises, and glossary cards for this topic.

  1. 01Cloud security fundamentals: shared responsibility, identity, and the audit trailWhat the provider secures and what you do, why identity is the cloud perimeter, and the first read-only commands to understand an AWS, Azure, or Google Cloud account you are responsible for. Includes the diagram and a defensive fix.
  2. 02Cloud accounts and container environmentsCloud failure is usually identity and exposure. Includes the diagram and a defensive fix.
  3. 03Workload identity instead of static keysA long-lived access key on a laptop or in a repository is a session that does not expire. Includes the diagram and a defensive fix.
  4. 04Open security groups: SSH, RDP, and databases reachable from anywhereFirewall rules that allow 0.0.0.0/0 to management or database ports expose servers to constant scanning. Includes the diagram and a defensive fix.
  5. 05Public object storage: finding and closing open buckets and containersBuckets made public by mistake remain one of the most common cloud leaks. Includes the diagram and a defensive fix.
  6. 06Disabled metadata protections: IMDSv2 and why it blunts SSRFCloud instance metadata services hand out credentials to code on the machine. Includes the diagram and a defensive fix.

Exercises

  1. 01Control benchA failure is on the table. Choose the control that changes the outcome.
  2. 02Terminal mission: Database ports published to the worldA Compose file publishes ports for five services. Work out which ones listen on every interface, which are bound to localhost only, and why the host firewall does not save you.
  3. 03Terminal mission: A subdomain pointing at nothingOne shop.example subdomain still has a CNAME to a cloud app that was deleted. Find it before someone else registers the name and serves content under your domain.

Glossary

  1. 01Public object storageA bucket or blob container is world-readable or world-writable, so data leaks or is replaced.
  2. 02Open security groupsA management port reachable from the internet is an invitation, whatever password sits on it.
  3. 03Disabled metadata protectionsA workload role can be stolen by anything that can make the instance ask for its own credentials.