Interview Prep/DevSecOps/Incident Response and Governance

A developer pushed an image with an embedded `.env` file to a public Docker Hub repository. How do you respond?

BeginnerScenarioIncident Response and Governance
Answer

Situation read → Public images are scraped by bots quickly. Treat every secret in it as leaked.

What I'd do →

  1. Rotate every credential in the .env file first.
  2. Make the repository private or delete the tag; deletion does not undo downloads.
  3. Check logs of the affected services for use of the leaked credentials.
  4. Add a .dockerignore with .env, and scan images for secrets in CI:
    trivy image --scanners secret myorg/app:1.2.0
    
  5. Restrict who can push to public namespaces.

Why → Rotation is the only real fix; removal only limits further exposure.

Interview tip → Say "rotate first, clean up second" clearly.

All DevSecOps questions

More on Incident Response and Governance