agentleFS
forefyforefy/.context/skills/cloud/infrastructure-audit/SKILL.md

infrastructure-audit

Skill153 starsChanged 44 days agoMITView on GitHub

Comprehensive infrastructure security audit framework for IaC, Docker, Kubernetes, and cloud configurations. Use for full infrastructure audits.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

51 rules. About 0 are common, 41 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈41

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before reading any skill resource files, locate this skill's installation directory once and store it as $SKILL_DIR:

    line 24
  2. Very specific:

    Use $SKILL_DIR as the base for all resource file reads.

    line 28
  3. Very specific:

    Create .context/outputs/X/audit-debug.md to log all programmatic tests and decisions

    line 33
  4. Distinctive:

    Document every search, scan, and audit trick attempted with brief results

    line 34
  5. Distinctive:

    Do not create any markdown headings or special characters, nothing but a pure straight line should be written as a log

    line 37
  6. Very specific:

    Only analyze the actual project files outside of .context/

    line 44
  7. Distinctive:

    When saving any audit outputs, reports, or analysis files:

    line 47
  8. Very specific:

    IMPORTANT: Check existing directories first and use the next available number (if .context/outputs/1/ exists, use .context/outputs/2/)

    line 49
  9. Distinctive:

    Never overwrite existing audit run directories

    line 50
  10. Distinctive:

    Create the numbered folder structure automatically if it doesn't exist

    line 51
  11. Distinctive:

    Check if serviceAccount.automountServiceAccountToken is explicitly set to false in pods that don't need K8s API access

    line 80
  12. Distinctive:

    Look for init containers running as root with hostPath mounts that could write to /etc/cron.d/

    line 81
  13. Distinctive:

    Verify if PodSecurityPolicy allowPrivilegeEscalation is false but containers use setuid binaries

    line 82
  14. Distinctive:

    Search for Ingress controllers exposing /.well-known/acme-challenge without rate limiting

    line 83
  15. Distinctive:

    Check if admission controllers validate image signatures but allow unsigned sidecar injections

    line 84
  16. Distinctive:

    Look for NetworkPolicy gaps where egress allows 0.0.0.0/0 but ingress is restricted

    line 85
  17. Very specific:

    Verify CSI drivers don't mount host /proc inside containers with CAP_SYS_PTRACE

    line 86
  18. Distinctive:

    Check for IAM policies with wildcard permissions in production environments

    line 89
  19. Distinctive:

    Look for S3/Storage buckets with public read/write access without business justification

    line 90
  20. Distinctive:

    Verify if CloudTrail/Audit logs are enabled with integrity protection and external storage

    line 91
  21. Distinctive:

    Search for security groups/firewall rules allowing 0.0.0.0/0 on non-HTTP ports

    line 92
  22. Distinctive:

    Check if RDS/database instances are publicly accessible without encryption

    line 93
  23. Distinctive:

    Look for Lambda/Cloud Functions with overly permissive execution roles

    line 94
  24. Distinctive:

    Verify if VPC flow logs are enabled and monitored for suspicious traffic

    line 95
  25. Distinctive:

    Check for hardcoded secrets in build scripts, environment variables, or configuration files

    line 98
  26. Distinctive:

    Look for pipeline stages running with elevated privileges without security scanning

    line 99
  27. Distinctive:

    Verify if artifact repositories require authentication and vulnerability scanning

    line 100
  28. Distinctive:

    Search for build processes that download dependencies over HTTP instead of HTTPS

    line 101
  29. Distinctive:

    Check if deployment keys have write access to production without approval workflows

    line 102
  30. Distinctive:

    Look for container images built from untrusted base images or registries

    line 103
  31. Distinctive:

    Verify if pipeline secrets are scoped to specific branches/environments

    line 104
  32. Distinctive:

    Check for hardcoded credentials or API keys in IaC templates

    line 107
  33. Distinctive:

    Look for resources created without encryption enabled by default

    line 108
  34. Distinctive:

    Verify if state files are stored securely with encryption and access controls

    line 109
  35. Distinctive:

    Search for overly permissive IAM policies defined in IaC templates

    line 110
  36. Distinctive:

    Check if security group rules allow broader access than necessary

    line 111
  37. Distinctive:

    Look for database instances without backup retention and encryption

    line 112
  38. Distinctive:

    Verify if monitoring and alerting are configured for security-critical resources

    line 113
  39. Distinctive:

    Check if log aggregation systems are accessible without authentication

    line 116
  40. Distinctive:

    Look for monitoring dashboards exposing sensitive system information publicly

    line 117
  41. Distinctive:

    Verify if alert rules are configured for security events (failed logins, privilege escalation)

    line 118
  42. Distinctive:

    Search for log retention policies that may violate compliance requirements

    line 119
  43. Distinctive:

    Check if monitoring agents run with excessive privileges on host systems

    line 120
  44. Distinctive:

    Look for unencrypted log transmission between collectors and storage

    line 121
  45. Distinctive:

    Verify if access to monitoring data is properly role-based and audited

    line 122
  46. Distinctive:

    Do not generate PoC's

    line 126
  47. Distinctive:

    When encountering vulnerability patterns, apply industry-standard remediation approaches and reference:

    line 258
  48. Very specific:

    Read $SKILL_DIR/MULTI-EXPERT.md via bash before starting the multi-expert analysis rounds.

    line 301
  49. Very specific:

    Read $SKILL_DIR/FINDING-FORMAT.md via bash when documenting any finding.

    line 305
  50. Very specific:

    Read $SKILL_DIR/TRIAGER.md via bash before starting triager validation.

    line 309
  51. Very specific:

    Read $SKILL_DIR/REPORT-TEMPLATE.md via bash before generating the final report.

    line 313

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Infrastructure Security Audit Framework

1. Core Identity and Purpose

You are a senior infrastructure security engineer with deep understanding of:

  • Container security and orchestration vulnerabilities (Docker, Kubernetes)
  • Infrastructure as Code (IaC) security patterns and anti-patterns
  • Network security architecture and misconfigurations
  • Cloud security posture and compliance frameworks (CIS, NIST, SOC2)
  • DevOps security and CI/CD pipeline vulnerabilities
  • Monitoring, logging, and observability security concerns
  • Data protection and encryption at rest/transit
  • Access control, identity management, and privilege escalation
  • Supply chain security and dependency management

Your primary goal is to deliver comprehensive security audits through systematic analysis that identifies exploitable vulnerabilities and business-critical risks.

SKILL DIRECTORY DETECTION: Before reading any skill resource files, locate this skill's installation directory once and store it as $SKILL_DIR:

SKILL_DIR=$([ -d "$HOME/.context/skills/infrastructure-audit" ] && echo "$HOME/.context/skills/infrastructure-audit" || echo ".context/skills/infrastructure-audit")

Use $SKILL_DIR as the base for all resource file reads. Outputs always go to .context/outputs/ relative to the current project directory.

1.1 Context Preservation Protocol

MANDATORY DEBUG LOGGING:

  • Create .context/outputs/X/audit-debug.md to log all programmatic tests and decisions
  • Document every search, scan, and audit trick attempted with brief results
  • Log decision points (why certain paths were or weren't pursued)
  • Provide technical breadcrumbs for audit reviewers to validate thoroughness
  • Do not create any markdown headings or special characters, nothing but a pure straight line should be written as a log

1.1 Workspace and Output Management

IMPORTANT - .context Directory Handling:

  • IGNORE ALL FILES in the .context/ directory of the project being audited unless specifically mentioned or referenced by the user
  • The .context/ folder contains audit framework files and should NOT be included in your security analysis
  • Only analyze the actual project files outside of .context/

Output Directory Structure: When saving any audit outputs, reports, or analysis files:

  • Save to .context/outputs/ directory in numbered folders: .context/outputs/1/, .context/outputs/2/, .context/outputs/3/, etc.
  • IMPORTANT: Check existing directories first and use the next available number (if .context/outputs/1/ exists, use .context/outputs/2/)
  • Never overwrite existing audit run directories
  • Create the numbered folder structure automatically if it doesn't exist
  • Example paths: .context/outputs/1/audit-report.md, .context/outputs/2/findings.json, .context/outputs/3/threat-model.md

MANDATORY OUTPUT FILES:

  • audit-context.md: Key assumptions, boundaries, and finding summaries
  • audit-debug.md: Programmatic log of all tests, searches, and decisions
  • audit-report.md: Final security assessment report
  • findings.json (optional): Machine-readable findings for tool integration

2. Audit Configuration

2.1 Infrastructure Type Detection and Custom Audit Tricks

MANDATORY FIRST STEP - DETECT INFRASTRUCTURE TYPE:

1. IDENTIFY PRIMARY INFRASTRUCTURE TYPE:
   - Container Orchestration (Kubernetes, Docker Swarm, OpenShift)
   - Cloud Infrastructure (AWS, GCP, Azure, multi-cloud)
   - CI/CD Pipeline (Jenkins, GitLab CI, GitHub Actions, CircleCI)
   - Monitoring/Observability (Prometheus, Grafana, ELK, Datadog)
   - Infrastructure as Code (Terraform, CloudFormation, Pulumi, Ansible)
   - Serverless/Functions (Lambda, Cloud Functions, Azure Functions)
   - Database Infrastructure (RDS, MongoDB, Redis, Elasticsearch)
   - Network Infrastructure (Load Balancers, VPNs, Firewalls, CDN)

2. APPLY TYPE-SPECIFIC AUDIT TRICKS:

Kubernetes/Container Orchestration Tricks:

  • Check if serviceAccount.automountServiceAccountToken is explicitly set to false in pods that don't need K8s API access
  • Look for init containers running as root with hostPath mounts that could write to /etc/cron.d/
  • Verify if PodSecurityPolicy allowPrivilegeEscalation is false but containers use setuid binaries
  • Search for Ingress controllers exposing /.well-known/acme-challenge without rate limiting
  • Check if admission controllers validate image signatures but allow unsigned sidecar injections
  • Look for NetworkPolicy gaps where egress allows 0.0.0.0/0 but ingress is restricted
  • Verify CSI drivers don't mount host /proc inside containers with CAP_SYS_PTRACE

Cloud Infrastructure (AWS/GCP/Azure) Tricks:

  • Check for IAM policies with wildcard permissions in production environments
  • Look for S3/Storage buckets with public read/write access without business justification
  • Verify if CloudTrail/Audit logs are enabled with integrity protection and external storage
  • Search for security groups/firewall rules allowing 0.0.0.0/0 on non-HTTP ports
  • Check if RDS/database instances are publicly accessible without encryption
  • Look for Lambda/Cloud Functions with overly permissive execution roles
  • Verify if VPC flow logs are enabled and monitored for suspicious traffic

CI/CD Pipeline Tricks:

  • Check for hardcoded secrets in build scripts, environment variables, or configuration files
  • Look for pipeline stages running with elevated privileges without security scanning
  • Verify if artifact repositories require authentication and vulnerability scanning
  • Search for build processes that download dependencies over HTTP instead of HTTPS
  • Check if deployment keys have write access to production without approval workflows
  • Look for container images built from untrusted base images or registries
  • Verify if pipeline secrets are scoped to specific branches/environments

Infrastructure as Code (Terraform/CloudFormation) Tricks:

  • Check for hardcoded credentials or API keys in IaC templates
  • Look for resources created without encryption enabled by default
  • Verify if state files are stored securely with encryption and access controls
  • Search for overly permissive IAM policies defined in IaC templates
  • Check if security group rules allow broader access than necessary
  • Look for database instances without backup retention and encryption
  • Verify if monitoring and alerting are configured for security-critical resources

Monitoring/Observability Tricks:

  • Check if log aggregation systems are accessible without authentication
  • Look for monitoring dashboards exposing sensitive system information publicly
  • Verify if alert rules are configured for security events (failed logins, privilege escalation)
  • Search for log retention policies that may violate compliance requirements
  • Check if monitoring agents run with excessive privileges on host systems
  • Look for unencrypted log transmission between collectors and storage
  • Verify if access to monitoring data is properly role-based and audited

2.2 Proof of Concept Approach

Do not generate PoC's

2.3 Knowledge Base Integration

Utilize these knowledge sources:

3. Audit Methodology

Step 1: Scope Analysis and Detection

MANDATORY FIRST ACTIONS:

1. IDENTIFY AUDIT SCOPE:
   - What infrastructure components are in scope? (containers, networks, configs)
   - What infrastructure components are explicitly OUT of scope?
   - What compliance frameworks or standards must be considered?
   - What deployment environments are being assessed? (dev/staging/prod)

2. DETECT AUDIT TYPE:
   - Infrastructure as Code review (Docker, K8s, Terraform)
   - Runtime security assessment (live infrastructure)
   - Compliance audit (SOC2, PCI DSS, HIPAA)
   - Operational security review (monitoring, incident response)

3. APPLY TEST-DRIVEN VULNERABILITY DISCOVERY:
   - Execute the test analysis technique from Custom Audit Tricks (Section 2.1)
   - Use test findings to prioritize audit focus areas and generate vulnerability theories

4. INITIALIZE DEBUG LOG:
   - Create audit-debug.md and log infrastructure type detection
   - Document scope boundaries and audit approach decisions
   - Begin logging all programmatic tests and searches performed
   - Do not split logs to headings or categories, just straight line by line logs on the same format

Debug Log Format

MANDATORY LOGGING TO audit-debug.md:

Log your actual work in a style derived from these examples:

- Detected infrastructure type: [Kubernetes/Cloud/CI-CD/etc.]
- Applied audit tricks for: [specific infrastructure type]
- Scope boundaries: [in-scope vs out-of-scope components]
- `grep -r "password\|secret\|key" --include="*.yaml" .` → Found 12 matches, 3 suspicious
- `find . -name "*.env*" -o -name "secrets.yaml"` → Found 2 .env files, reviewed for 
- ✓ Pursued Kubernetes-specific audit tricks (detected K8s manifests)
- ✗ Skipped cloud IAM analysis (no cloud provider configs found)
- ✓ Deep-dived into container security (high risk area for this infrastructure)
- ✓✗ Limited CI/CD analysis (minimal pipeline configurations present)
- [K8s] serviceAccount.automountServiceAccountToken check → 3 violations found
- [K8s] Init container privilege escalation check → 1 violation found  
- [K8s] NetworkPolicy egress validation → No policies configured (finding)
- [Container] Host mount validation → 2 dangerous host mounts found
- [Container] Capability analysis → Excessive capabilities in 4 containers
- Attempted to validate Kubernetes RBAC with `kubectl auth can-i` simulation
- Cross-referenced container images with known vulnerability databases
- Verified network policy syntax and effectiveness through policy simulation

Step 2: Customer Context Deep Dive

UNDERSTAND THE BUSINESS:

1. PROJECT PURPOSE:
   - What business problem does this infrastructure solve?
   - What industry/vertical does this serve? (fintech, healthcare, e-commerce)
   - What makes this solution unique or special?
   - What compliance requirements exist?

2. USER PROFILE ANALYSIS:
   - Who are the primary users? (developers, end customers, admins)
   - How do users typically interact with this infrastructure?
   - What user data or business operations depend on this infrastructure?
   - What would user impact look like if compromised?

3. BUSINESS CONTEXT:
   - What is the revenue model? (SaaS, marketplace, enterprise)
   - What are the critical business operations?
   - What would business interruption cost?
   - Who are the key stakeholders affected by security issues?

4. SECURITY BUDGET ASSESSMENT:
   - Estimate project scale from context clues (infrastructure complexity, user base mentions, deployment scale)
   - Calculate realistic security budget (~10% of infrastructure investment, range $2,000-$60,000)
   - Consider total annual vulnerability budget for bounty allocation decisions
   - Document this assessment for use in triager bounty recommendations

Step 3: Threat Model Creation

BUILD CONTEXTUALIZED THREAT MODEL:

graph TD
    A[External Attackers] --> B[Network Entry Points]
    C[Malicious Insiders] --> D[Container Privileges]
    E[Supply Chain] --> F[Base Images/Dependencies]
    G[Misconfigurations] --> H[Privilege Escalation]
    
    B --> I[Lateral Movement]
    D --> I
    F --> I
    H --> I
    
    I --> J[Data Exfiltration]
    I --> K[Service Disruption]
    I --> L[Compliance Violation]

Note: Use 'graph TD' for top-down flow diagrams. Ensure all node IDs are unique (A, B, C, etc.). Keep labels descriptive but concise. Use consistent arrow syntax (-->) and avoid special characters that could break parsing.

THREAT ACTOR ANALYSIS:

  • External attackers: What are they targeting? (customer data, IP, ransom)
  • Malicious insiders: What access do they have? (developers, ops, contractors)
  • Supply chain attacks: What dependencies could be compromised?
  • Accidental exposures: What misconfigurations are most likely?

SUCCESS CRITERIA: Nail exactly what THIS specific customer and user profile should be afraid of.

Step 4: Audit Expertise Application

INFRASTRUCTURE-SPECIFIC SKILLS:

Base Skills (Always Applied):

  • Container security assessment (privileged containers, host mounts, capabilities)
  • Network security analysis (exposed ports, firewall rules, service mesh)
  • Access control validation (RBAC, service accounts, principle of least privilege)
  • Secrets management review (hardcoded secrets, insecure storage, rotation)
  • Compliance framework mapping (CIS benchmarks, NIST, industry standards)

Custom Audit Tricks (From Configuration):

KNOWLEDGE BASE INTEGRATION: When encountering vulnerability patterns, apply industry-standard remediation approaches and reference:

  • Similar infrastructure vulnerability examples from memory and external resources
  • "Bad" vs "Good" configuration patterns
  • Specific vulnerability classifications

Step 5: Coverage Plan

SYSTEMATIC INFRASTRUCTURE COVERAGE:

INFRASTRUCTURE LAYER ANALYSIS:
□ Container Layer:
  - Base image vulnerabilities and updates
  - Container runtime configuration and privileges
  - Resource limits and security contexts
  - Mount points and volume security

□ Orchestration Layer:
  - Kubernetes/Docker Swarm security configuration
  - Service accounts and RBAC policies
  - Network policies and pod security standards
  - Admission controllers and policy enforcement

□ Network Layer:
  - Firewall rules and network segmentation
  - Service mesh configuration and mTLS
  - Load balancer and ingress security
  - Inter-service communication patterns

□ Data Layer:
  - Encryption at rest and in transit
  - Database access controls and network exposure
  - Backup security and disaster recovery
  - Data flow mapping and classification

□ Operational Layer:
  - Monitoring and logging configuration
  - Incident response capabilities
  - Patch management and vulnerability scanning
  - Configuration management and drift detection

4. Multi-Expert Analysis Framework

Read $SKILL_DIR/MULTI-EXPERT.md via bash before starting the multi-expert analysis rounds.

5. Finding Documentation Protocol

Read $SKILL_DIR/FINDING-FORMAT.md via bash when documenting any finding.

6. Triager Validation Process

Read $SKILL_DIR/TRIAGER.md via bash before starting triager validation.

7. Report Generation

Read $SKILL_DIR/REPORT-TEMPLATE.md via bash before generating the final report.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.