Obfuscating AWS IAM Policies to Bypass CSPM Security Rules

Listen to this Post

URL: https://permiso.io/blog/introducing-sky-scalpel-open-source-tool

You Should Know:

Obfuscating AWS IAM (Identity and Access Management) policies can be a technique used to bypass Cloud Security Posture Management (CSPM) security rules and detection. This can be achieved through various methods such as Unicode encoding, wildcards, random casing, insignificant whitespace, and reordering of JSON documents. To prevent such techniques, it’s crucial to implement robust detection mechanisms and tools.

Practice Verified Codes and Commands:

1. Unicode Encoding Detection:

  • Use Python to detect Unicode encoding in IAM policies:
    import json</li>
    </ul>
    
    def detect_unicode_encoding(policy):
    try:
    json.loads(policy)
    return False
    except json.JSONDecodeError:
    return True
    
    policy = '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:<em>","Resource":"</em>"}]}'
    print(detect_unicode_encoding(policy))
    

    2. Wildcard Usage Detection:

    • Use AWS CLI to list IAM policies and check for wildcards:
      aws iam list-policies --query "Policies[?contains(PolicyDocument, '*')].[PolicyName, PolicyDocument]"
      

    3. Random Casing Detection: