Library / Case Studies

Scalable IAM Architecture to Secure Access to 100 AWS Accounts at Segment

A real-world engineering write-up from Segment on distributed Security.

By Segment engineers · Segment · Added 2026-10-12

Open original source

All content belongs to Segment engineers / Segment. We only link to it and give credit. Report a problem

Learn this case study

About 37 min left. Your work is saved as you go.

What you are about to study

Segment explains a real system. You should know the basics: caching, queues and replication.

Ideas you will meet

Distributed Systems
Consensus, time, failure and the fundamentals of scale-out.
Web Security
OWASP risks, XSS, CSRF, CORS and secure design.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Networking and Web Security Deep Dive · 13 minThe OWASP Top 10 and secure designA map of the most common web application risks, what each means in practice and a short review checklist you can apply to any design.Read here

    What the Top 10 is

    OWASP (the Open Worldwide Application Security Project) publishes an awareness list of the most critical web application risks, updated every few years from real data. Treat it as a checklist of categories to think about, not a complete standard. The names and order change between editions, so below the themes are described in stable terms with the current style of names in brackets.

    The recurring risk categories

    Figure SDA-NSD-05-1 · The risk categories as a review map · © forcsguy.com

    CategoryIn plain wordsTypical prevention
    Broken access controlUsers can act outside their permissions (view others' data, call admin features)Check authorisation on the server for every request and object; deny by default; test with two users
    Cryptographic failuresSensitive data exposed (no TLS, weak or home-made crypto, plaintext storage)TLS everywhere, strong standard algorithms, hash passwords with a slow salted hash, manage keys properly
    InjectionInput interpreted as code or commandsParameterised queries, validation, least privilege (see the attacks lesson)
    Insecure designThe design itself lacks controlsThreat modelling, abuse cases, secure patterns, limits on resources
    Security misconfigurationDefault passwords, open storage buckets, verbose errors, missing headersHardened baselines, infrastructure as code, regular scans
    Vulnerable and outdated componentsKnown flaws in libraries or platformsInventory dependencies, update, use automated advisories
    Identification and authentication failuresWeak passwords, no MFA, bad session handlingMFA, rate limiting, safe recovery, strong session management
    Software and data integrity failuresUntrusted updates, insecure CI/CD, unsafe deserialisationSigned artefacts, protected pipelines, verify dependencies
    Security logging and monitoring failuresAttacks go unnoticedLog security events, alert, practise incident response
    Server-side request forgeryThe server fetches attacker-chosen URLsAllow-lists, block internal ranges, isolation

    Authentication, authorisation, encryption, hashing

    • Authentication answers "who are you?"; authorisation answers "what may you do?". Do both on the server, every request.
    • Encryption is reversible with a key (protect data in transit and at rest). Hashing is one-way (verify without storing the original): for passwords use a slow, salted algorithm such as Argon2, bcrypt or scrypt, never plain SHA of the password. A salt is a unique random value per password that defeats precomputed tables. (Details in the passwords lesson.)
    • Never invent your own cryptography.

    Secure design in practice

    1. Threat model early. Draw the data flows, list assets, ask "who might attack this and how?" (a simple method: for each component consider spoofing, tampering, repudiation, information disclosure, denial of service and elevation of privilege).
    2. Least privilege everywhere: users, services, database accounts, cloud roles.
    3. Defence in depth: several independent controls.
    4. Secure defaults: deny first; features off until needed.
    5. Fail safe: on error, do not grant access; do not leak details.
    6. Minimise data: do not collect or keep what you do not need.
    7. Automate: dependency scanning, static analysis, secret scanning, container scanning in CI.
    8. Test: unit tests for authorisation rules, automated scans, periodic penetration tests.
    9. Prepare for incidents: logs, alerts, runbooks, key rotation, backups.

    A short review checklist for any feature

    • Who is allowed to do this, and where is that checked?
    • What input comes from users, and how is it validated and encoded?
    • What secrets and personal data are involved, and how are they protected and logged?
    • What can an attacker abuse in volume (rate limits, size limits, cost)?
    • What third-party code or services does it add, and are they maintained?
    • How would we notice if it were abused?

    Where this fits

    Security is a property of the whole system: network edge (previous lessons), application code (attacks lesson), identity (SSO and passwords lessons), data (encryption) and operations (monitoring and incident response). Make it a routine part of design reviews, not a final gate.

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Scalable IAM Architecture to Secure Access to 100 AWS Accounts at Segment.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…