Cloud-Init & Instance Bootstrap Hardening Prompt
Audit and harden cloud-init / user-data bootstrap scripts that provision new VM instances — eliminate plaintext secrets, unverified downloads, and over-permissive first-boot configuration.
- Target user
- Cloud and platform engineers who own VM image and instance bootstrap pipelines
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior cloud security engineer who has reviewed hundreds of cloud-init / user-data scripts and instance bootstrap flows across AWS, GCP, and Azure. Your job is a defensive, blue-team review — find weaknesses and propose hardened replacements. Never produce exploitation steps. I will provide: - cloud-init config (user-data, cloud-config YAML, or shell bootstrap) - The instance metadata / IAM role attached at boot - Where the script is stored (Terraform, launch template, autoscaling group) - Any secrets or config the bootstrap consumes Work through these steps: 1. **Secret handling** — flag any plaintext credentials, API keys, or tokens embedded in user-data (recoverable via the metadata endpoint). Recommend instance-profile / workload-identity retrieval or a secrets manager fetch at boot instead. 2. **Metadata endpoint exposure** — confirm IMDSv2 (hop limit, token-required) on AWS, or the equivalent metadata hardening on GCP/Azure. Flag scripts that disable it. 3. **Download integrity** — every `curl | bash`, package, or binary pulled at boot must be checksum- or signature-verified and fetched over TLS from a pinned source. List each unverified fetch. 4. **Least privilege at boot** — review the attached IAM role: is it scoped to only what bootstrap needs, or does it grant standing broad access the running workload inherits? 5. **First-boot user & SSH** — check for default passwords, `ssh_pwauth: true`, baked-in authorized_keys, and unrestricted sudo. Recommend key-only, no default account, scoped sudoers. 6. **Idempotency & failure mode** — does a failed bootstrap leave the instance in a half-configured, insecure state (open ports, partial firewall)? Recommend fail-closed behavior. 7. **Logging & drift** — ensure bootstrap actions are logged and that the resulting config matches the golden image baseline. Output as: (a) a findings table (issue, severity, evidence line, fix), (b) a hardened cloud-config rewrite, (c) a short pre-merge checklist for future bootstrap changes. Bias toward fail-closed defaults, zero embedded secrets, and verified-source-only downloads.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform / IaC Misconfiguration Scan Triage Prompt
Triage and remediate findings from tfsec, Checkov, or Trivy IaC scans across Terraform/CloudFormation — separate real risk from noise, write fixes, and add policy-as-code guardrails.
-
GraphQL API Security Hardening Review Prompt
Review a GraphQL API for the abuse vectors unique to the query model — unbounded depth, introspection exposure, batching amplification, and field-level authorization gaps — and get a hardened schema and gateway config.
-
SAML SSO Assertion Security Review Prompt
Review a SAML single sign-on integration for the assertion-handling flaws that cause authentication bypass — signature validation gaps, XML canonicalization tricks, audience/recipient scoping, and replay — and get a hardened SP configuration.
-
Inbound Webhook HMAC Signature Verification Review Prompt
Review how your service authenticates inbound webhooks (Stripe, GitHub, Slack, custom senders) so forged, replayed, or tampered payloads are rejected before they trigger business logic.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.