Last active
August 14, 2024 03:20
-
-
Save hotnops/a1d4ab5fc49d4d4190600827da9078f2 to your computer and use it in GitHub Desktop.
Useful APEMAN Queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find cognito vulenerable roles as specified in https://securitylabs.datadoghq.com/articles/amplified-exposure-how-aws-flaws-made-amplify-iam-roles-vulnerable-to-takeover/ | |
MATCH p=(r:AWSRole) <- [:AttachedTo] - (a:AWSAssumeRolePolicy) <- [:AttachedTo] - (s:AWSStatement {effect: "Allow"}) - [:Principal] -> (prin) | |
WHERE prin.name CONTAINS "cognito" | |
WITH s, p, r | |
OPTIONAL MATCH p2=(s) <- [:AttachedTo] - (c:AWSCondition) <- [:AttachedTo] - (ck:AWSConditionKey) | |
WHERE ck.name = "cognito-identity.amazonaws.com:aud" | |
WITH p, p2, s,r, COLLECT(ck) AS matchedKeys | |
WHERE SIZE(matchedKeys) = 0 | |
RETURN r.arn | |
// Get all cross account role chains | |
MATCH p=(a:UniqueArn) - [:IdentityTransform*] -> (b:AWSRole) WHERE NOT a.account_id = b.account_id | |
RETURN p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment