Detect Cycles in Cloud IAM Permission Chains

Last updated: December 9, 2025

Quick Overview

Given a set of IAM policies and role assumption chains across cloud accounts, detect circular permission chains that could lead to privilege escalation. Model this as a graph problem.

Wiz
Coding & Algorithms
Software Engineer
Wiz
December 9, 2025
Software Engineer
Technical Phone Screen
Coding & Algorithms
Medium

6

3

4,208 solved


Given a set of IAM policies and role assumption chains across cloud accounts, detect circular permission chains that could lead to privilege escalation. Model this as a graph problem.

Circular IAM permission chains are a real security risk. If Role A can assume Role B, and Role B can assume Role A, an attacker who compromises either role effectively has the permissions of both. More complex cycles across multiple roles and accounts can create unexpected privilege escalation paths. This problem tests your ability to model real security concepts as graph problems.

What the Interviewer Expects
  • Model IAM roles and assume-role relationships as a directed graph
  • Implement cycle detection using DFS with proper coloring (white/gray/black)
  • Return the actual cycle path, not just boolean detection
  • Handle multiple disconnected components
  • Analyze complexity and discuss real-world implications
Key Topics to Cover
Cycle detection in directed graphs
DFS with three-color marking
IAM role modeling
Privilege escalation analysis
Graph connectivity
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you extend this to detect cycles across different cloud providers?
  • What if some edges are conditional (can only assume role during business hours)?
  • How would you rank detected cycles by security severity?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Problem Analysis

This problem requires us to detect cycles in a directed graph, where nodes represent IAM roles and directed edges represent the ability to assume roles. Given that circular permissions can lead to pri...

Approach
  1. Model the IAM roles as a directed graph: Create an adjacency list where each role points to the roles it can assume. For example, if Role A can assume Role B and Role C, the adjacency list entr...

Submit Your Answer
Markdown supported

Related Questions