Machine Identity Security: Service Accounts, Keys and Workloads
Machine identity covers workloads that authenticate without a human at the keyboard: service accounts, API keys, CI/CD tokens, certificates, cloud instance roles and workload identities. Secure them with unique identities, vault or managed credentials, short lifetime, least privilege, rotation and audit — not shared passwords in chat. Defence and builder hygiene only; no credential-theft recipes.
Friends! Humans get MFA training, but the svc_backup password gets pasted in Slack — a silent breach path. Today: machine identity: vault, short-lived tokens, least privilege, rotation, audit. No attack steps. Own apps / lab only.
मित्रांनो! Humans ला MFA शिकवतात, पण svc_backup चा password Slack मध्ये paste — हा silent breach path. आज machine identity: vault, short-lived tokens, least privilege, rotation, audit. Attack steps नाही. Own apps / lab only.
मित्रों! Humans को MFA सिखाते हैं, लेकिन svc_backup का password Slack में paste — ये silent breach path. आज machine identity: vault, short-lived tokens, least privilege, rotation, audit. Attack steps नहीं. Own apps / lab only.
Quick answer
Secure service accounts and machine identities:
- Inventory every non-human identity: AD services, cloud roles, CI secrets, bot users, certificates.
- Give each workload its own identity — never one shared “god” key across prod and laptop demos.
- Prefer managed identities / gMSA / cloud roles over long-lived static passwords when the platform allows.
- Store remaining secrets in an approved vault; never git, screenshots, wiki footers or chat.
- Scope permissions to the minimum actions and resources; review quarterly.
- Rotate on a calendar and on suspicion; alert on auth from unusual places.
- Log who (which workload) used which credential; owners must exist on a wiki page.
Tiny mental model:
Workload → its own ID → short-lived or vaulted secret → least privilege → audit
Shared forever-password in git = breach waiting to publish
What do I need before this guide?
- Human IAM habits: Cloud IAM least privilege.
- AD context: Active Directory hardening and monitoring.
- Optional: Software supply chain / secrets.
- Lab: a throwaway app or cloud sandbox you control.
What is machine identity?
Service accounts and workloads use vaulted or short-lived credentials, least privilege and rotation instead of shared forever keys.
Service accounts आणि workloads vaulted or short-lived credentials, least privilege आणि rotation वापरतात — shared forever keys ऐवजी.
Service accounts और workloads vaulted or short-lived credentials, least privilege और rotation इस्तेमाल करते हैं — shared forever keys की जगह.
Common machine identities (defender vocabulary)
- OS / directory service accounts — Windows services, Linux daemons bound to domain or local users.
- Cloud instance / workload identities — roles attached to VMs, functions, Kubernetes service accounts.
- CI/CD and automation tokens — pipeline secrets that deploy or call APIs.
- API keys and client credentials — OAuth client secrets, vendor integrations.
- Certificates and keys — mTLS client certs, code-signing (protect and inventory separately).
- RPA / bot accounts — often over-privileged “human impersonators” — treat as machines with owners.
Educational warning: do not harvest tokens from other tenants, crack service passwords, or exfiltrate CI secrets. Practise rotation and vault wiring on systems you own.
Real incident: CI secrets exposure pattern (CircleCI 2023, public lessons)
Public reporting around CircleCI’s January 2023 security incident described customer urgency to rotate secrets that might have been exposed via the CI environment. Separately, years of breach reports show the same root theme: long-lived pipeline credentials and secrets copied into many tools create a wide blast radius when any one system is abused.
Takeaways (vertical):
- What happened — CI-adjacent trust forced emergency rotation across many customer secrets.
- What went wrong (theme) — valuable machine credentials concentrated and sometimes overly long-lived.
- Care-take — inventory CI secrets; rotate on vendor advisory without waiting for “proof of use”.
- Care-take — prefer OIDC / short-lived cloud roles from pipelines over static access keys when possible.
- Care-take — revoke first, investigate second when a vault or CI path may be tainted.
- Bonus parallel — Codecov-style supply-chain reports also stressed reviewing CI secrets after trust breaks.
Human vs machine identity
- Humans: MFA, phishing-resistant factors, joiner/leaver tickets.
- Machines: no interactive MFA prompt — compensate with platform attestation, network allow-lists, short TTL and vault issuance.
- Do not share a human’s password with a batch job “just for tonight”.
- Break-glass human admins stay separate from deploy bots.
- Fictional Mauli Dairy, Pune: the invoice API uses a cloud role on the app host; developers never paste the old static key into Telegram.
Password-less machines still need owners
- A cloud role with no human password can still wipe a database — ownership and least privilege remain mandatory.
- ChatOps bots that run privileged commands need the same change control as humans typing those commands.
- Record the business purpose: “deploy invoices API” beats “misc automation”.
Red Team vs Blue Team (awareness only)
Red Team — what attackers try
- Find secrets in git history, ticket attachments, container env dumps (high-level).
- Abuse over-privileged CI roles to reach production data.
- Keep persistence via forgotten service accounts that nobody rotates.
Blue Team — defend, detect, respond
- Secret scanning in repos and pipelines; block merges on high-entropy leaks.
- Alert on unused identities suddenly authenticating after months quiet.
- Conditional access / IP allow-lists for automation where supported.
- Rapid revoke playbooks for CI and vault incidents.
- Quarterly attestation: owner confirms each machine identity still needed.
How do I secure service accounts step by step?
Step 1 — Inventory spreadsheet (start ugly)
- Columns: name, system, owner, privilege summary, secret location, last rotated, expires.
- Mark anything with Domain Admin / cloud
*:*/ production DB admin as P0. - Delete orphan identities after owner confirmation.
Step 2 — Replace the worst patterns
- Static AWS keys on laptops → IAM roles on compute or SSO short sessions.
- AD service password in a share → gMSA or vault-issued secret with rotation.
- One Jenkins user that can deploy everywhere → split per environment.
- Certificates: track expiry; alert 30 days prior.
Step 3 — Operate
- Every pipeline secret has an expiry or rotation job.
- Production deploy credentials cannot be read by feature-branch pipelines.
- Application configs pull from vault at runtime; no secrets in images.
- Audit logs reviewed for machine identities like you review human admins.
Step 4 — Lab drill
- Create a fake API key for a toy app on your laptop.
- Put it in vault (or password manager as a training stand-in); remove from
.envcommitted copies. - Rotate it once; confirm the old value fails; write the five-line note.
Ravindra Bagale's Tip
💡 Students leave a "temporary" key in the README and forget it. Temporary without a calendar = permanent. In interviews say: inventory, vault, short-lived cloud roles, rotate-on-incident. Do not paste secrets into ChatGPT either. Got it?
Ravindra Bagale's Tip – मराठी
💡 Students "temporary" key README मध्ये ठेवतात आणि विसरतात. Temporary without calendar = permanent. Interview मध्ये बोला: inventory, vault, short-lived cloud roles, rotate-on-incident. Secret paste ChatGPT मध्ये पण नको. समजलं का?
Ravindra Bagale's Tip – हिंदी
💡 Students "temporary" key README में रखते हैं और भूल जाते हैं. Temporary without calendar = permanent. Interview में बोलो: inventory, vault, short-lived cloud roles, rotate-on-incident. Secret paste ChatGPT में भी नहीं. समझ में आया?
Short-lived credentials beat “forever keys”
- Cloud instance roles and workload identity federation mint temporary credentials — prefer them for compute.
- OIDC into cloud from GitHub Actions / GitLab / similar removes many static deploy keys when configured carefully.
- Certificate-based client auth needs inventory and renewal automation — expiry is an availability and security event.
- If a vendor only offers a long-lived API key, isolate it: network allow-list, minimal scopes, 90-day rotation, dedicated owner.
- Document the revoke button location before an incident — panic searching wastes hours.
Lab warning
Practise vault wiring and rotation on your sandbox. Do not revoke credentials on an employer or client tenant without change tickets and approval. Do not scan the public internet for exposed keys to “help notify” — use official disclosure channels if you find something accidentally in your own telemetry.
Care-take — organisation habits
- Secrets in tickets = regenerate immediately.
- Third-party integrations get unique credentials per vendor.
- Offboarding removes human and the bots they owned.
- Signing keys offline or in HSM per policy — not on the intern laptop.
- Tabletop: “CI advisory says rotate within 24h — who owns the list?”
- Prefer federation over copying passwords into yet another SaaS.
How do I fix common machine-identity mistakes?
Ghabru naka 😅 — these are the usual ones:
| Symptom | Likely cause | Fix |
|---|---|---|
| Key in git history | Rushed commit | Rotate; purge guidance per org; pre-commit scan |
| Prod outage after rotate | Hard-coded old secret | Runtime vault; dual-run period |
| Bot is Global Admin | Convenience | Least privilege; split duties |
| No owner on svc account | Tribal knowledge | Force owner field or disable |
| Same key in dev and prod | Copy-paste culture | Separate identities per env |
| Cert expired overnight | No inventory | Expiry monitoring + calendar |
Try it at home
Educational only on your projects:
- List every API key in one personal project (even if only three).
- Move one secret out of plaintext config into an env var loaded locally (not committed).
- Set a calendar reminder to rotate it in 30 days.
- Enable secret scanning on a private repo you own if the host offers it.
- Write two interview sentences on machine vs human identity.
Learn it properly
Course lessons:
Related guides: AD hardening · Cloud IAM least privilege · SBOM / secrets · Crypto TLS / PKI
Got it? Machine identity = service accounts, CI tokens, roles, certs. Unique ID, vault / managed identity, least privilege, rotate, audit. Shared forever key = breach. No attack harvesting — your systems. Next: STRIDE threat modeling guide.
समजलं का? Machine identity = service accounts, CI tokens, roles, certs. Unique ID, vault / managed identity, least privilege, rotate, audit. Shared forever key = breach. Attack harvesting नाही – तुमच्या systems. आता STRIDE threat modeling guide.
समझ में आया? Machine identity = service accounts, CI tokens, roles, certs. Unique ID, vault / managed identity, least privilege, rotate, audit. Shared forever key = breach. Attack harvesting नहीं – आपके systems. आगे STRIDE threat modeling guide.
Frequently asked questions
What is machine identity?
Authentication for workloads without a human at the keyboard — services, pipelines, roles, certificates.
Are cloud instance roles safer than access keys?
Usually yes when scoped tightly: temporary credentials beat forever keys on disk.
What did CI incidents teach?
Public CircleCI-2023 style lessons urged rapid secret rotation and less reliance on long-lived pipeline keys.
Can I paste service passwords into ChatGPT to debug?
No. Treat that as a leak — rotate and use approved enterprise tools.
Is this an attack guide?
No. Builder and defender hygiene on systems you own or are authorised to manage.
Where are related lessons?
Cloud IAM, secrets protection and AD defence checklist chapters on this site.