Pipeline Security Scanning
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q1 You are asked to add security to an existing CI pipeline. Where do SAST, SCA, secrets scanning and DAST each go?
Beginner
Situation read โ Classic "shift left" design question. Each scan type needs a different artifact, so each lands at a different stage.
What I'd do โ
- Pre-commit and PR: secrets scan (
gitleaks) and fast SAST (semgrep) on the diff only. - Build stage: SCA against lockfiles (
trivy fs,osv-scanner) and IaC scan (checkov,trivy config). - After image build: image scan (
trivy image), SBOM generation, signing. - After deploy to staging: DAST (
ZAP baseline) against the running app. - Production: runtime detection and continuous re-scan of SBOMs.
Why โ SAST and SCA need only source, so they run before anything is built. DAST needs a running target, so it can only run after deploy.
Interview tip โ Say "cheap and fast scans block the PR, slow scans run nightly or post-deploy".
Q2 Gitleaks flags an AWS access key in a pull request. The developer says it is a test key. What do you do?
Beginner
Situation read โ I never trust "it is a test key" until I verify it. Anything shaped like AKIA... is live until proven otherwise.
What I'd do โ
- Block the merge and keep the PR open.
- Check whether the key is valid:
aws sts get-caller-identitywith that key from a trusted workstation, or ask the cloud team to look it up in IAM. - If live, deactivate it right away:
aws iam update-access-key --access-key-id AKIA... --status Inactive --user-name <user>. - Remove the key from the branch history, not just the last commit, then rotate and move the value to a secret store.
- Add a fake-looking placeholder or an allowlist entry in
.gitleaks.tomlonly if it is truly a dummy.
Why โ A key pushed to a remote can be scraped within minutes, even on private repos that later get exposed.
Interview tip โ Mention that rotation matters more than deleting the commit.
Q3 Developers fear security scans will slow the pipeline from 6 to 20 minutes. How do you roll them out?
Beginner
Situation read โ The real risk is developer pushback, not the tools. Slow gates get bypassed.
What I'd do โ
- Run scans in parallel with unit tests, not after them.
- Scan only changed files on PRs (
semgrep cidoes diff-aware scanning). - Cache vulnerability databases (
trivy--cache-dirplus CI cache). - Move heavy scans (full DAST, deep CodeQL) to nightly schedules.
- Publish timing per job and keep the added time under about 2 minutes on PRs.
Why โ Developers accept gates that are fast and predictable. A 2-minute scan with a clear message wins over a 15-minute scan nobody trusts.
Interview tip โ Frame it as "security as a quality gate with a time budget".
Q4 A SAST tool reports 2,000 findings on a legacy repo the first time you run it. How do you introduce it without freezing delivery?
Intermediate
Situation read โ Blocking on 2,000 old findings guarantees the tool gets switched off.
What I'd do โ
- Baseline: record current findings as accepted debt (
semgrep cibaseline commit, or CodeQL "new alerts only" on PRs). - Gate only on new findings of High/Critical severity.
- Triage the baseline by exploitability: injection, auth and crypto first, style issues last.
- Create a burn-down target per sprint, owned by the team that owns the code.
- Turn off noisy rules with written justification.
Why โ You stop the bleeding first, then pay down debt at a rate the team can sustain.
Interview tip โ "Block new, burn down old" is the phrase interviewers like.
Q5 A developer insists a scanner finding is a false positive. What is your process?
Beginner
Situation read โ Both extremes are bad: ignoring all developer claims, and accepting them without evidence.
What I'd do โ
- Ask the developer to explain why in the PR (data flow, sanitisation, unreachable code).
- A security engineer or champion reviews and confirms.
- Record the suppression in code with a reason and expiry, for example
// nosemgrep: rule-id -- input validated in X, review 2026-03. - Track suppressions in a report so they can be audited.
- If a rule is wrong repeatedly, tune or disable the rule centrally.
Why โ Suppressions without a reason become hidden vulnerabilities.
Interview tip โ Say "suppression needs a reviewer and an expiry date".
Q6 SCA flags a critical CVE in a transitive dependency and no patched version exists. What are your options?
Intermediate
Situation read โ The question is whether the vulnerable code path is reachable, not just whether the package is present.
What I'd do โ
- Check reachability: read the advisory for the affected function and grep your usage. Tools such as
govulncheckdo this for Go. - Look for a newer major version or an alternative library; use overrides (
npm overrides, MavendependencyManagement,go.mod replace). - Add a compensating control such as a WAF rule or input validation if reachable.
- If unreachable, document a VEX statement (
not_affected,vulnerable_code_not_in_execute_path) and an expiry. - Open an issue upstream and set a review date.
Why โ You manage risk with evidence instead of blocking the release over a theoretical issue.
Interview tip โ Mention VEX; most candidates do not.
Q7 Developers bypass your pre-commit secret scan with git commit --no-verify. How do you close the gap?
Intermediate
git commit --no-verify. How do you close the gap?Situation read โ Client-side hooks are advice, not enforcement. They can always be skipped.
What I'd do โ
- Keep the pre-commit hook for fast feedback (
pre-commitframework with gitleaks). - Enforce the same scan in CI as a required status check on the protected branch.
- Turn on server-side push protection (GitHub secret scanning push protection, GitLab push rules).
- Run a scheduled full-history scan across all repos.
Why โ Defence in depth: the hook helps the honest developer, the server-side control stops the rest.
Interview tip โ "Never rely on client-side controls for enforcement."
Q8 You must introduce DAST against a staging web app that shares a database with other teams. How do you do it safely?
Intermediate
Situation read โ Active scans send attack payloads and can create junk data or lock accounts. Shared data makes the blast radius bigger.
What I'd do โ
- Start with passive baseline mode:
docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://staging.example.com -r report.html. - Get a dedicated test environment or isolated schema for active scans.
- Use test accounts with an authentication script; exclude logout and destructive URLs.
- Run active scans (
zap-full-scan.py) only in a window, with rate limits. - Feed results into the same triage queue as SAST.
Why โ Passive scans find missing headers and cookie flags at no risk. Active scans need a safe sandbox.
Interview tip โ Say you always get written approval and a scope before active scanning.
Q9 A small startup has no security budget. Which free tooling gives the best coverage first?
Beginner
Situation read โ Pick open-source tools that cover the most common breaches: leaked secrets, vulnerable dependencies, vulnerable images and misconfigured IaC.
What I'd do โ
gitleaksfor secrets.trivyfor dependencies, images, IaC and secrets in one binary.semgrepcommunity rules for SAST.OWASP ZAPbaseline against staging.- Enable free platform features: Dependabot, GitHub secret scanning, branch protection, MFA.
Why โ These five items cover most real-world incidents at zero licence cost.
Interview tip โ Cost is a design constraint, not an excuse; show you can phase the programme.
Q10 A secret exists in the git history of an 8-year-old monorepo with 400 contributors. Do you rewrite history?
Advanced
Situation read โ The secret is already compromised. Rewriting history is cleanup, not remediation.
What I'd do โ
- Rotate the credential first and confirm the old one is dead.
- Search access logs for use of the old credential during its exposure window.
- Decide on rewriting: for an internal repo with a rotated secret, I usually do not rewrite, because it breaks 400 clones and open PRs.
- If the secret is highly sensitive or the repo is public, rewrite with
git filter-repo --replace-text expressions.txt, force-push, ask GitHub to purge cached views, and have everyone re-clone. - Add scanning to prevent recurrence.
Why โ Rotation removes the risk. History rewriting reduces noise and future scanner alerts at a high coordination cost.
Interview tip โ Lead with "rotate first".
Q11 How do you decide which findings should block a build and which should only warn?
Intermediate
Situation read โ A gate policy needs to be simple enough that every developer can predict the result.
What I'd do โ
- Block: verified secrets, Critical/High SCA with a fix available, new High SAST findings, Critical IaC misconfigurations (public buckets, open 0.0.0.0/0 on SSH).
- Warn: Medium and Low, issues with no fix, old baseline findings.
- Implement with exit codes:
trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 app:1.2.3. - Review the policy quarterly with the engineering leads.
- Provide an exception process with owner and expiry.
Why โ --ignore-unfixed avoids blocking on things nobody can fix today.
Interview tip โ Mention that policy lives in code, versioned and reviewed.
Q12 Renovate or Dependabot floods the team with 60 PRs a week. How do you make it sustainable?
Intermediate
Situation read โ The tool is working, the configuration is not. Noise causes ignored PRs.
What I'd do โ
- Group updates (Renovate
groupName, Dependabotgroups) per ecosystem or per week. - Auto-merge patch and minor updates when tests pass.
- Schedule runs, for example Monday morning only.
- Raise security updates immediately, regular updates weekly.
- Limit open PRs (
open-pull-requests-limitin Dependabot,prConcurrentLimitin Renovate).
Why โ Small frequent updates are safer than one big upgrade after two years.
Interview tip โ Auto-merge needs a solid test suite; say that out loud.
Q13 A team writes Python, Go and Java. Which SAST tools do you pick and why?
Beginner
Situation read โ Prefer one multi-language tool plus language-specific depth where it pays off.
What I'd do โ
semgrepas the common layer across all three languages.banditfor Python,gosecandgovulncheckfor Go, SpotBugs with the Find Security Bugs plugin for Java.- CodeQL if the code is on GitHub (free for public repos, licensed for private).
- Normalise output as SARIF and upload to one dashboard.
Why โ One consistent workflow reduces training, while language tools catch idioms generic rules miss.
Interview tip โ Mention SARIF as the interchange format.
Q14 Full SAST on a large monorepo takes 40 minutes. How do you cut it?
Advanced
Situation read โ Full scans on every PR are wasteful. Most changes touch a small part of the tree.
What I'd do โ
- Diff-aware scans on PRs (
semgrep ciwith--baseline-commit). - Path filters in the pipeline so only affected services are scanned.
- Shard by directory in parallel jobs.
- Run a full scan nightly on the default branch and track new findings there.
- For CodeQL, use incremental analysis and cache the database where supported.
Why โ PR scans need speed, nightly scans need completeness. Splitting them keeps both.
Interview tip โ Tie the answer to developer wait time as a measurable metric.
Q15 Findings live in five different tools and nobody has a single view. What do you build?
Intermediate
Situation read โ Scattered findings mean duplicates, no ownership and no metrics.
What I'd do โ
- Standardise on SARIF for code scanners and CycloneDX or SPDX for SBOMs.
- Import everything into one vulnerability management tool (DefectDojo, or GitHub Advanced Security code scanning for simple setups).
- Deduplicate by fingerprint and map each finding to a service and a team owner.
- Auto-create tickets in Jira with SLAs per severity.
- Build a dashboard: open by severity, age, MTTR, SLA breaches.
Why โ Without ownership and SLAs, findings are just a list.
Interview tip โ Mention MTTR as the key metric.
Q16 How do you secure a GitHub Actions workflow that uses many third-party actions?
Intermediate
Situation read โ A compromised action runs with your secrets. Tag references like @v3 can be moved by the owner or an attacker.
What I'd do โ
- Pin third-party actions to a full commit SHA with a comment for the version:
uses: actions/checkout@<40-char-sha> # v4. - Set least-privilege
permissions:at the workflow top, for examplecontents: read. - Allow only approved actions in org settings.
- Use Dependabot or Renovate to bump the SHAs.
- Use OIDC to cloud instead of long-lived keys.
Why โ A SHA is immutable, a tag is not.
Interview tip โ Cite the tj-actions/changed-files incident of March 2025 as a real example.
Q17 A workflow using pull_request_target checks out the PR head and runs tests. Why is this dangerous and what do you change?
Advanced
pull_request_target checks out the PR head and runs tests. Why is this dangerous and what do you change?Situation read โ pull_request_target runs in the context of the base repo with secrets and a write token. Checking out untrusted fork code and executing it hands those to an attacker.
What I'd do โ
- Switch to
pull_requestfor building and testing fork code; it has no secrets and a read-only token. - If you need privileged steps (labeling, comments), split into two workflows: untrusted build uploads an artifact, a second
workflow_runworkflow reads it as data only. - Never interpolate PR titles or branch names directly in
run:; pass them throughenv:. - Set
permissions:to the minimum.
Why โ Untrusted code plus secrets is the root of most Actions compromises.
Interview tip โ Name "pwn request" as the attack class.
Q18 A critical hotfix is blocked by a security gate at 2 a.m. What is your break-glass process?
Beginner
Situation read โ Gates must not become outage amplifiers, but bypasses must be visible.
What I'd do โ
- A named on-call lead approves an override through a documented path (a protected label or a manual approval environment).
- The override is logged automatically with who, why and which finding.
- The fix ships; a follow-up ticket with a 48-hour SLA closes the finding.
- Review all overrides weekly.
Why โ You trade a controlled risk for availability, and you keep an audit trail.
Interview tip โ "Break-glass, logged, reviewed" is the whole answer.
Q19 A licence scan shows a GPL-3.0 library inside your proprietary SaaS product. What now?
Intermediate
Situation read โ Whether GPL obligations trigger depends on distribution, linking and the exact licence. This is a legal call, but engineering provides facts.
What I'd do โ
- Identify how it is used: linked into the shipped binary, a separate process, a build tool only, or never distributed (SaaS).
- Escalate to legal with the SBOM entry and usage details.
- Meanwhile, find a permissive alternative (MIT, Apache-2.0) or isolate behind a network boundary.
- Add a licence policy to CI:
trivy fs --scanners license --severity HIGH .orlicensee/ScanCode. - Keep an allow/deny list owned by legal.
Why โ AGPL is the one that reaches SaaS; plain GPL generally triggers on distribution.
Interview tip โ Do not give legal conclusions; say you provide evidence and the policy engine.
Q20 How do you add API security testing to a pipeline for a REST service with an OpenAPI spec?
Intermediate
Situation read โ The spec lets a scanner know every endpoint, so crawling is not needed.
What I'd do โ
- Lint the spec for security issues (
spectralwith an OWASP ruleset). - Deploy to an ephemeral environment.
- Run
zap-api-scan.py -t https://api.stg.example.com/openapi.json -f openapi -r api.htmlwith an auth header. - Add contract-based fuzzing (
schemathesis run) for unexpected inputs. - Test authorization separately: two users, check one cannot read the other's object (BOLA).
Why โ Generic scanners are weak at authorization bugs, so you need explicit tests for them.
Interview tip โ Say BOLA is the top API risk in the OWASP API Top 10.
Q21 How do you harden self-hosted CI runners?
Advanced
Situation read โ A persistent runner shared between repos is a lateral-movement path: one bad job can leave malware or steal tokens for the next.
What I'd do โ
- Use ephemeral runners (one job per VM or pod, destroyed afterwards), for example Actions Runner Controller on Kubernetes.
- Never attach self-hosted runners to public repos.
- Give each runner minimal cloud permissions through short-lived credentials and IMDSv2 with hop limit 1.
- Network egress allowlist; no access to production networks.
- Separate runner groups per trust level.
- Patch the base image regularly and log all job activity.
Why โ Ephemeral runners remove persistence, which is the main attacker advantage.
Interview tip โ Mention that docker.sock mounts equal root on the host.
Q22 How do you prove to leadership that the DevSecOps programme works?
Beginner
Situation read โ Leadership cares about risk reduction and delivery speed, not number of scans.
What I'd do โ
- Track mean time to remediate by severity and the share of findings fixed within SLA.
- Track the count of critical vulnerabilities reaching production.
- Track coverage: percent of repos with secrets, SAST and SCA enabled.
- Track pipeline time added and the false-positive rate.
- Report trends monthly, not snapshots.
Why โ Trend lines show improvement, and coverage shows blind spots.
Interview tip โ Include a developer-experience metric; it shows maturity.
Q23 Your company bans a specific unsafe internal helper function. How do you enforce it automatically?
Intermediate
Situation read โ This is a custom SAST rule, which is cheap with Semgrep.
What I'd do โ
- Write a rule:
rules:
- id: no-legacy-exec-helper
languages: [python]
severity: ERROR
message: "legacy_exec() is banned, use safe_run() instead"
pattern: legacy_exec(...)- Test it with
semgrep --testusing annotated test files. - Publish it in a shared rules repo and run it in all pipelines:
semgrep ci --config ./rules. - Announce with a migration guide and an autofix where possible (
fix:).
Why โ Codifying lessons from incidents means the same bug cannot return.
Interview tip โ Mention rules as code with unit tests.
Q24 An org-wide secret scan finds 5,000 hits. How do you prioritise?
Advanced
Situation read โ Most hits are test fixtures and expired tokens. Treating all as equal burns the team out.
What I'd do โ
- Re-run with verification:
trufflehog git file://. --only-verifiedto confirm which credentials are live. - Rank by blast radius: cloud admin keys, production DB credentials, signing keys, then SaaS tokens.
- Prioritise public and widely-accessible repos.
- Rotate first, clean history later.
- Assign owners through CODEOWNERS and track in tickets with SLAs.
- Add push protection to stop new ones.
Why โ Verified live secrets are incidents; unverified ones are hygiene.
Interview tip โ "Verified first, then by blast radius."
Q25 How do you integrate threat modelling into a two-week sprint without slowing the team?
Intermediate
Situation read โ Heavy threat modelling workshops do not survive agile cadence. It needs to be small and triggered.
What I'd do โ
- Trigger it only for changes with new trust boundaries: new service, new data type, new external integration, auth changes.
- Use a 30-minute session with a simple data flow diagram and STRIDE prompts.
- Capture threats as backlog tickets with acceptance criteria.
- Keep diagrams as code (Mermaid or a Threat Dragon file) in the repo.
- Security champions facilitate so the security team is not a bottleneck.
Why โ Lightweight, repeated modelling finds design flaws that no scanner will.
Interview tip โ Say "design flaws need design-time review".
Container and IaC Security
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q26 A team asks whether to use ubuntu, alpine or a distroless base image. How do you advise?
Beginner
ubuntu, alpine or a distroless base image. How do you advise?Situation read โ Fewer packages means fewer CVEs and less attacker tooling, but also harder debugging.
What I'd do โ
- Recommend distroless or a minimal Chainguard/Wolfi-style image for production services in compiled languages.
- Use Alpine when the team needs a shell and a package manager, and accept musl compatibility quirks.
- Use Ubuntu or Debian slim only when software needs glibc and many system libraries.
- Pair with multi-stage builds so compilers never reach the runtime image.
- Debug with
kubectl debugephemeral containers instead of baking in a shell.
Why โ Attack surface scales with the number of installed packages.
Interview tip โ Mention that smaller does not mean automatically patched; you still rescan.
Q27 trivy image shows 300 vulnerabilities in your app image. How do you bring this down?
Beginner
trivy image shows 300 vulnerabilities in your app image. How do you bring this down?Situation read โ Most findings come from the OS layer and unused packages, not your code.
What I'd do โ
- Group by layer and package:
trivy image --format table app:1.0. - Switch to a smaller, regularly rebuilt base image.
- Remove packages you do not need (
apt-get purge, no curl/wget in final image). - Rebuild weekly to pick up base image patches.
- Filter on actionable items:
--severity HIGH,CRITICAL --ignore-unfixed.
Why โ One base image switch often removes 80% of findings.
Interview tip โ Say you prioritise fixable and exploitable findings, not raw counts.
Q28 A Dockerfile runs the app as root. How do you fix it and prove the fix?
Intermediate
Situation read โ Root in a container increases the impact of any breakout or volume misconfiguration.
What I'd do โ
- Create a user and switch to it:
RUN addgroup -S app && adduser -S app -G app
USER 10001:10001- Use a numeric UID so Kubernetes
runAsNonRootcan verify it. - Set
securityContext: runAsNonRoot: true, allowPrivilegeEscalation: false, capabilities.drop: [ALL]. - Enforce with Hadolint rule DL3002 and a Kyverno or PSA policy.
- Verify:
docker run --rm app:1.0 idshows non-zero uid.
Why โ Numeric UID matters: kubelet cannot validate a named user.
Interview tip โ Mention that ports below 1024 need NET_BIND_SERVICE or a higher port.
Q29 Checkov fails a Terraform PR because an S3 bucket allows public access. What do you change?
Beginner
Situation read โ A public bucket is one of the most common causes of data leaks.
What I'd do โ
- Add a public access block:
resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.this.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}- Enable default encryption and versioning.
- If the bucket must serve public web content, use CloudFront with Origin Access Control instead.
- Enforce account-wide with S3 Block Public Access at account level.
Why โ Block Public Access overrides any ACL or policy mistake.
Interview tip โ Mention account-level block as the guardrail behind the resource-level fix.
Q30 How do you set up image scanning so nothing vulnerable reaches production?
Intermediate
Situation read โ Scanning in CI alone is not enough, since images can be pushed from elsewhere and age after the build.
What I'd do โ
- Scan in CI and fail on policy:
trivy image --exit-code 1 --severity CRITICAL --ignore-unfixed $IMAGE. - Enable registry scanning (ECR enhanced scanning, Harbor with Trivy) for continuous rescans.
- Allow only images from your registry via admission policy.
- Require a signature and attestation of a passed scan at admission (Kyverno
verifyImages). - Alert on new CVEs for images already deployed.
Why โ The build-time gate stops bad images, admission stops bypasses, continuous scan handles aging.
Interview tip โ Describe it as three layers: build, registry, cluster.
Q31 An image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?
Intermediate
Situation read โ Vulnerability data changes daily. A clean scan is a point-in-time statement.
What I'd do โ
- Rely on stored SBOMs: query them for the affected package (
grype sbom:./sbom.jsonor your inventory DB). - List running workloads using the image digest:
kubectl get pods -A -o jsonpath='{..image}'. - Assess exploitability, internet exposure and available fix.
- Rebuild with the patched base, run tests, and roll out via the normal pipeline.
- Add temporary mitigation (WAF rule, network restriction) if the fix takes days.
Why โ SBOM-based lookup answers "are we affected" in minutes instead of hours.
Interview tip โ Log4Shell is the example everyone remembers.
Q32 You find ENV DB_PASSWORD=... and ARG NPM_TOKEN in a Dockerfile. What is wrong and how do you fix it?
Beginner
ENV DB_PASSWORD=... and ARG NPM_TOKEN in a Dockerfile. What is wrong and how do you fix it?Situation read โ Values baked into ENV ship in every layer's metadata. ARG values show in docker history.
What I'd do โ
- Remove the values and rotate the exposed secrets.
- Use BuildKit secret mounts for build-time secrets:
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm cidocker build --secret id=npmrc,src=$HOME/.npmrc -t app:1.0 .- Inject runtime secrets from Kubernetes Secrets, Vault or Secrets Manager.
- Scan images for secrets:
trivy image --scanners secret app:1.0.
Why โ Secret mounts are not stored in any image layer.
Interview tip โ Say "build secrets via mounts, runtime secrets via the platform".
Q33 Why and how do you use multi-stage builds from a security point of view?
Intermediate
Situation read โ Build tools, source code and caches in the final image add CVEs and help an attacker.
What I'd do โ
- Build in one stage, copy only the artifact to a minimal final stage:
FROM golang:1.23 AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -o /out/app ./cmd/app
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/app /app
ENTRYPOINT ["/app"]- Pin base images by digest.
- Keep
.dockerignorestrict (.git,.env,*.pem).
Why โ The final image contains only what runs.
Interview tip โ Mention .dockerignore as a common source of leaked files.
Q34 How do you reduce the chance of container escape on a shared node pool?
Advanced
Situation read โ Containers share the host kernel. Escapes use dangerous capabilities, privileged mode, host mounts or kernel bugs.
What I'd do โ
- Forbid
privileged,hostPID,hostNetwork, hostPath and dangerous capabilities (PSArestricted). - Drop all capabilities, add back only what is needed; enable
seccompProfile: RuntimeDefault. - Use read-only root FS and non-root users.
- Keep the node OS patched, use a container-optimised OS (Bottlerocket, Flatcar).
- For untrusted workloads use sandboxed runtimes (gVisor, Kata Containers) via
RuntimeClass. - Detect with Falco rules for shell in container and sensitive mounts.
Why โ Layers: restrict the process, restrict the kernel interface, isolate the kernel when trust is low.
Interview tip โ Name seccomp, AppArmor and user namespaces.
Q35 Terraform state contains database passwords in plain text. How do you handle it?
Intermediate
Situation read โ State stores resource attributes, including sensitive ones, even if marked sensitive = true in outputs.
What I'd do โ
- Use a remote backend with encryption and versioning: S3 with SSE-KMS, bucket policy restricting principals, DynamoDB or S3 native lockfile.
- Restrict read access to state to the CI role and a few admins.
- Avoid creating secrets in Terraform: use
manage_master_user_password = truefor RDS or reference Secrets Manager. - Enable ephemeral resources/values on Terraform 1.10+ where supported.
- Audit access through CloudTrail data events.
Why โ State is as sensitive as the secrets inside it.
Interview tip โ Note that sensitive = true hides CLI output only.
Q36 How do you enforce "no public RDS, encryption on" for all Terraform changes across teams?
Intermediate
Situation read โ Per-team review does not scale. Put the rules in code that runs against the plan.
What I'd do โ
- Produce a plan JSON:
terraform plan -out tfplan && terraform show -json tfplan > plan.json. - Evaluate with OPA/conftest:
package terraform
deny[msg] {
r := input.resource_changes[_]
r.type == "aws_db_instance"
r.change.after.publicly_accessible == true
msg := sprintf("%s must not be public", [r.address])
}- Run
conftest test plan.jsonas a required check. - Backstop with AWS SCPs or Config rules for anything created outside Terraform.
Why โ Plan-time checks give fast feedback, SCPs give hard enforcement.
Interview tip โ Say "shift-left check plus cloud-side backstop".
Q37 A security group allows 0.0.0.0/0 on port 22. How do you fix it properly?
Beginner
0.0.0.0/0 on port 22. How do you fix it properly?Situation read โ Internet-exposed SSH is scanned and brute-forced constantly.
What I'd do โ
- Remove the rule:
aws ec2 revoke-security-group-ingress --group-id sg-... --protocol tcp --port 22 --cidr 0.0.0.0/0. - Replace admin access with AWS Systems Manager Session Manager (no inbound port, IAM-authenticated, logged).
- If SSH is unavoidable, restrict to a bastion or VPN CIDR.
- Add a Config rule
restricted-sshand a Checkov check to prevent regressions.
Why โ No open port means nothing to scan.
Interview tip โ Session Manager is the answer most interviewers want.
Q38 A manifest uses image: myapp:latest. Why is this a security problem and what do you use instead?
Intermediate
image: myapp:latest. Why is this a security problem and what do you use instead?Situation read โ latest is mutable. You cannot tell what runs, cannot roll back reliably, and cannot link a running pod to a scan or signature.
What I'd do โ
- Tag with an immutable version or commit SHA, and enable tag immutability in the registry (ECR
imageTagMutability=IMMUTABLE). - Deploy by digest:
image: registry.example.com/myapp@sha256:.... - Enforce with a Kyverno policy that rejects
:latestand tags without digest. - Let GitOps tooling (Argo CD Image Updater, Renovate) bump digests through PRs.
Why โ Digests make deployments reproducible and verifiable.
Interview tip โ Signatures and scan results are tied to digests, not tags.
Q39 How do you control which images may run in a cluster of 200 teams?
Advanced
Situation read โ You need central policy that does not slow teams down and cannot be bypassed from kubectl.
What I'd do โ
- Allow only approved registries via admission control (Kyverno or Gatekeeper).
- Require cosign signatures from the CI identity using keyless verification:
verifyImages:
- imageReferences: ["registry.example.com/*"]
attestors:
- entries:
- keyless:
issuer: https://token.actions.githubusercontent.com
subject: https://github.com/example-org/*- Roll out in
Auditmode first, publish reports, then switch toEnforce. - Provide exemptions by namespace label with expiry.
Why โ Admission is the last gate before execution.
Interview tip โ Mention audit-before-enforce rollout.
Q40 Someone opened a security group manually in the console, bypassing Terraform. How do you detect and prevent it?
Intermediate
Situation read โ Drift means your reviewed code is no longer the truth.
What I'd do โ
- Detect: scheduled
terraform plan -detailed-exitcode(exit 2 means changes) and AWS Config rules. - Alert via CloudTrail and EventBridge on
AuthorizeSecurityGroupIngressfrom non-pipeline principals. - Remediate: re-apply Terraform, or auto-remediate with Config and SSM Automation.
- Prevent: remove write permissions from humans, use read-only console roles plus a break-glass role, add SCPs.
Why โ If humans cannot change prod directly, drift becomes rare.
Interview tip โ "Detect, remediate, then remove the permission that allowed it."
Q41 A developer pulls a random image from Docker Hub for a database tool. How do you decide if it is acceptable?
Beginner
Situation read โ Unknown images can contain miners, backdoors or outdated software.
What I'd do โ
- Prefer Docker Official Images, Verified Publisher or Docker-Sponsored Open Source.
- Check the Dockerfile source and update frequency.
- Scan it:
trivy image publisher/tool:1.2. - Mirror approved images into the internal registry and pin by digest.
- Block direct pulls from public registries in production.
Why โ A curated internal registry gives one place for scanning and control.
Interview tip โ Mention pull-through caches as the practical approach.
Q42 A CI job mounts /var/run/docker.sock into a container to build images. Is that acceptable?
Intermediate
/var/run/docker.sock into a container to build images. Is that acceptable?Situation read โ Docker socket access equals root on the host. Any process in that container can start a privileged container.
What I'd do โ
- Replace with daemonless builders: BuildKit rootless, Kaniko, Buildah or ko.
- If you must use Docker, run on ephemeral VMs isolated from other workloads.
- Never share the socket on runners that build untrusted code from forks.
- Add a policy rule that rejects hostPath mounts of the socket.
Why โ You remove the privilege instead of trying to monitor it.
Interview tip โ Note Kaniko is now archived upstream; mention BuildKit or Buildah as current options.
Q43 You must run customer-submitted code in your platform. What isolation do you choose?
Advanced
Situation read โ Standard containers share a kernel, which is not a strong enough boundary for hostile code.
What I'd do โ
- Use microVMs (Firecracker, Kata Containers) or a user-space kernel (gVisor) through a Kubernetes
RuntimeClass. - Place them on a dedicated node pool with taints.
- Deny egress by default with NetworkPolicy; allow only needed endpoints.
- Set CPU, memory, pid and time limits; short-lived pods.
- No cloud credentials: block IMDS and use no service account token (
automountServiceAccountToken: false).
Why โ Defence rests on the smallest possible kernel attack surface plus no useful credentials.
Interview tip โ Compare the trade-off: gVisor has syscall overhead, Kata needs virtualisation.
Q44 How do you scan Helm charts and Kubernetes manifests before deployment?
Intermediate
Situation read โ Misconfigurations like privileged pods and missing limits are easiest to catch before they hit the cluster.
What I'd do โ
- Render the chart:
helm template myapp ./chart -f values-prod.yaml > rendered.yaml. - Scan:
trivy config rendered.yaml,kubesec scan, orcheckov -f rendered.yaml. - Validate schema with
kubeconform -strict. - Evaluate custom rules with conftest or Kyverno CLI (
kyverno apply policy.yaml --resource rendered.yaml). - Run on every PR and block on high severity.
Why โ Scanning rendered output tests what is actually applied, not just templates.
Interview tip โ Scan with the production values file; defaults can hide problems.
Q45 What does Hadolint do and how do you use it in a pipeline?
Beginner
Situation read โ Hadolint lints Dockerfiles for bad practices, and embeds ShellCheck for RUN lines.
What I'd do โ
- Run locally or in CI:
hadolint Dockerfileordocker run --rm -i hadolint/hadolint < Dockerfile. - Fail on warnings and above:
hadolint --failure-threshold warning Dockerfile. - Store exceptions in
.hadolint.yamlwith comments. - Typical catches: missing
USER(DL3002), unpinned versions (DL3008),ADDinstead ofCOPY(DL3020).
Why โ It is fast and catches issues before the image is even built.
Interview tip โ Pair it with image scanning; they find different problems.
Q46 Checkov reports a failure in a shared Terraform module you cannot change this sprint. How do you handle it?
Intermediate
Situation read โ Do not disable the whole check. Accept narrowly, with an owner and a date.
What I'd do โ
- Suppress inline with a reason:
#checkov:skip=CKV_AWS_144:Cross-region replication not required for logs, ticket SEC-412. - Or use a baseline file:
checkov -d . --create-baselinethen--baseline .checkov.baseline. - File a ticket against the module owner with a due date.
- Report skips in a monthly review.
Why โ Narrow, documented exceptions keep the gate meaningful.
Interview tip โ Every exception should answer "who owns it and when does it expire".
Q47 How do you ensure all new EBS volumes and RDS instances are encrypted, even if a team forgets?
Intermediate
Situation read โ Rely on defaults and guardrails, not on remembering.
What I'd do โ
- Turn on EBS encryption by default per region:
aws ec2 enable-ebs-encryption-by-default. - Use IaC modules where
storage_encrypted = trueis hard-coded. - Add an SCP denying
rds:CreateDBInstancewhenrds:StorageEncryptedis false. - Add AWS Config rules (
encrypted-volumes,rds-storage-encrypted) with auto-remediation or alerts. - Use customer managed KMS keys for sensitive data with key policies.
Why โ Preventive controls beat detective ones; you want both.
Interview tip โ Remember that you cannot encrypt an existing unencrypted RDS instance in place; you restore from an encrypted snapshot copy.
Q48 As platform lead, how do you design guardrails so teams can self-serve infrastructure safely?
Advanced
Situation read โ You want speed without the security team reviewing every change.
What I'd do โ
- Offer golden Terraform modules with secure defaults (encryption, logging, private networking).
- Enforce policy as code in CI (OPA, Checkov) for custom resources.
- Apply cloud-level preventive controls: SCPs, permission boundaries, tag policies.
- Give teams scoped accounts or namespaces; central logging and Security Hub aggregation.
- Provide paved-road templates with CI, scanning and signing preconfigured.
- Measure adoption and exception rate.
Why โ The easiest path should also be the secure path.
Interview tip โ Use the phrase "paved road" and "guardrails, not gates".
Q49 A team wants a privileged container for Docker-in-Docker builds in Kubernetes CI. What do you offer instead?
Beginner
Situation read โ Privileged pods can break out to the node. The need is to build images, not to run Docker.
What I'd do โ
- Use BuildKit in rootless mode or Buildah in an unprivileged pod.
- Use a remote builder service (BuildKit daemon, cloud build) outside the cluster.
- Run builders on a separate, tainted node pool with no production credentials.
- Block
privileged: truethrough admission policy elsewhere.
Why โ Moving builds off shared nodes isolates the risk.
Interview tip โ Say you replace the tool instead of granting the privilege.
Q50 After enabling readOnlyRootFilesystem: true, the app crashes writing to /tmp. How do you proceed?
Intermediate
readOnlyRootFilesystem: true, the app crashes writing to /tmp. How do you proceed?Situation read โ Read-only root is a good control; the app just needs explicit writable paths.
What I'd do โ
- Find the writes:
kubectl logsshowsRead-only file systemerrors with the path. - Mount
emptyDirat the needed paths:
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}- Redirect caches and logs to stdout or those mounts.
- Keep
readOnlyRootFilesystem: true.
Why โ An attacker cannot drop binaries into the image filesystem.
Interview tip โ Do not remove the control to fix the symptom.
Supply Chain Security
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q51 What is an SBOM, and at which point in the pipeline do you generate it?
Beginner
Situation read โ An SBOM is an inventory of components in a build artifact. It makes "are we affected by CVE-X" a query instead of an investigation.
What I'd do โ
- Generate it from the final image, because that is what ships:
syft app:1.0 -o cyclonedx-json > sbom.cdx.json. - Do it in CI right after the image build, once per release.
- Store it next to the image in the registry as an attestation (
cosign attest --type cyclonedx). - Index SBOMs centrally (Dependency-Track) for continuous matching.
Why โ Generating from the built image captures OS packages and copied binaries, not only lockfile entries.
Interview tip โ An SBOM is data; value comes from continuous matching against new CVEs.
Q52 A customer asks for an SBOM for your product. What do you give them?
Beginner
Situation read โ Customers want a machine-readable list they can import into their tooling.
What I'd do โ
- Provide CycloneDX or SPDX JSON per release, generated by
syftortrivy image --format cyclonedx. - Sign it so they can verify authenticity.
- Include a VEX document to say which listed CVEs do not affect you.
- Review for internal-only package names or paths before sharing.
- Publish it through a customer portal or release assets.
Why โ SBOM plus VEX reduces back-and-forth about scanner noise.
Interview tip โ Mention that regulations such as US EO 14028 and the EU Cyber Resilience Act push this.
Q53 How do you sign container images in GitHub Actions without managing private keys?
Intermediate
Situation read โ Keyless signing with Sigstore uses the workflow's OIDC identity and a short-lived certificate from Fulcio.
What I'd do โ
- Grant the job
id-token: writeandpackages: write. - Install cosign (
sigstore/cosign-installer) and sign by digest:
cosign sign --yes ghcr.io/example-org/app@sha256:<digest>- Record the signature in the Rekor transparency log (automatic).
- Verify with identity constraints:
cosign verify ghcr.io/example-org/app@sha256:<digest> \
--certificate-identity-regexp 'https://github.com/example-org/app/.github/workflows/release.yml@.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.comWhy โ No long-lived key means no key to steal.
Interview tip โ Sign the digest, never the tag.
Q54 You signed images in CI. How do you make sure the cluster only runs signed images?
Intermediate
Situation read โ Signing without verification is decoration. Verification must happen at admission.
What I'd do โ
- Deploy Kyverno (
verifyImages) or the Sigstore policy-controller. - Define the trusted identity (issuer and subject) as in the signing pipeline.
- Start with
validationFailureAction: Audit, review violations, thenEnforce. - Use
mutateDigest: trueto rewrite tags to digests. - Exempt system namespaces with explicit rules.
Why โ Admission control covers deployments from any source, including manual kubectl.
Interview tip โ Mention that you also verify attestations, such as SBOM and scan results.
Q55 Leadership wants "SLSA compliance". What do you propose?
Intermediate
Situation read โ SLSA is a maturity framework for build integrity. The Build track has levels 1 to 3.
What I'd do โ
- Level 1: build is scripted and produces provenance.
- Level 2: build on a hosted service that signs the provenance (GitHub Actions with
actions/attest-build-provenance). - Level 3: isolated, non-forgeable builds; use reusable workflows or
slsa-github-generatorso the build definition is separated from the project. - Verify provenance at deploy with
slsa-verifierorgh attestation verify. - Pick one critical service first and expand.
Why โ Provenance proves what source, builder and inputs produced the artifact.
Interview tip โ State a realistic target, usually L2 first, L3 for crown jewels.
Q56 What is typosquatting and how do you protect developers from it?
Beginner
Situation read โ Attackers publish packages with names near popular ones (reqeusts, colourama) hoping for a typo.
What I'd do โ
- Use a private registry proxy and only allow packages through it.
- Review new dependencies in PRs; require approval for new packages.
- Use SCA tools that flag new or low-reputation packages (Socket, OpenSSF Scorecard).
- Install from lockfiles only, with integrity hashes.
- Train developers to copy names from the official docs.
Why โ A proxy and review step turns a silent typo into a visible event.
Interview tip โ Mention install scripts as the typical payload trigger.
Q57 Your internal package acme-utils exists in a private registry. How do you prevent dependency confusion?
Advanced
acme-utils exists in a private registry. How do you prevent dependency confusion?Situation read โ If the package manager checks a public registry too, an attacker can publish acme-utils with a higher version and win resolution.
What I'd do โ
- Use scoped or namespaced names: npm
@acme/utils; register the scope publicly as well. - Configure the client to route the scope to the private registry:
@acme:registry=https://npm.acme.internal/. - In pip, avoid
--extra-index-url; use a single proxy index with exclusion rules. - In Maven/Gradle, use repository content filtering for the group.
- Use lockfiles with hashes and block resolution of internal names from public upstream in Artifactory or Nexus.
Why โ Namespace ownership and a single resolution path remove the ambiguity.
Interview tip โ Cite Alex Birsan's 2021 research as the origin.
Q58 Why do you use npm ci and lockfiles in CI, and what does it protect against?
Intermediate
npm ci and lockfiles in CI, and what does it protect against?Situation read โ npm install may update versions, so two builds of the same commit can differ.
What I'd do โ
- Commit
package-lock.json,poetry.lock,go.sum,Cargo.lock. - In CI use
npm ci(fails if the lockfile does not matchpackage.json),pip install --require-hashes -r requirements.txt,go mod verify. - Review lockfile diffs in PRs.
- Block registry-source changes in lockfile with a check.
Why โ Reproducible installs mean a poisoned new release does not enter automatically.
Interview tip โ Lockfile integrity hashes also detect tampered tarballs.
Q59 Should dependencies be pinned to exact versions or use ranges?
Beginner
Situation read โ Ranges give automatic fixes but also automatic breakage and compromise. Pinning gives control but needs update discipline.
What I'd do โ
- Pin exact versions via lockfiles for applications.
- Use ranges in libraries so consumers can resolve.
- Use Renovate or Dependabot to move pins forward with PRs.
- Add a cooldown (Renovate
minimumReleaseAge: "3 days", Dependabotcooldown) so brand-new releases get some time to be flagged.
Why โ A few days of delay avoids most malicious package windows.
Interview tip โ Pin plus automated updates, not pin and forget.
Q60 A widely used open-source library you depend on appears to have a maintainer-injected backdoor, as in the xz case. How do you respond?
Advanced
Situation read โ First establish exposure: which versions, where deployed, whether the malicious path is reachable in your use.
What I'd do โ
- Query SBOMs for affected versions across all services and base images.
- Follow the maintainers and CISA/vendor advisories; pin to a known-good version or roll back.
- Rebuild images from clean sources and redeploy; invalidate build caches.
- Hunt for indicators: unexpected processes, outbound connections, modified binaries (via Falco, EDR, file integrity).
- Rotate credentials accessible from affected hosts if compromise is plausible.
- Afterwards reduce blast radius: fewer SSH-reachable hosts, minimal images.
Why โ Inventory plus rollback speed matter more than predicting the attack.
Interview tip โ xz was caught by a performance anomaly; mention observability as a defence.
Q61 How do you attach scan and test results to an image so later stages can verify them?
Intermediate
Situation read โ Evidence should travel with the artifact and be verifiable, so deploy-time policy can use it.
What I'd do โ
- Produce the result predicate:
trivy image --format cosign-vuln -o vuln.json app@sha256:.... - Attach it:
cosign attest --yes --predicate vuln.json --type vuln app@sha256:.... - At admission, Kyverno
attestationscondition checks the attestation was signed by CI and has no critical findings. - Do the same for SBOM and provenance.
Why โ Policy can say "only images with a recent passing scan from our pipeline may run".
Interview tip โ Attestations are in-toto statements signed with the same identity.
Q62 CycloneDX or SPDX: which do you choose?
Intermediate
Situation read โ Both are accepted standards. The choice depends on consumers.
What I'd do โ
- Use CycloneDX for security use cases: native VEX, services, and wide support in Dependency-Track and Grype.
- Use SPDX where licence compliance or regulatory submissions require it (ISO/IEC 5962).
- Generate both if needed;
syft app:1.0 -o cyclonedx-json -o spdx-json. - Validate with the format's schema and a tool like
sbomqs.
Why โ Pick by consumer requirements, not preference.
Interview tip โ Both are fine; the real question is completeness and accuracy.
Q63 How does a private package proxy (Artifactory, Nexus) improve supply chain security?
Intermediate
Situation read โ Direct pulls from public registries give no control and no audit.
What I'd do โ
- Route all builds through one proxy; block direct egress to public registries from CI.
- Cache packages so builds survive upstream removals (left-pad type incidents).
- Add curation: block known-malicious packages, enforce licence rules, hold new versions for a few days.
- Scan cached artifacts continuously (JFrog Xray, Nexus IQ).
- Log which build pulled which package for incident response.
Why โ One chokepoint gives control, caching and an audit trail.
Interview tip โ Mention egress control, or developers will go around the proxy.
Q64 A new npm worm is stealing tokens through install scripts. What do you change in your pipelines right now?
Advanced
Situation read โ Install-time scripts execute with the CI job's privileges and secrets. Reduce what they can reach.
What I'd do โ
- Disable lifecycle scripts by default:
npm ci --ignore-scripts(allow explicit exceptions for packages needing builds). - Use short-lived tokens; replace long-lived npm publish tokens with trusted publishing (OIDC).
- Run installs in jobs with no cloud or publish credentials; separate install/build from publish.
- Check lockfile versions against the advisory; pin and add a release-age cooldown.
- Search for the published IoCs in repos and runner logs, then rotate any exposed token.
Why โ If scripts cannot reach secrets, a malicious package has little to steal.
Interview tip โ Separate "build with untrusted deps" from "publish with trusted credentials".
Q65 What does --ignore-scripts change, and what breaks when you use it?
Beginner
--ignore-scripts change, and what breaks when you use it?Situation read โ npm runs preinstall, install and postinstall scripts of dependencies by default. They are a popular malware trigger.
What I'd do โ
- Run
npm ci --ignore-scriptsor setignore-scripts=truein.npmrc. - Expect breakage in packages that compile native code or download binaries (
sharp,esbuild,node-gypmodules). - Explicitly rebuild trusted ones:
npm rebuild esbuild. - Document the allowlist in the repo.
Why โ You choose which code runs at install time, instead of every package.
Interview tip โ pnpm 10 disables dependency scripts by default and uses an allowlist.
Q66 How do you generate build provenance for a GitHub Actions release?
Intermediate
Situation read โ Provenance records the repo, commit, workflow and builder identity, signed by the platform.
What I'd do โ
- Add permissions
id-token: write,attestations: write,contents: read. - Use
actions/attest-build-provenancewith the artifact path or image digest:
- uses: actions/attest-build-provenance@<sha>
with:
subject-name: ghcr.io/example-org/app
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true- Verify before deploy:
gh attestation verify oci://ghcr.io/example-org/app@sha256:... --owner example-org.
Why โ Verification links an artifact to a specific repo and workflow.
Interview tip โ Provenance proves origin, not that the code is free of bugs.
Q67 What is a reproducible build and why do security teams care?
Advanced
Situation read โ A build is reproducible if independent builders produce bit-identical output from the same source.
What I'd do โ
- Pin toolchains and base images by digest; avoid network access during build.
- Remove nondeterminism: timestamps (
SOURCE_DATE_EPOCH), file ordering, random IDs, locale. - For Go use
-trimpathand-buildvcs=false; for Docker use BuildKit with--output type=oci,rewrite-timestamp=true. - Rebuild on a second, independent builder and compare digests.
Why โ Matching hashes show the binary was not tampered with in the build system, which was the SolarWinds failure mode.
Interview tip โ Say "hermetic plus deterministic".
Q68 A Dockerfile downloads a binary with curl | sh. How do you make it safe?
Intermediate
curl | sh. How do you make it safe?Situation read โ You are executing whatever the server returns at build time. A compromised URL means a compromised image.
What I'd do โ
- Pin an explicit version in the URL.
- Verify a SHA-256 checksum stored in the repo:
echo "<sha256> tool.tgz" | sha256sum -c -. - Prefer verifying a signature (
cosign verify-blob, GPG) from the publisher. - Better: use a package from your internal proxy, or copy from a pinned image with
COPY --from=.
Why โ A checksum committed in the repo ties the build to a reviewed artifact.
Interview tip โ curl | sh in a Dockerfile is a code review red flag.
Q69 What branch protection settings do you consider the minimum for production repositories?
Intermediate
Situation read โ The repo is the root of trust for everything built from it.
What I'd do โ
- Require pull requests with at least one approval, and dismiss stale approvals on new commits.
- Require code owner review for sensitive paths (
.github/workflows/,terraform/). - Require status checks: tests, SAST, secrets, SCA.
- Disallow force pushes and deletions; include administrators.
- Require signed commits or verified tags for releases where policy needs it.
- Use rulesets and protected environments for deploy approval.
Why โ One person alone cannot push code to production.
Interview tip โ Protect the workflow files with CODEOWNERS; they are code that holds secrets.
Q70 Why do some teams require signed git commits, and what does it prove?
Beginner
Situation read โ Git author names are free text. Anyone can set user.name to your CTO.
What I'd do โ
- Sign with SSH, GPG or Sigstore gitsign:
git config commit.gpgsign trueandgit config gpg.format ssh. - Enable "Require signed commits" in branch rules.
- Register keys on the platform so commits show "Verified".
- Combine with MFA and short-lived credentials.
Why โ It proves the commit came from someone holding the key, not just using an email.
Interview tip โ It proves identity, not that the code is safe; reviews still matter.
Q71 Compare key-based and keyless signing for release artifacts. Which would you use?
Advanced
Situation read โ Both are valid. The decision depends on environment, trust model and operations burden.
What I'd do โ
- Keyless (Sigstore): short-lived certificates bound to OIDC identity, logged in Rekor. Best for public CI such as GitHub Actions. No key rotation.
- KMS-backed keys (
cosign sign --key awskms:///alias/release): key never leaves HSM, works air-gapped, good for regulated environments. - Self-managed key files: avoid; rotation and storage are painful.
- For private deployments, run private Fulcio/Rekor or use KMS keys with strict IAM.
- Verify policy by identity (keyless) or public key (KMS) at admission.
Why โ Keyless reduces key custody risk; KMS gives control where the public Sigstore infrastructure cannot be used.
Interview tip โ Mention transparency logs help detect misuse after the fact.
Q72 What is a VEX and how does it reduce vulnerability noise?
Intermediate
Situation read โ SBOM plus scanner gives many CVEs that do not apply to your product. VEX says which actually do.
What I'd do โ
- Write VEX statements per CVE and product with status:
not_affected,affected,fixed,under_investigation, plus a justification. - Use CycloneDX VEX or OpenVEX (
vexctl create). - Feed it to scanners:
grype --vex vex.json app:1.0,trivy image --vex vex.json app:1.0. - Review statements when code changes.
Why โ Consumers can suppress findings with evidence from the vendor.
Interview tip โ Compare it to a documented false-positive that others can trust.
Q73 How do you evaluate whether a new open-source dependency is safe enough to adopt?
Intermediate
Situation read โ Popularity is not safety. Look at project health and security practices.
What I'd do โ
- Run OpenSSF Scorecard:
scorecard --repo=github.com/org/project. - Check maintainers, release cadence, open security advisories and bus factor.
- Review transitive dependency count and install scripts.
- Check licence compatibility.
- Wrap the library behind your own interface so you can replace it.
- Record the decision in an ADR.
Why โ Cheap vetting up front is better than emergency removal later.
Interview tip โ Mention Scorecard checks such as branch protection, signed releases and pinned dependencies.
Q74 Vendors send you SBOMs for their software. How do you operationalise them?
Advanced
Situation read โ SBOMs sitting in email folders protect no one.
What I'd do โ
- Ingest into Dependency-Track via its API, tagging vendor, product, version and environment.
- Enable continuous matching against NVD, OSV and GitHub advisories; notify owners via webhook or Slack.
- Ask vendors for VEX and for signed SBOMs.
- Add SBOM delivery to procurement and contract requirements with a remediation SLA.
- Review vendor risk quarterly.
Why โ When the next Log4Shell happens, you search by component and know your exposure in minutes.
Interview tip โ Say "ingest, match, notify, contract".
Q75 Why should you "build once, promote the same artifact" across environments?
Intermediate
Situation read โ Rebuilding per environment means production runs something that was never tested or scanned.
What I'd do โ
- Build and push one image tagged with commit SHA, record the digest.
- Scan, sign and attest it once.
- Promote by deploying the same digest through dev, staging and prod via GitOps PRs.
- Keep environment differences in config, not in builds.
- Admission policy checks the signature in every environment.
Why โ What you tested and signed is exactly what runs in production.
Interview tip โ Rebuilding for prod breaks the chain of evidence.
Secrets and Identity Management
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q76 A team stores database passwords in a .env file committed to a private repo. How do you migrate them out?
Beginner
.env file committed to a private repo. How do you migrate them out?Situation read โ Private does not mean safe. Every clone, fork, laptop and CI cache now holds production credentials.
What I'd do โ
- Treat every value in the file as exposed and plan rotation, not just removal.
- Create the secrets in a store (AWS Secrets Manager, Vault, Azure Key Vault):
aws secretsmanager create-secret --name prod/orders/db --secret-string file://db.json. - Change the app or deployment to read from the store (External Secrets Operator, CSI driver or SDK call).
- Rotate each credential, then delete
.envand add it to.gitignore; commit a.env.examplewith placeholders. - Add
gitleaksin pre-commit and CI so it does not come back.
Why โ Moving the file without rotating leaves the old values valid in git history forever.
Interview tip โ Always say "rotate first, clean history second".
Q77 Your CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?
Intermediate
Situation read โ Static keys in CI are the most common cloud breach path. OIDC federation removes them completely.
What I'd do โ
- Create a GitHub OIDC identity provider in IAM (
token.actions.githubusercontent.com). - Create a role whose trust policy restricts
subto the exact repo and branch or environment:
"Condition": {
"StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
"StringLike": { "token.actions.githubusercontent.com:sub": "repo:acme/orders:environment:prod" }
}- In the workflow add
permissions: id-token: writeand useaws-actions/configure-aws-credentialswithrole-to-assume. - Run both paths for a week, then delete the IAM user and its keys.
Why โ Credentials now last about an hour, are scoped to one repo and environment, and nothing exists to leak.
Interview tip โ Mention the sub condition; a wildcard repo:acme/* trust is a common mistake.
Q78 An auditor asks how often you rotate database credentials. You currently never do. What do you build?
Intermediate
Situation read โ Manual rotation never happens. It has to be automated and the app has to tolerate it.
What I'd do โ
- Turn on managed rotation:
aws secretsmanager rotate-secret --secret-id prod/orders/db --rotation-rules AutomaticallyAfterDays=30, or RDS-managed master passwords. - Use the alternating-users strategy so one credential is always valid during the switch.
- Make the app re-read the secret on auth failure or on a short cache TTL instead of only at startup.
- Alert on rotation failures through EventBridge or CloudWatch.
- Longer term, move to Vault dynamic credentials so each pod gets its own short-lived user.
Why โ Rotation that breaks the app gets disabled within a week, so app behaviour matters as much as the schedule.
Interview tip โ Say "rotation is an app-design problem, not a cron job".
Q79 Pods need AWS access. A developer mounted an IAM user's keys as a Kubernetes Secret. What do you propose instead?
Beginner
Situation read โ Static keys in a Secret are base64, readable by anyone with get secrets in that namespace, and never expire.
What I'd do โ
- Use EKS Pod Identity (or IRSA on older clusters) to bind an IAM role to a service account.
- With Pod Identity:
aws eks create-pod-identity-association --cluster-name prod --namespace orders --service-account orders-sa --role-arn arn:aws:iam::111122223333:role/orders-s3. - Set
serviceAccountName: orders-sain the deployment; the AWS SDK picks up credentials automatically. - Delete the Secret and deactivate the IAM user's keys.
Why โ Credentials are temporary, rotated by AWS and scoped to one workload.
Interview tip โ GKE has Workload Identity and AKS has Workload Identity too; same idea everywhere.
Q80 Should you use Kubernetes Secrets, Sealed Secrets, External Secrets Operator or the Secrets Store CSI driver?
Intermediate
Situation read โ They solve different problems: storage, GitOps encryption, or syncing from an external source of truth.
What I'd do โ
- If a cloud secret manager exists, use External Secrets Operator to sync into native Secrets. Apps stay unchanged.
- If secrets must never touch etcd, use the CSI driver to mount them as files directly from the store.
- Use Sealed Secrets only for small GitOps setups without a secret manager; the encrypted blob lives in git.
- Whatever I pick, enable etcd encryption at rest and restrict
get/list secretsin RBAC.
Why โ The source of truth should be a store with audit logs and rotation, not a YAML file.
Interview tip โ ESO is the common default in 2025โ2026 GitOps stacks.
Q81 A Slack webhook URL and a Stripe live key were posted in a public GitHub issue. What is your response sequence?
Beginner
Situation read โ Public exposure means bots have already seen it. Speed matters more than root cause right now.
What I'd do โ
- Revoke and reissue both: roll the Stripe key in the dashboard, regenerate the Slack webhook.
- Edit or delete the issue content and ask GitHub support to purge cached versions if needed.
- Check Stripe logs and Slack audit for usage between post time and revocation.
- Update consumers with the new values from the secret store.
- Write a short incident note and enable GitHub push protection and secret scanning alerts org-wide.
Why โ Deleting the comment does nothing for copies already scraped.
Interview tip โ Order matters: revoke, then clean, then investigate.
Q82 How would you set up HashiCorp Vault so Kubernetes workloads authenticate without any static token?
Advanced
Situation read โ The bootstrap secret problem: the app needs a credential to fetch credentials. Kubernetes auth uses the service account token as identity.
What I'd do โ
- Enable the auth method:
vault auth enable kubernetes
vault write auth/kubernetes/config kubernetes_host=https://$K8S_API:443
vault write auth/kubernetes/role/orders \
bound_service_account_names=orders-sa \
bound_service_account_namespaces=orders \
policies=orders-read ttl=1h- Write a narrow policy:
path "kv/data/orders/*" { capabilities = ["read"] }. - Use the Vault Agent injector or Vault Secrets Operator to deliver secrets to pods.
- Use projected, audience-bound service account tokens, and enable Vault audit devices.
Why โ Identity comes from the platform; nothing long-lived is ever written into a manifest.
Interview tip โ Name it "secret zero" and explain how platform identity solves it.
Q83 Engineers share one admin account for the production cloud console. How do you fix access?
Beginner
Situation read โ Shared accounts kill accountability; audit logs show one name for everyone.
What I'd do โ
- Set up SSO through IAM Identity Center (or Entra ID / Google) federated with the corporate IdP.
- Create permission sets by job function: read-only, developer, ops-admin.
- Enforce MFA in the IdP and remove console passwords for IAM users.
- Lock the root user: hardware MFA, no access keys, credentials in a safe.
- Rotate the shared password and disable the account once everyone has moved.
Why โ Individual identities make CloudTrail useful and offboarding instant.
Interview tip โ Leavers lose cloud access the moment HR disables them in the IdP.
Q84 Developers need occasional production database access for debugging. How do you grant it safely?
Intermediate
Situation read โ Standing access is the risk. Just-in-time, time-boxed, logged access is the goal.
What I'd do โ
- No permanent prod DB roles for developers.
- Access request flow (Teleport, StrongDM, Boundary, or an IAM Identity Center permission set with approval) granting 1โ4 hours.
- Connect through a bastion-less path: SSM Session Manager port forwarding or the access proxy, with session recording.
- Default to a read-only replica role; writes need a second approver.
- Use IAM database authentication or Vault dynamic users so credentials expire with the session.
Why โ Debugging stays possible, but every session has an owner, a reason and an expiry.
Interview tip โ Use the phrase "zero standing privileges".
Q85 A service account token from a GCP project has been found on a public paste site. What do you do?
Intermediate
Situation read โ A JSON service account key is long-lived. It stays valid until someone deletes it.
What I'd do โ
- Identify the key ID from the JSON and delete it:
gcloud iam service-accounts keys delete KEY_ID [email protected]. - Review Cloud Audit Logs filtered on that principal for the exposure window.
- Check for persistence: new keys, new service accounts, IAM binding changes, new compute instances.
- Replace keys with Workload Identity Federation for the system that used it.
- Enforce the org policy
iam.disableServiceAccountKeyCreation.
Why โ Attackers create their own persistence fast, so deleting the leaked key alone is not enough.
Interview tip โ Always mention hunting for persistence after a credential leak.
Q86 How do you inject secrets into a GitHub Actions job without them appearing in logs?
Beginner
Situation read โ GitHub masks registered secrets, but transformations (base64, substrings, JSON) can still leak them.
What I'd do โ
- Store values as environment-scoped secrets with required reviewers on the
prodenvironment. - Pass them via
env:to the specific step, not to the whole job. - Mask derived values:
echo "::add-mask::$TOKEN". - Never
set -xin steps that touch secrets and never echo them. - Better still, fetch at runtime from Vault or a cloud store using OIDC so the value is never a repo secret.
Why โ Masking is a safety net, not a control. Reduced scope and short life are the real controls.
Interview tip โ Mention that secrets are not passed to workflows triggered from forks.
Q87 A legacy app reads its config only from environment variables, and security says env vars are unsafe. How do you handle it?
Intermediate
Situation read โ Env vars leak through /proc/<pid>/environ, crash dumps, debug pages and child processes. But a rewrite is not happening this quarter.
What I'd do โ
- Keep values out of the manifest: source the env vars from a Secret synced by ESO, not from literal YAML.
- Restrict
pods/execand secret read access in RBAC. - Disable debug endpoints and error pages that dump the environment.
- Plan the move to file-mounted secrets read at startup, which also allows hot reload.
- Make sure log shippers do not capture environment dumps.
Why โ Pragmatic risk reduction now, cleaner design later.
Interview tip โ Show you can reduce risk without blocking delivery.
Q88 Your company has 300 TLS certificates and two outages last year from expiry. What do you build?
Intermediate
Situation read โ Expiry outages mean inventory and renewal are manual. Automate issuance and alert on what remains.
What I'd do โ
- Inventory: scan endpoints and pull from cloud certificate services and CT logs.
- In Kubernetes, use cert-manager with an ACME
ClusterIssuer(Let's Encrypt or internal CA) so certs renew at two-thirds of lifetime. - For load balancers, use ACM, which renews automatically for DNS-validated certs.
- Alert at 30 and 7 days left with blackbox exporter
probe_ssl_earliest_cert_expiry. - Assign an owner to every remaining manual certificate.
Why โ Public certificate lifetimes are getting shorter, so manual renewal will only get harder.
Interview tip โ Mention the CA/B Forum plan to cut public cert lifetimes toward 47 days.
Q89 Microservices talk over plain HTTP inside the cluster. Security wants service-to-service authentication. What are your options?
Advanced
Situation read โ The internal network is not a trust boundary. Each service needs a verifiable identity.
What I'd do โ
- Service mesh with mTLS: Istio or Linkerd issue SPIFFE identities per service account and rotate certs automatically.
- Enforce strict mode, e.g. Istio
PeerAuthenticationwithmtls.mode: STRICT, after a permissive rollout. - Add authorization: Istio
AuthorizationPolicyallowing onlyordersto callpayments. - Without a mesh: SPIRE for identities plus app-level mTLS, or signed JWTs between services.
- Keep NetworkPolicies as a second layer.
Why โ mTLS gives encryption and identity; authorization policies turn identity into least privilege.
Interview tip โ Roll out permissive first, watch metrics, then switch to strict.
Q90 An employee with admin access leaves the company on bad terms today. What is your checklist?
Beginner
Situation read โ Act before they are out of the building; assume worst-case intent.
What I'd do โ
- Disable the IdP account and kill sessions; this cuts SSO to cloud, GitHub and Slack.
- Revoke anything not behind SSO: personal access tokens, SSH keys, IAM users, kubeconfig certs, API keys.
- Rotate shared secrets they could have read (break-glass passwords, CI secrets).
- Review the last 30 days of audit logs for unusual activity or new access paths.
- Transfer ownership of their repos, pipelines and on-call duties.
Why โ SSO coverage decides how fast this is; anything outside SSO is a manual hunt.
Interview tip โ The real answer is "this is why everything goes through SSO".
Q91 A Kubernetes kubeconfig with a client certificate for system:masters was copied to a contractor laptop. What now?
Advanced
system:masters was copied to a contractor laptop. What now?Situation read โ Client certificates cannot be revoked individually in Kubernetes, and system:masters bypasses RBAC.
What I'd do โ
- On managed clusters, check whether the cert came from the cluster CA; rotating the CA is the only real revocation.
- Plan a CA rotation: on EKS that means a new cluster or the documented cert rotation path; on kubeadm
kubeadm certs renewdoes not revoke, so a CA change is needed. - Meanwhile, restrict API endpoint access to known CIDRs or private-only.
- Review audit logs for that certificate's
CN. - Going forward, give humans access only via OIDC/IAM-mapped identities, never long-lived client certs.
Why โ You cannot delete a cert from Kubernetes; trust lives in the CA.
Interview tip โ Knowing "certs cannot be revoked" separates seniors from juniors.
Q92 How do you manage SSH access to 500 Linux servers without distributing static keys?
Intermediate
Situation read โ authorized_keys sprawl means nobody knows who can log in where.
What I'd do โ
- Replace SSH with SSM Session Manager or an access proxy (Teleport, Boundary) where possible; port 22 closed.
- Where SSH stays, use short-lived SSH certificates from Vault SSH CA:
vault write ssh-client-signer/sign/ops public_key=@id_ed25519.pub. - Servers trust the CA via
TrustedUserCAKeysinsshd_config; no per-user keys on hosts. - Disable password auth and root login.
- Record sessions and ship logs centrally.
Why โ Certificates expire on their own, so offboarding is automatic.
Interview tip โ "SSH certificates, not keys" is the key phrase.
Q93 A developer created a GitHub personal access token with full repo and admin:org scopes for a script. How do you respond?
Beginner
repo and admin:org scopes for a script. How do you respond?Situation read โ A classic PAT with org admin scope, owned by one human, is a huge blast radius.
What I'd do โ
- Ask what the script needs, then replace the token with a fine-grained PAT limited to the needed repos and permissions with an expiry.
- For automation, prefer a GitHub App with installation tokens that last one hour.
- Revoke the classic token.
- Set an org policy requiring approval for fine-grained PATs and restricting classic PATs.
Why โ GitHub Apps are not tied to a person and have scoped, short-lived tokens.
Interview tip โ Say "automation should never run as a human".
Q94 Terraform needs credentials for AWS, Datadog and Cloudflare in CI. How do you supply them securely?
Intermediate
Situation read โ Multiple providers often means multiple static tokens. Minimise and federate.
What I'd do โ
- AWS: OIDC role assumption, separate plan (read) and apply (write) roles.
- Others: store API tokens in Vault or Secrets Manager, fetch at job start using the AWS role or Vault JWT auth.
- Pass via env vars (
DD_API_KEY,CLOUDFLARE_API_TOKEN), never in.tfvarscommitted to git. - Mark sensitive variables with
sensitive = trueand useephemeralresources/variables (Terraform 1.10+) so values stay out of state where supported. - Scope each token to the zones or orgs it manages.
Why โ One federated identity unlocks the rest, so there is only one trust root to protect.
Interview tip โ Split plan and apply roles; PRs only ever get the read role.
Q95 How do you detect secrets that slipped past scanners and are already in logs or tickets?
Advanced
Situation read โ Scanners cover repos; secrets also end up in logs, Jira, Confluence and Slack.
What I'd do โ
- Run
trufflehogwith verification on Slack exports, Confluence and Jira where licences allow, or use the vendor's DLP features. - Add redaction processors in the log pipeline (Fluent Bit, Vector) for known patterns like
AKIA[0-9A-Z]{16}and JWTs. - Plant canary tokens in sensitive places; any use triggers an alert.
- Monitor cloud provider leak notifications (AWS quarantine policy events, GitHub partner alerts).
- Feed every finding to rotation, not just deletion.
Why โ Logs are often less protected than code and keep data for months.
Interview tip โ Canary tokens show you think about detection, not only prevention.
Q96 A secret manager outage took down all apps because they fetch secrets on every request. How do you redesign?
Advanced
Situation read โ The secret store became a hard runtime dependency on the hot path.
What I'd do โ
- Fetch at startup and cache in memory with a TTL; refresh in the background.
- Keep serving with the cached value if refresh fails, and alert.
- For Kubernetes, sync to native Secrets with ESO so a store outage only blocks updates, not running pods.
- Use client-side caching libraries (AWS Secrets Manager caching client, Vault Agent cache).
- Run Vault in HA with replicas across zones, and test failure in game days.
Why โ Secrets change rarely; there is no need to call the store per request.
Interview tip โ Balance security (fresh secrets) and availability (cached secrets) out loud.
Q97 Your app encrypts customer PII with a key hard-coded in the source. How do you fix the key management?
Intermediate
Situation read โ Anyone with repo access can decrypt all PII. The key must move to a KMS and data needs re-encryption.
What I'd do โ
- Create a KMS key with a key policy limited to the app role.
- Use envelope encryption:
GenerateDataKeyper record or batch, store the encrypted data key with the ciphertext. - Write a migration job that decrypts with the old key and re-encrypts with KMS-derived data keys.
- Remove the old key from code and history, and treat it as compromised.
- Enable automatic key rotation and CloudTrail alerts on
Decryptspikes.
Why โ KMS keys never leave the HSM, every use is logged, and access is controlled by IAM.
Interview tip โ Explain envelope encryption in one sentence; interviewers love it.
Q98 Two teams argue: one wants a central Vault cluster, the other wants each team to use cloud-native secret managers. How do you decide?
Advanced
Situation read โ It is a trade-off between consistency and operational load.
What I'd do โ
- Single cloud: cloud-native managers win; no cluster to run, IAM integration built in.
- Multi-cloud or on-prem heavy, or need for dynamic DB creds, PKI and SSH CA: Vault (or OpenBao) earns its operational cost.
- Consider a hybrid: cloud-native as storage, ESO as the uniform interface for Kubernetes.
- Agree on common standards either way: naming, rotation, audit, access via workload identity.
Why โ Running Vault well needs a dedicated team; a badly run Vault is worse than a managed service.
Interview tip โ Mention OpenBao as the open-source fork after Vault's licence change.
Q99 How do you verify that no human has standing write access to production cloud accounts?
Intermediate
Situation read โ Policy says "no standing access"; you need evidence, not belief.
What I'd do โ
- List IAM users and access keys:
aws iam generate-credential-reportand check for console passwords or active keys. - Review Identity Center assignments for prod accounts; only JIT-elevated permission sets should have write.
- Use IAM Access Analyzer unused access findings to spot unused roles and permissions.
- Automate a weekly check (AWS Config rule or a script) that fails on new standing admin assignments.
- Report results to the security dashboard.
Why โ Continuous evidence beats a yearly access review spreadsheet.
Interview tip โ "Evidence over policy" fits every compliance conversation.
Q100 A pipeline needs to push images to registries in three clouds. How do you avoid storing three sets of credentials?
Advanced
Situation read โ Each cloud supports OIDC federation from CI. Use the CI identity token everywhere.
What I'd do โ
- AWS ECR:
configure-aws-credentialswith a role, thenaws ecr get-login-password | docker login. - GCP Artifact Registry: Workload Identity Federation pool trusting GitHub, via
google-github-actions/auth. - Azure ACR: federated credential on an Entra app registration, via
azure/loginwithclient-id,tenant-id,subscription-id. - Restrict each trust to the repo and
refs/heads/mainor an environment. - Push once, then replicate with the registries' own replication if possible.
Why โ Zero stored secrets in CI; all three tokens are short-lived and auditable.
Interview tip โ Show you know the GCP and Azure equivalents, not just AWS.
Kubernetes Security
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q101 Every developer has cluster-admin on the shared cluster "because it is easier". How do you fix RBAC without a revolt?
Beginner
cluster-admin on the shared cluster "because it is easier". How do you fix RBAC without a revolt?Situation read โ cluster-admin for everyone means any compromised laptop owns the cluster. Fix it gradually with good defaults.
What I'd do โ
- Find who has it:
kubectl get clusterrolebindings -o wide | grep cluster-admin. - Create a namespaced
Rolefor app teams (deployments, services, configmaps, pods/log) and bind it per team namespace with aRoleBinding. - Give a cluster-wide read-only
ClusterRolefor visibility, excluding secrets. - Keep
cluster-adminfor a small platform group via JIT elevation. - Test with
kubectl auth can-i --list [email protected] -n ordersbefore removing old bindings.
Why โ Teams keep full control of their own namespaces, so daily work does not change.
Interview tip โ kubectl auth can-i shows you verify RBAC rather than guess.
Q102 You must roll out Pod Security Standards on a cluster with 80 existing namespaces. How do you avoid breaking workloads?
Intermediate
Situation read โ Pod Security Admission can warn and audit before it enforces. Use that.
What I'd do โ
- Label all namespaces with warn and audit at
restricted, enforce atbaseline:
kubectl label ns --all \
pod-security.kubernetes.io/enforce=baseline \
pod-security.kubernetes.io/warn=restricted \
pod-security.kubernetes.io/audit=restricted --overwrite- Dry-run first:
kubectl label --dry-run=server --overwrite ns orders pod-security.kubernetes.io/enforce=restrictedlists violating pods. - Fix manifests team by team (runAsNonRoot, drop capabilities, seccomp
RuntimeDefault). - Move namespaces to
enforce=restrictedonce clean; keep system namespaces atprivilegedwith a documented reason.
Why โ Warnings in kubectl output and audit logs give teams time to fix things before anything is blocked.
Interview tip โ PodSecurityPolicy was removed in 1.25; PSA is the built-in replacement.
Q103 A pentest shows any pod can reach any other pod, including the database. What do you implement?
Beginner
Situation read โ Kubernetes networking is flat by default. NetworkPolicies need a CNI that enforces them (Calico, Cilium, or VPC CNI with network policy enabled).
What I'd do โ
- Confirm enforcement support in the CNI.
- Apply default deny in each namespace:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny, namespace: orders }
spec:
podSelector: {}
policyTypes: [Ingress, Egress]- Add allow rules: ingress controller to frontend, frontend to API, API to DB on 5432, and DNS egress to kube-dns on 53.
- Test with a temporary pod and
nc -zv.
Why โ Default deny turns lateral movement from trivial into hard.
Interview tip โ Forgetting DNS egress is the classic mistake; mention it.
Q104 Falco alerts "Terminal shell in container" on a production payments pod at 3 a.m. Walk through your response.
Intermediate
Situation read โ Could be an engineer debugging or an attacker with RCE. Verify fast, preserve evidence.
What I'd do โ
- Check the alert fields: user, command line, parent process, pod and node.
- Check audit logs for a matching
pods/execby a known human: if found, confirm with that person. - If no exec in audit logs, the shell came from inside the app: treat it as RCE.
- Isolate: apply a deny-all NetworkPolicy to the pod label, cordon the node, but do not delete the pod yet.
- Capture evidence (process list, network connections, container filesystem diff), then rotate the pod's secrets and redeploy from a known-good image.
Why โ Audit logs tell you if the shell came through the API or from an exploit.
Interview tip โ "Isolate, don't delete" keeps evidence for forensics.
Q105 A cluster's nodes are suddenly at 100% CPU and you find pods running xmrig in a namespace nobody owns. How do you respond?
Intermediate
xmrig in a namespace nobody owns. How do you respond?Situation read โ Cryptomining is often the first visible sign of a compromise. Find the entry point, not just the miner.
What I'd do โ
- Save the pod specs:
kubectl get pod -n x -o yaml > evidence.yaml, note the creator from audit logs (user.usernameon thecreateevent). - Isolate with a deny-all NetworkPolicy and scale the workloads down; block the mining pool domains at egress.
- Find the entry point: exposed dashboard, anonymous API access, leaked kubeconfig, vulnerable app with RCE, or a compromised CI token.
- Revoke the credential used, check for other persistence (DaemonSets, CronJobs, new RBAC bindings, mutating webhooks).
- Rebuild affected nodes if any pod was privileged or used hostPath.
Why โ Deleting the miner without closing the hole means it is back in an hour.
Interview tip โ Mention checking for malicious webhooks and CronJobs as persistence.
Q106 The Kubernetes API server endpoint is public. Is that a problem, and what do you do?
Beginner
Situation read โ A public endpoint still needs auth, but it exposes the cluster to credential stuffing and zero-day exploits.
What I'd do โ
- Prefer a private endpoint; access via VPN, bastion or SSM.
- If public is needed (for example hosted CI), restrict to known CIDRs:
aws eks update-cluster-config --name prod --resources-vpc-config endpointPublicAccess=true,publicAccessCidrs="203.0.113.0/24",endpointPrivateAccess=true. - Confirm anonymous auth gives nothing useful:
curl -k https://$API/apishould return 401 or 403. - Keep the control plane version current.
Why โ Reducing who can reach the API cuts off whole classes of attacks.
Interview tip โ Private endpoint plus CI runners inside the VPC is the clean answer.
Q107 A team mounts hostPath: / into a logging agent. How do you evaluate and constrain this?
Intermediate
hostPath: / into a logging agent. How do you evaluate and constrain this?Situation read โ Mounting / gives the pod full node access, including kubelet credentials and other pods' data.
What I'd do โ
- Ask what it really needs; log agents usually need only
/var/logand/var/lib/docker/containersor/var/log/pods. - Narrow the mounts and set
readOnly: true. - Run it in a dedicated namespace labelled for an exception, not in app namespaces.
- Enforce with Kyverno or Gatekeeper: deny
hostPathexcept allowlisted paths in allowlisted namespaces.
Why โ Platform agents sometimes need host access, but each one should get only the paths it uses.
Interview tip โ Treat every DaemonSet with host mounts as part of the node's trusted base.
Q108 How do you stop pods from getting a service account token they never use?
Beginner
Situation read โ By default every pod gets a token for its service account. If the app is compromised, that token talks to the API.
What I'd do โ
- Set
automountServiceAccountToken: falseon thedefaultservice account in each namespace and on pod specs that do not call the API. - Create dedicated service accounts for workloads that need API access, with minimal Roles.
- Rely on projected, time-bound tokens (default since 1.22) rather than legacy Secret-based tokens.
- Audit for leftover legacy token Secrets:
kubectl get secrets -A --field-selector type=kubernetes.io/service-account-token.
Why โ Most apps never talk to the Kubernetes API; giving them a token only helps an attacker.
Interview tip โ Mention the default service account; it often has extra permissions someone added.
Q109 Security wants to know who deleted a production deployment last Friday. Audit logging was never configured. What do you set up?
Intermediate
Situation read โ Without audit logs, that question has no answer. Turn them on now and keep them off-cluster.
What I'd do โ
- Managed clusters: enable control plane audit logs (
aws eks update-cluster-config --logging '{"clusterLogging":[{"types":["audit"],"enabled":true}]}', GKE has Admin Activity on by default). - Self-managed: write an audit policy logging
RequestResponsefor secrets metadata only,Metadatafor most, and drop noisy reads. - Ship to a SIEM with retention matching compliance (often 1 year).
- Alert on high-risk verbs:
deleteon deployments in prod,createon clusterrolebindings,pods/exec. - For Friday's event: check GitOps history and CI logs, which may still show who changed what.
Why โ Audit logs are the only record of who did what in the cluster.
Interview tip โ Never log secret values at RequestResponse level; use Metadata for secrets.
Q110 How do you make sure Kubernetes Secrets are encrypted at rest in etcd?
Intermediate
Situation read โ Secrets are base64, not encrypted. Anyone with an etcd backup can read them unless encryption is configured.
What I'd do โ
- Managed: on EKS enable envelope encryption with a KMS key (
aws eks associate-encryption-config); recent EKS versions encrypt by default, but a customer KMS key gives control and audit. - Self-managed:
EncryptionConfigurationwith thekmsv2 provider, passed via--encryption-provider-config. - Re-encrypt existing Secrets:
kubectl get secrets -A -o json | kubectl replace -f -. - Protect etcd backups and restrict
get/liston secrets in RBAC.
Why โ Encryption at rest protects against stolen disks and backups, not against users who can read secrets through the API.
Interview tip โ Say clearly that base64 is encoding, not encryption.
Q111 Write a policy that rejects any Deployment without CPU and memory limits and without a team label. Which tool and how?
Intermediate
team label. Which tool and how?Situation read โ An admission policy engine handles this. Kyverno writes it in YAML, Gatekeeper in Rego, or built-in ValidatingAdmissionPolicy in CEL.
What I'd do โ
- Kyverno example:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata: { name: require-limits-and-team }
spec:
validationFailureAction: Audit
rules:
- name: check
match: { any: [ { resources: { kinds: [Deployment] } } ] }
validate:
message: "team label and resource limits are required"
pattern:
metadata: { labels: { team: "?*" } }
spec: { template: { spec: { containers: [ { resources: { limits: { cpu: "?*", memory: "?*" } } } ] } } }- Start in
Audit, review policy reports, then switch toEnforce. - Run the same policies in CI with
kyverno applyso developers see failures before merge.
Why โ Limits prevent noisy-neighbour denial of service; labels give ownership for incidents.
Interview tip โ "Audit first, then enforce, and test in CI too."
Q112 kube-bench reports 40 CIS benchmark failures on your managed EKS nodes. How do you prioritise?
Intermediate
Situation read โ Many CIS controls cover the control plane, which the provider manages. Use the right benchmark first.
What I'd do โ
- Run the managed profile:
kube-bench run --benchmark eks-1.5.0(or the current EKS benchmark) instead of the generic one. - Separate node findings (kubelet config, file permissions) from things AWS owns.
- Fix high-impact ones: kubelet
anonymous-auth=false,authorization-mode=Webhook,protectKernelDefaults. - Bake fixes into the node AMI or Bottlerocket settings, not hand-edits.
- Document accepted exceptions with reasons.
Why โ Running the wrong benchmark creates noise and wastes effort on controls you cannot change.
Interview tip โ Mention shared responsibility for managed Kubernetes.
Q113 A critical CVE affects the Kubernetes version running on all your clusters. How do you plan the upgrade under pressure?
Advanced
Situation read โ Assess exploitability first, apply mitigations, then upgrade in a controlled order.
What I'd do โ
- Read the advisory: which component, what preconditions (feature enabled, specific permissions)? Check if our config is affected.
- Apply interim mitigations from the advisory (disable a feature gate, restrict RBAC, admission policy).
- Check API deprecations:
kubentorpluto detect-helm, and add-on compatibility (CNI, CSI, ingress). - Upgrade a non-prod cluster, run smoke tests, then prod control plane, then node groups with PDBs respected.
- Track with a change ticket and report status to security.
Why โ Rushed upgrades cause outages; mitigations buy time to upgrade safely.
Interview tip โ Always show you check exploitability before panicking.
Q114 Developers want to debug distroless pods that have no shell. How do you allow that securely?
Beginner
Situation read โ Adding a shell back to images undoes the hardening. Ephemeral containers give a debug shell only when needed.
What I'd do โ
- Use
kubectl debug -it orders-7d9f --image=busybox:1.36 --target=appto attach a temporary container sharing the process namespace. - Allow
pods/ephemeralcontainersonly in non-prod by default; prod via JIT access. - Log and alert on ephemeral container creation in prod via audit logs.
- Keep debug images in the approved registry.
Why โ Images stay minimal, and debugging is controlled and audited.
Interview tip โ kubectl debug is the modern answer to "but I need a shell".
Q115 Five teams share one cluster. How do you design tenant isolation?
Advanced
Situation read โ Namespaces are a soft boundary. How far to go depends on trust between tenants.
What I'd do โ
- Per-team namespaces with RBAC, ResourceQuota and LimitRange.
- Default-deny NetworkPolicies; allow only declared dependencies.
- PSA
restrictedand policy engine rules (no hostPath, no hostNetwork, approved registries only). - Node isolation for sensitive tenants: dedicated node pools with taints and tolerations.
- If tenants are untrusted (customers), use separate clusters, virtual clusters (vcluster) or sandboxed runtimes.
Why โ Internal teams need guardrails; untrusted tenants need hard boundaries.
Interview tip โ Say "soft multi-tenancy vs hard multi-tenancy" and when each fits.
Q116 A pod needs to bind to port 80 and the team added NET_ADMIN and SYS_ADMIN capabilities. What do you suggest?
Beginner
NET_ADMIN and SYS_ADMIN capabilities. What do you suggest?Situation read โ Binding to a low port needs at most NET_BIND_SERVICE. SYS_ADMIN is close to full root.
What I'd do โ
- Change the app to listen on 8080 and map port 80 in the Service.
- If it truly must bind 80, use only
NET_BIND_SERVICE:
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities: { drop: ["ALL"], add: ["NET_BIND_SERVICE"] }- Block
SYS_ADMINandNET_ADMINthrough PSArestrictedor a policy.
Why โ Services already remap ports; capabilities should never be the workaround.
Interview tip โ "Drop ALL, add back only what you need" is the line to say.
Q117 Your Argo CD instance can deploy to every cluster with admin rights. How do you secure the GitOps control plane?
Advanced
Situation read โ Argo CD is now the most powerful identity in the estate. Whoever controls it or its repos controls production.
What I'd do โ
- SSO for the UI, disable the local
adminuser, RBAC viaargocd-rbac-cmper team. - Use
AppProjectto limit source repos, destination clusters and namespaces, and allowed resource kinds per team. - Restrict cluster-scoped resources (
clusterResourceWhitelist) to platform projects. - Protect the config repos: branch protection, CODEOWNERS, signed commits; optionally verify commit signatures in Argo CD.
- Keep Argo CD patched and its API off the internet.
Why โ In GitOps, a merge to the config repo is a deploy, so repo access is production access.
Interview tip โ Mention AppProject boundaries; most setups leave the default project wide open.
Q118 Pods can call the cloud metadata endpoint and grab the node's IAM role credentials. How do you block that?
Intermediate
Situation read โ If pods can reach 169.254.169.254, they can act with the node role. That is an SSRF and privilege escalation path.
What I'd do โ
- Enforce IMDSv2 with hop limit 1 on nodes:
aws ec2 modify-instance-metadata-options --instance-id i-... --http-tokens required --http-put-response-hop-limit 1, and set it in the launch template. - Give pods their own roles with Pod Identity or IRSA so they do not need node credentials.
- Add NetworkPolicy egress deny to
169.254.169.254/32for app namespaces. - Keep the node role minimal.
Why โ Hop limit 1 stops containers that are not using host networking from getting IMDSv2 tokens.
Interview tip โ Link this to SSRF; the Capital One breach is the reference everyone knows.
Q119 How do you control which external domains pods can reach?
Advanced
Situation read โ Standard NetworkPolicy works on IPs, not domains. Egress control by domain needs more tooling.
What I'd do โ
- Cilium
CiliumNetworkPolicywithtoFQDNsrules (for examplematchName: api.stripe.com) plus DNS visibility. - Or an egress gateway or proxy (Istio egress gateway, Squid) that pods must use, with an allowlist.
- At the VPC level, AWS Network Firewall domain lists or a NAT with filtering.
- Start in log-only mode to build the allowlist from real traffic.
Why โ Egress control blocks data exfiltration and command-and-control callbacks.
Interview tip โ Say you learn real traffic first, then enforce, to avoid breaking apps.
Q120 A Helm chart from a vendor creates a ClusterRole with * on *. The team wants to install it today. What do you do?
Intermediate
* on *. The team wants to install it today. What do you do?Situation read โ Wildcard RBAC gives the vendor's controller full cluster control. If it is compromised, so is the cluster.
What I'd do โ
- Render it:
helm template vendor/chart | yq 'select(.kind == "ClusterRole")'and list what the operator really needs. - Check the chart values for a "namespaced" or "restricted RBAC" mode; many charts have one.
- If not, write a narrower ClusterRole and disable chart-managed RBAC (
rbac.create=false). - Install into a dedicated namespace and log its API actions.
- Raise an issue with the vendor.
Why โ Third-party operators are part of the supply chain and should get least privilege too.
Interview tip โ "Render before you install" shows good habits.
Q121 How do you enforce seccomp and AppArmor profiles across workloads?
Advanced
Situation read โ Containers run unconfined by default on many setups. RuntimeDefault seccomp blocks a large set of dangerous syscalls with little breakage.
What I'd do โ
- Set
seccompProfile: { type: RuntimeDefault }in podsecurityContext; PSArestrictedrequires it. - Enable kubelet
--seccomp-defaultso pods without a profile still getRuntimeDefault. - For high-risk apps, generate custom profiles with Security Profiles Operator recording mode.
- AppArmor: use the
appArmorProfilefield (GA in 1.30) withRuntimeDefaultor a custom loaded profile.
Why โ Syscall filtering cuts the kernel attack surface that container escapes depend on.
Interview tip โ Mention the seccomp-default kubelet flag; few candidates know it.
Q122 Your private image registry is reachable but pods in some namespaces pull from it with a shared imagePullSecret containing an admin token. What is wrong?
Beginner
Situation read โ The pull secret can push and delete images. Anyone who reads it can overwrite production images.
What I'd do โ
- Replace it with a read-only pull credential, ideally per namespace or team.
- Better: use node or workload identity (ECR via the node role, GKE Artifact Registry via Workload Identity) so no pull secret is needed.
- Rotate the admin token right away.
- Enable tag immutability on the registry.
Why โ Pulling and pushing are different trust levels; runtime only needs to pull.
Interview tip โ Pair this with "deploy by digest" for defence in depth.
Q123 An attacker could create pods in one namespace. List the paths they would use to escalate, and how you block each.
Advanced
Situation read โ "Create pods" is more powerful than it sounds.
What I'd do โ
- Mount any Secret or service account in that namespace via the pod spec: limit what lives there and use separate namespaces for sensitive workloads.
- Run privileged or with hostPath/hostPID to escape to the node: PSA
restrictedblocks it. - Schedule onto control plane or sensitive nodes with tolerations: policy engine restricting tolerations and nodeSelectors.
- Steal node credentials from IMDS: IMDSv2 hop limit 1 and egress deny.
- Reach other services: default-deny NetworkPolicies.
Why โ Each control closes one escalation path; together they contain the attacker in one namespace.
Interview tip โ Saying "create pod is effectively read all secrets in the namespace" shows depth.
Q124 How do you secure the ingress layer of a cluster serving public traffic?
Intermediate
Situation read โ The ingress controller is the internet-facing entry. Harden it like an edge proxy.
What I'd do โ
- Terminate TLS with cert-manager certs, enforce TLS 1.2+ and HSTS.
- Put a WAF in front (AWS WAF on the ALB, Cloud Armor, or ModSecurity/Coraza rules).
- Rate limit per client IP and set request size limits.
- Disable risky annotations: for ingress-nginx, keep
allow-snippet-annotations: false(snippets enable config injection). - Patch the controller quickly; the 2025 "IngressNightmare" CVEs in ingress-nginx showed why.
Why โ One misconfigured controller exposes every app behind it.
Interview tip โ Mention IngressNightmare and the admission webhook exposure lesson.
Q125 How do you continuously check the security posture of 20 clusters?
Intermediate
Situation read โ One-off audits go stale. Continuous scanning with central reporting is needed.
What I'd do โ
- Deploy Trivy Operator or Kubescape in each cluster to scan workloads, RBAC and configs; export results as CRDs and metrics.
- Use the same policy engine rules (Kyverno/Gatekeeper) everywhere, rolled out by GitOps.
- Aggregate into a central dashboard (Grafana or a CNAPP like Wiz, Prisma, Defender for Cloud).
- Track trends: critical findings per cluster, time to fix.
- Fail cluster creation pipelines if baseline policies are missing.
Why โ Consistency across clusters matters more than perfection in one.
Interview tip โ Talk about posture as a metric over time, not a one-time report.
Cloud IAM and Compliance
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q126 You find an IAM policy with "Action": "*", "Resource": "*" attached to an application role. How do you right-size it?
Beginner
"Action": "*", "Resource": "*" attached to an application role. How do you right-size it?Situation read โ The app almost certainly uses a handful of APIs. Find out which ones from real usage, then shrink the policy.
What I'd do โ
- Check last-accessed data:
aws iam generate-service-last-accessed-details --arn <role-arn>thenget-service-last-accessed-details. - Use IAM Access Analyzer policy generation from CloudTrail for the role (90 days of activity).
- Write the new policy with specific actions and resource ARNs, e.g.
s3:GetObjectonarn:aws:s3:::orders-bucket/*. - Deploy to staging, watch for
AccessDeniedin CloudTrail, adjust, then roll to prod. - Add a Checkov or cfn-lint rule to block
*:*in future IaC.
Why โ Usage data removes the guesswork that keeps teams from tightening policies.
Interview tip โ Mention Access Analyzer policy generation by name.
Q127 Your company has 40 AWS accounts with no central controls. How do you set up preventive guardrails?
Intermediate
Situation read โ Multi-account is good for blast radius but needs org-level controls so no account owner can switch off security.
What I'd do โ
- Put all accounts in AWS Organizations with OUs (Security, Infrastructure, Workloads-Prod, Workloads-NonProd, Sandbox).
- Apply SCPs: deny leaving the org, deny disabling CloudTrail/GuardDuty/Config, deny unapproved regions, deny root user actions.
{ "Effect": "Deny", "Action": ["cloudtrail:StopLogging","cloudtrail:DeleteTrail","guardduty:DeleteDetector"], "Resource": "*" }- Use Control Tower or Account Factory for Terraform for new accounts with baselines.
- Test SCPs on the Sandbox OU first.
Why โ SCPs apply even to account admins, so guardrails cannot be removed from inside an account.
Interview tip โ SCPs never grant permissions; they only set the maximum.
Q128 GuardDuty reports UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS. What happened and what do you do?
Advanced
UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS. What happened and what do you do?Situation read โ Temporary credentials from an EC2 instance role are being used from an IP outside AWS. Someone stole them, often via SSRF or a compromised host.
What I'd do โ
- Identify the instance and role from the finding.
- Revoke active sessions: in IAM console "Revoke active sessions" on the role, which adds a deny policy on
aws:TokenIssueTime. - Review CloudTrail for actions by that role from the external IP.
- Isolate the instance (restrictive security group), snapshot disks for forensics.
- Find the root cause (SSRF, IMDSv1, RCE), enforce IMDSv2, patch, and redeploy from a clean image.
Why โ Rotating the role does not invalidate issued session tokens; the token-issue-time deny does.
Interview tip โ Knowing "revoke sessions" works via a date-condition deny is a strong signal.
Q129 Your company must pass SOC 2 Type II in six months. What does DevOps own, and how do you automate evidence?
Intermediate
Situation read โ Type II checks that controls operated over a period, so evidence must be continuous, not screenshots on audit day.
What I'd do โ
- Map controls DevOps owns: change management, access control, logging, backups, vulnerability management, incident response.
- Make the pipeline the evidence: PR reviews, branch protection, CI logs, deployment records all link back to tickets.
- Automate access reviews and quarterly exports from the IdP.
- Use a compliance platform (Vanta, Drata, Secureframe) or AWS Audit Manager to collect evidence via APIs.
- Run a readiness assessment at month two to find gaps early.
Why โ If evidence collection is manual, the controls will drift during the audit window.
Interview tip โ Explain the difference between Type I (design at a point) and Type II (operation over time).
Q130 A partner needs access to one S3 bucket in your account. How do you set up cross-account access safely?
Intermediate
Situation read โ Do not create IAM users for partners. Use a role with a trust policy and an external ID.
What I'd do โ
- Create a role trusting the partner's account with an
sts:ExternalIdcondition:
"Condition": { "StringEquals": { "sts:ExternalId": "c2f1-partner-unique-id" } }- Attach a policy allowing only the needed actions on that bucket and prefix.
- Optionally add a bucket policy limiting access to that role.
- Monitor
AssumeRoleevents from the partner account.
Why โ The external ID prevents the confused deputy problem when a third party serves many customers.
Interview tip โ Say "confused deputy" when you explain the external ID.
Q131 Someone logged in with the AWS root user last night. How do you react, and how should you have known?
Beginner
Situation read โ Root use should be almost never. Treat any unplanned root login as an incident until explained.
What I'd do โ
- Check CloudTrail for
ConsoleLoginwithuserIdentity.type = Root, source IP and what actions followed. - Confirm with the custodian of the root credentials.
- If unexplained: reset the password, replace MFA, check for new IAM users, access keys, or changed billing/contact details.
- Set up detection: EventBridge rule on root
ConsoleLoginsending to Slack/PagerDuty. - With Organizations, use centralised root access management to remove root credentials from member accounts.
Why โ Root bypasses IAM policies (though not SCPs in member accounts), so it is the highest-value credential.
Interview tip โ Mention the newer AWS feature to remove member-account root credentials.
Q132 How do you collect logs from 40 accounts so an attacker in one account cannot delete them?
Intermediate
Situation read โ Logs in the same account as the attacker can be wiped. Centralise to a locked-down account.
What I'd do โ
- Organization CloudTrail trail writing to an S3 bucket in a dedicated Log Archive account.
- S3 Object Lock in compliance mode with a retention period, plus versioning.
- Bucket policy allowing only CloudTrail to write; no human write or delete access.
- Also centralise VPC Flow Logs, Config, GuardDuty and Security Hub to the Security account via delegated admin.
- SCP denying changes to the trail from member accounts.
Why โ Attackers delete logs to hide; immutability preserves evidence.
Interview tip โ "Separate account, object lock, no human write" is the summary.
Q133 Security Hub shows 12,000 findings across accounts. Teams ignore it. How do you make it useful?
Intermediate
Situation read โ Too many findings with no owners means no action. Filter, prioritise and route.
What I'd do โ
- Disable standards and controls that do not apply (for example, controls for services you do not use).
- Focus on critical and high in production accounts first.
- Route findings to owning teams by account or tag through EventBridge into Jira, with SLAs.
- Auto-remediate safe ones (enable S3 block public access, turn on EBS default encryption).
- Report a trend chart weekly so progress is visible.
Why โ People act on a short, owned list, not on a dashboard of thousands.
Interview tip โ Talk about routing to owners; ownership is what fixes findings.
Q134 A developer can create IAM roles for their Lambdas. How do you stop them from creating an admin role for themselves?
Advanced
Situation read โ iam:CreateRole plus iam:PassRole or AttachRolePolicy is a privilege escalation path. Permission boundaries close it.
What I'd do โ
- Create a boundary policy defining the maximum any developer-created role can do.
- Allow
iam:CreateRoleonly when the boundary is attached:
"Condition": { "StringEquals": { "iam:PermissionsBoundary": "arn:aws:iam::111122223333:policy/dev-boundary" } }- Deny deleting or changing the boundary policy itself and deny
iam:DeleteRolePermissionsBoundary. - Restrict role names to a prefix (
app-*) so they cannot modify platform roles.
Why โ Teams self-serve roles, but no role they create can exceed the boundary.
Interview tip โ Effective permissions = identity policy โฉ boundary โฉ SCP.
Q135 The company enters the EU market and must keep customer data in the EU. How do you enforce data residency in the cloud?
Intermediate
Situation read โ Residency needs prevention (cannot create resources elsewhere) and evidence (where data actually lives).
What I'd do โ
- SCP denying actions outside approved regions using
aws:RequestedRegion, with exceptions for global services (IAM, CloudFront, Route 53). - Separate EU accounts or projects for EU customer data.
- Check replication settings: S3 CRR, DynamoDB global tables, backups and logs must not copy to non-EU regions.
- Review third-party services (logging, APM, support tools) for where they process data.
- Keep a data map for the DPO showing systems and regions.
Why โ Residency breaks most often through backups and SaaS tools, not primary databases.
Interview tip โ Mention global services exceptions in region-deny SCPs; forgetting them breaks IAM.
Q136 PCI DSS applies to your payment flow. How do you reduce the scope of the audit?
Advanced
Situation read โ Everything that stores, processes or transmits card data, or can affect its security, is in scope. Shrinking that is the biggest lever.
What I'd do โ
- Use a payment provider's hosted fields or redirect (Stripe Elements, Adyen) so card numbers never touch our servers.
- If card data must be handled, isolate it in a separate account/VPC with strict network segmentation.
- Tokenise card numbers so downstream systems see tokens only.
- Keep CI/CD and admin access for the in-scope environment separate and logged.
- Document data flows and segmentation tests for the QSA.
Why โ A smaller cardholder data environment means fewer systems to harden, monitor and audit.
Interview tip โ "The cheapest PCI control is not touching card data."
Q137 Developers in a sandbox account accidentally ran a $9,000 GPU instance for two weeks. How do you add guardrails without blocking experimentation?
Beginner
Situation read โ Cost is a security concern too (cryptojacking looks the same). Sandboxes need limits, not locks.
What I'd do โ
- AWS Budgets with alerts at 50/80/100% and a budget action that applies a deny policy at the limit.
- SCP on the Sandbox OU denying large or GPU instance types except via approval.
- Auto-cleanup: nightly job (aws-nuke or Lambda) deleting resources older than N days without a
keeptag. - Cost anomaly detection alerts to the account owner.
Why โ People can still experiment, but nothing expensive keeps running without anyone noticing.
Interview tip โ Link cost anomalies to compromised-account detection.
Q138 A KMS key policy was edited and now nobody, including admins, can use or manage the key. What do you do?
Advanced
Situation read โ Key policies are the primary access control for KMS. If the policy excludes the account root principal, IAM policies cannot help.
What I'd do โ
- Check if any principal in the policy still has
kms:PutKeyPolicy; use it to restore the standard root-account statement. - If none, open a case with AWS Support; they can help in some cases but it is slow and not guaranteed.
- Meanwhile, assess impact: which data and services depend on the key.
- Prevent: manage key policies in IaC with review, always include
arn:aws:iam::<acct>:rootwithkms:*, and use the KMS policy lockout safety check (do not bypass it).
Why โ A locked-out key can mean permanently unreadable data.
Interview tip โ Mention BypassPolicyLockoutSafetyCheck and why you never set it to true casually.
Q139 How do you make sure EC2 instances and Lambdas reach S3 and DynamoDB without going over the internet?
Beginner
Situation read โ Traffic to AWS APIs via NAT goes over public endpoints. VPC endpoints keep it on the AWS network and let you add policies.
What I'd do โ
- Create gateway endpoints for S3 and DynamoDB (free) and interface endpoints for others (ECR, STS, Secrets Manager).
- Add endpoint policies limiting access to your own buckets.
- Use bucket policies with
aws:SourceVpceto deny access not through the endpoint for sensitive buckets. - Bonus: lower NAT gateway data costs.
Why โ Private paths reduce exposure and enable data perimeter controls.
Interview tip โ Mention "data perimeter" (aws:ResourceOrgID, aws:PrincipalOrgID) as the bigger pattern.
Q140 An auditor asks you to prove that all production changes in the last year were reviewed. How do you produce it?
Intermediate
Situation read โ If deploys only come from merged PRs, evidence is a query. If people deploy by hand, you have a gap.
What I'd do โ
- Export merged PRs to
mainwith approvers via GitHub API:gh pr list --state merged --base main --limit 1000 --json number,mergedAt,reviews. - Match deployments (Argo CD history, CI deploy jobs) to PR commits.
- Show branch protection settings and their history (audit log) to prove no bypass.
- List exceptions (break-glass deploys) with their post-review tickets.
- Show CloudTrail to prove there were no console changes outside the pipeline, or explain the ones found.
Why โ A control is only as good as its evidence trail.
Interview tip โ Say "every prod change maps to a PR, an approver and a pipeline run".
Q141 Your team uses Azure and AWS. How do you keep IAM consistent across both?
Advanced
Situation read โ Different models (AWS IAM policies vs Azure RBAC role assignments), but the same principles.
What I'd do โ
- One IdP (Entra ID or Okta) as the source of identity for both; groups drive access.
- Map job functions to AWS permission sets and Azure built-in or custom roles.
- Manage both in Terraform from one repo, with review.
- Use workload identity in both: IRSA/Pod Identity and Azure Workload Identity; no secrets.
- Run a CSPM across both clouds and run access reviews from the IdP.
Why โ The IdP group is the common layer, so access reviews and offboarding work the same way in both clouds.
Interview tip โ Show you know the equivalents: SCP vs Azure Policy, IAM role vs managed identity.
Q142 A CloudTrail trail was stopped in one account for six hours. How do you detect this next time in minutes?
Beginner
Situation read โ Disabling logging is a classic attacker step. It should be both prevented and detected.
What I'd do โ
- Prevent with an SCP denying
cloudtrail:StopLogging,DeleteTrail,UpdateTrailfor non-security roles. - Detect with an EventBridge rule on those API calls routing to the on-call channel.
- Use an organization trail, which member accounts cannot modify.
- GuardDuty also raises
Stealth:IAMUser/CloudTrailLoggingDisabled.
Why โ Six hours without logs is six hours you cannot investigate.
Interview tip โ Pair prevention (SCP) with detection (EventBridge) every time.
Q143 How do you implement compliance as code for a framework like CIS AWS Foundations?
Intermediate
Situation read โ Manual checklists drift. Codify the checks so they run continuously and in pipelines.
What I'd do โ
- Runtime: enable the CIS standard in Security Hub, or AWS Config conformance packs.
- Pre-deploy: Checkov or Trivy config scans on Terraform with CIS-mapped checks.
- Ad-hoc:
prowler aws --compliance cis_3.0_awsfor full reports. - Store exceptions in code with expiry dates and approvers.
- Report compliance score per account over time.
Why โ The same control checked before deploy and at runtime catches both new and drifted issues.
Interview tip โ Mention Prowler; it is a well known open-source tool.
Q144 A data scientist uploaded a customer CSV with PII to a public GitHub gist "for a quick share". What do you do?
Beginner
Situation read โ This is a data breach, not just a security mistake. Legal and privacy must be involved.
What I'd do โ
- Delete the gist right away and ask GitHub support to purge caches.
- Notify security and the privacy/legal team; they decide on regulatory notification (GDPR has a 72-hour window to notify the authority).
- Record what data, how many records, how long it was public, and whether it was accessed.
- Provide a safe sharing option (internal storage with access control) and DLP alerts.
- Run a blameless review.
Why โ Legal deadlines start when you become aware, so escalation must be fast.
Interview tip โ Mention GDPR's 72-hour notification timeline.
Q145 Teams keep launching untagged resources and nobody knows who owns what during incidents. How do you enforce tagging?
Beginner
Situation read โ Ownership tags are security metadata. Without them, findings and incidents have no owner.
What I'd do โ
- Define required tags (
team,env,data-classification) in AWS Organizations tag policies. - Enforce in IaC: Terraform
default_tagsin the provider and a Checkov/OPA check in CI. - Optionally deny creation without tags via SCP with
aws:RequestTagconditions for key services. - Report untagged resources weekly and auto-notify account owners.
Why โ Tags let you route findings, calculate costs and answer "who owns this?" quickly in an incident.
Interview tip โ default_tags in the Terraform AWS provider is a quick win to mention.
Q146 How do you detect and stop an IAM privilege escalation via iam:PassRole?
Advanced
iam:PassRole?Situation read โ A user who can pass a powerful role to EC2 or Lambda, then run code there, gains that role's permissions.
What I'd do โ
- Scope
iam:PassRoleto specific role ARNs and use theiam:PassedToServicecondition (e.g. onlylambda.amazonaws.com). - Find risky combinations with tools like PMapper or Cloudsplaining.
- Alert on
PassRoleof admin roles in CloudTrail (it shows up on the service API call, such asRunInstancesorCreateFunction). - Keep admin roles not passable by default.
Why โ PassRole is the most common path from limited to full access in AWS.
Interview tip โ Name the pattern: "PassRole plus compute create equals escalation".
Q147 A healthcare customer requires HIPAA compliance. What changes for your cloud platform?
Intermediate
Situation read โ HIPAA protects PHI. In the cloud it starts with a BAA and using only eligible services.
What I'd do โ
- Sign the BAA with the cloud provider and use only HIPAA-eligible services for PHI.
- Encrypt PHI at rest (KMS) and in transit (TLS everywhere, including internal).
- Strict access control, MFA, and audit logs of PHI access kept for six years where policy requires.
- Keep PHI out of logs, traces and error messages; add redaction.
- Backups and DR plans documented and tested.
Why โ Many HIPAA findings come from PHI ending up in logs or tools that are not covered by the BAA.
Interview tip โ Mention "BAA" and "HIPAA-eligible services" early.
Q148 A CSPM flags 200 IAM users with access keys older than 365 days. What is your plan?
Beginner
Situation read โ Old static keys are a top breach cause. Most are probably unused or replaceable.
What I'd do โ
- Pull the credential report and sort by
access_key_1_last_used_date. - Deactivate keys unused for 90+ days, with a notice to owners; delete after 30 more days.
- For active keys, move workloads to roles (OIDC for CI, instance or pod roles for apps).
- For the few that must stay, set up rotation and an owner.
- Add a Config rule (
access-keys-rotated) to alert going forward.
Why โ Deactivating first is reversible, which reduces fear of breaking something.
Interview tip โ "Deactivate, wait, delete" is the safe pattern.
Q149 Leadership asks for ISO 27001 certification. What parts land on the DevOps team?
Intermediate
Situation read โ ISO 27001 is a management system with Annex A controls. DevOps owns many technical controls.
What I'd do โ
- Map Annex A technological controls to our setup: access control, logging and monitoring, secure development, configuration management, backup, vulnerability management.
- Document processes we already follow (change management via PRs, incident response runbooks).
- Produce evidence automatically from tools: IaC repos, CI logs, scan reports, access reviews.
- Feed the risk register with technical risks and treatments.
- Prepare for internal audit before the certification audit.
Why โ Many controls already exist in good DevOps practice; the gap is usually documentation and evidence.
Interview tip โ The 2022 revision grouped controls into four themes; mention "technological controls".
Q150 How do you give engineers read-only access to production for troubleshooting without exposing sensitive data?
Advanced
Situation read โ AWS ReadOnlyAccess includes reading S3 objects, secrets metadata and DynamoDB items. That is data access, not just config visibility.
What I'd do โ
- Start from
ViewOnlyAccessor a custom role that covers describe/list actions. - Explicitly deny data-plane reads:
s3:GetObject,dynamodb:GetItem,dynamodb:Scan,secretsmanager:GetSecretValue,kms:Decrypt. - Give logs and metrics access through the observability platform with PII redaction.
- Data access needs a JIT request with justification.
Why โ Being able to see the infrastructure is different from being able to read customer data.
Interview tip โ Contrasting ReadOnlyAccess with ViewOnlyAccess is a strong detail.
Vulnerability Management and OWASP
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q151 A pentest report shows SQL injection in a search endpoint of a Java service. How do you handle it end to end?
Beginner
Situation read โ Confirmed injection (OWASP A03) in production code. Fix the code, check whether it was exploited, and stop the same class of bug from coming back.
What I'd do โ
- Reproduce from the report in staging and confirm the vulnerable query.
- Replace string concatenation with a parameterised query:
PreparedStatement ps = conn.prepareStatement( "SELECT id, name FROM products WHERE name LIKE ?"); ps.setString(1, "%" + term + "%"); - Search access and database logs for injection payloads (
' OR 1=1,UNION SELECT,sleep() to see if it was already abused. - Add a Semgrep or CodeQL rule for string-built SQL so the pattern fails in PR.
- Make sure the app's DB user has no DDL rights, so the next bug has a smaller blast radius.
Why โ One fix closes one hole; the rule closes the class; least-privilege DB access limits what an attacker can do with the next one.
Interview tip โ Always mention checking logs for prior exploitation, not just patching.
Q152 A scanner reports 4,000 open CVEs across 300 images. The team can fix maybe 100 a month. How do you prioritise?
Intermediate
Situation read โ CVSS alone will make everything look urgent. We need to rank by real risk.
What I'd do โ
- Drop CVEs in images that are not running anywhere (join scan data with what is deployed).
- Put anything in the CISA KEV catalogue at the top, then sort by EPSS score.
- Weight by exposure: internet-facing and data-holding services first.
- Use reachability (Snyk, Endor Labs, govulncheck for Go) or VEX to mark packages that are present but never loaded.
- Group by fix: one base image bump often closes hundreds of CVEs at once.
trivy image --severity CRITICAL,HIGH --ignore-unfixed --format json app:1.4 \ | jq '[.Results[].Vulnerabilities[]?.PkgName] | group_by(.) | map({pkg: .[0], n: length}) | sort_by(-.n)'
Why โ KEV plus EPSS plus exposure is a defensible ranking; base image rebuilds give the biggest win per hour.
Interview tip โ Say "fix by package, not by CVE".
Q153 A user reports they can see another customer's invoice by changing the ID in the URL. What do you do?
Beginner
Situation read โ This is an IDOR, part of Broken Access Control (OWASP A01), and it is a data breach in progress.
What I'd do โ
- Treat it as a security incident: page the owning team and AppSec.
- Hot-fix the handler to check ownership on the server side, not just authentication:
invoice = Invoice.get(invoice_id) if invoice.tenant_id != current_user.tenant_id: abort(404) - Query access logs for requests where the user's tenant differs from the invoice's tenant to measure exposure.
- Involve legal and privacy; exposed personal data may trigger notification duties.
- Audit other endpoints that take object IDs and add authorization tests to CI.
Why โ Sequential IDs make enumeration trivial. Returning 404 instead of 403 also avoids confirming that the object exists.
Interview tip โ UUIDs reduce guessing but are not access control.
Q154 A webhook feature lets users enter a URL, and a pentester used it to read the cloud metadata endpoint. How do you fix it?
Advanced
Situation read โ Classic SSRF (OWASP A10). The server fetched http://169.254.169.254/ on behalf of the attacker and could leak instance credentials.
What I'd do โ
- Rotate the instance role credentials immediately and check CloudTrail for their use from outside our IPs.
- Enforce IMDSv2 with hop limit 1 so a plain GET cannot read credentials.
- In code: resolve the hostname, reject private, loopback, link-local and metadata ranges, then connect to the resolved IP (prevents DNS rebinding). Disable redirects or re-check each hop.
- Route outbound webhook calls through an egress proxy that only allows public destinations.
- Run the webhook sender in an isolated network segment with no internal access.
Why โ Blocklists in code alone get bypassed (decimal IPs, IPv6, redirects). Network isolation and IMDSv2 are the backstops.
Interview tip โ Mention DNS rebinding; it shows you know why "validate the URL string" is not enough.
Q155 A team still runs Log4j 2.14 in an internal service and says it is not internet-facing. How do you respond?
Intermediate
Situation read โ Log4Shell (CVE-2021-44228) is in CISA KEV and triggers on any logged attacker-controlled string, including data that arrives through queues or internal APIs.
What I'd do โ
- Check whether any user-controlled input reaches its logs (headers, payloads forwarded by other services).
- Upgrade to a current 2.x release (2.17.1 or later for Java 8+); it is usually a drop-in change.
- If the upgrade is blocked, remove the
JndiLookupclass from the jar as a temporary measure:zip -q -d log4j-core-2.14.1.jar org/apache/logging/log4j/core/lookup/JndiLookup.class - Block outbound LDAP/RMI egress from the service.
- Set a hard deadline; "internal" is not an accepted risk for a KEV entry.
Why โ Internal services get reached through lateral movement and data pipelines. Exploited CVEs are not negotiable.
Interview tip โ Note that the old formatMsgNoLookups flag was found to be incomplete.
Q156 A security review finds passwords stored as unsalted MD5 hashes. How do you migrate without forcing every user to reset?
Advanced
Situation read โ Cryptographic failure (OWASP A02). Unsalted MD5 cracks in seconds with GPUs and rainbow tables.
What I'd do โ
- Wrap existing hashes now: store
argon2id(md5_hash)for every user in one migration, so no plain MD5 remains at rest. - On next successful login, verify via the wrapped path, then re-hash the plain password with Argon2id (or bcrypt cost 12+) directly and mark the record upgraded.
- After a fixed period, force reset for accounts that never logged in.
- Treat the old database dumps and backups as compromised data; check who had access.
- Add a test or lint rule blocking
md5/sha1for password handling.
Why โ Wrapping protects everyone today, not only those who log in again.
Interview tip โ "Wrap, then upgrade on login" is the textbook migration pattern.
Q157 Your DAST scan in staging finds reflected XSS in a React app. The developers say React escapes everything. Who is right?
Intermediate
Situation read โ React escapes values rendered in JSX, but there are known escape hatches.
What I'd do โ
- Look for
dangerouslySetInnerHTML,href={userInput}(allowsjavascript:URLs), direct DOM writes (innerHTML,document.write) and server-rendered templates outside React. - Fix the source: sanitise HTML with DOMPurify, validate URL schemes to
http/https. - Add a strict Content Security Policy as defence in depth:
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-r4nd0m'; object-src 'none'; base-uri 'none' - Add a Semgrep rule (
react-dangerouslysetinnerhtml) to PR scanning.
Why โ Frameworks reduce XSS a lot but do not eliminate it. The DAST hit is real until proven otherwise.
Interview tip โ Name the escape hatches; it shows you have actually read React code.
Q158 A critical CVE in OpenSSL is announced. How do you find every affected place within an hour?
Intermediate
Situation read โ OpenSSL lives in base images, statically linked binaries and VM AMIs. We need inventory, not grep.
What I'd do โ
- Query the stored SBOMs (Dependency-Track, or Grype against SBOM files) for the affected package and version range:
for f in sboms/*.cdx.json; do grype sbom:$f --only-fixed -q | grep -i openssl && echo "$f"; done - Cross-reference with what is running: Kubernetes image list, ECR scan results, AWS Inspector for EC2.
- Check managed services and vendors separately (load balancers, appliances).
- Rank by exposure: TLS-terminating edge services first.
- Rebuild base images once, then trigger rebuilds of dependent images.
Why โ If SBOMs are generated at build time and stored, this is a query. Without them it becomes a week of guessing.
Interview tip โ This is the best answer to "why do SBOMs matter?"
Q159 Security wants all critical CVEs fixed in 7 days, but some base image CVEs have no upstream fix. How do you report this honestly?
Beginner
Situation read โ An SLA that cannot be met by anyone becomes ignored. Unfixable findings need a separate track.
What I'd do โ
- Split the metric: "fixable and overdue" versus "no fix available".
- For no-fix items, record a risk acceptance with an expiry and a compensating control (not reachable, network-restricted).
- Run scanners with
--ignore-unfixedfor gating, but keep full data for reporting. - Re-check daily; when a fix appears, the SLA clock starts.
- Where possible, switch to a minimal base (distroless, Chainguard, Alpine) that does not contain the package at all.
Why โ Leadership trusts metrics that separate what we can act on from what we cannot.
Interview tip โ "The SLA clock starts when a fix exists" is a common, reasonable policy.
Q160 A developer uses pickle.loads() on data received from an API. What is the risk and what do you recommend?
Intermediate
pickle.loads() on data received from an API. What is the risk and what do you recommend?Situation read โ Insecure deserialization (now folded into OWASP A08, Software and Data Integrity Failures). Unpickling attacker data gives remote code execution.
What I'd do โ
- Replace pickle with a data-only format: JSON with schema validation (pydantic), or protobuf.
- If pickle is unavoidable between trusted services, sign the payload with HMAC and verify before loading.
- Search the codebase for similar sinks:
pickle.loads,yaml.loadwithoutSafeLoader, JavaObjectInputStream,Marshal.loadin Ruby. - Enable Bandit rules B301 and B506 in CI.
bandit -r src/ -t B301,B506
Why โ Deserialisers that build arbitrary objects execute code during loading; validation afterwards is too late.
Interview tip โ yaml.safe_load versus yaml.load is a frequent follow-up.
Q161 An API lets users update their profile with a JSON body, and a tester set "role": "admin" successfully. What went wrong?
Beginner
"role": "admin" successfully. What went wrong?Situation read โ Mass assignment, listed in the OWASP API Top 10 as Broken Object Property Level Authorization. The handler bound the whole request body to the user model.
What I'd do โ
- Revert the escalated accounts and check logs for
roleoris_adminin update payloads. - Use an explicit allowlist DTO for the endpoint:
class ProfileUpdate(BaseModel): display_name: str | None = None avatar_url: HttpUrl | None = None model_config = {"extra": "forbid"} - Move role changes to a separate admin-only endpoint with its own authorization check.
- Add an API test that sends forbidden fields and expects a 4xx.
Why โ Binding whole objects is convenient and dangerous; allowlists make the attack surface explicit.
Interview tip โ Reference the OWASP API Security Top 10 (2023), not only the web Top 10.
Q162 A login endpoint has no rate limit, and you see 50,000 failed logins from 3,000 IPs in an hour. What do you do?
Intermediate
Situation read โ Credential stuffing with leaked password lists, spread across IPs to dodge simple limits (OWASP A07).
What I'd do โ
- Turn on WAF rate-based rules and bot control at the edge (AWS WAF, Cloudflare), keyed on IP and on username.
- Add progressive delays and CAPTCHA after a few failures per account.
- Check for successful logins from the same IPs; force reset and revoke sessions for those accounts.
- Check passwords against breached lists at sign-up and change (HIBP k-anonymity API).
- Push MFA adoption, starting with high-value accounts.
Why โ Per-IP limits fail against distributed attacks; per-account signals and MFA stop the actual takeover.
Interview tip โ Distinguish brute force (one account, many passwords) from stuffing (many accounts, leaked pairs).
Q163 How do you run a bug bounty or vulnerability disclosure programme without overwhelming the team?
Intermediate
Situation read โ External reports are valuable but noisy. Start small and build triage capacity first.
What I'd do โ
- Publish a
security.txtand a disclosure policy with scope, safe harbour and response times:Contact: mailto:[email protected] Policy: https://example.com/security-policy Expires: 2027-06-30T00:00:00.000Z - Start with a private, invite-only programme on a platform (HackerOne, Bugcrowd, Intigriti) that handles first-level triage.
- Define scope tightly (one or two domains), exclude DoS and social engineering.
- Route valid reports into the normal vulnerability workflow with severity-based SLAs.
- Go public only when mean time to triage is consistently low.
Why โ A public programme with no triage capacity burns researcher goodwill and team time.
Interview tip โ A VDP (no rewards) usually comes before a paid bounty.
Q164 A new CVE with CVSS 9.8 hits a library you use, but only in a function you never call. Do you still patch urgently?
Advanced
Situation read โ CVSS scores the vulnerability, not our exposure. Reachability matters, but we must prove it, not assume it.
What I'd do โ
- Verify reachability with a tool that does call-graph analysis (govulncheck for Go, Snyk or Endor reachability for Java/JS) and a code search for the vulnerable function.
govulncheck ./... - Check transitive callers: a framework we use may call the function for us.
- If not reachable, publish a VEX statement (
not_affected, justificationvulnerable_code_not_in_execute_path) and move it to the normal patch cycle. - If it is in KEV or has a public exploit, patch anyway; the cost of being wrong is high.
- Schedule the bump in the next dependency update batch either way.
Why โ Reachability-based triage cuts noise by a large factor, but the decision must be documented.
Interview tip โ "Deprioritise with evidence, never ignore" is the right tone.
Q165 Developers keep asking why the same CVE shows up as Critical in one scanner and Medium in another. How do you explain and handle it?
Beginner
Situation read โ Scanners pull severity from different sources: NVD CVSS, the distro's own advisory, or GitHub Advisory Database.
What I'd do โ
- Explain that distro vendors (Debian, Red Hat, Ubuntu) rescore based on how the package is built and used in their distro.
- Pick one source of truth per finding type: for OS packages use the vendor severity, for language packages use GHSA/NVD.
- Configure the aggregator (DefectDojo, Security Hub) to normalise severity and deduplicate by CVE + package + asset.
- Document the policy so audit questions have one answer.
Why โ Consistent severity makes SLAs enforceable and avoids arguments in every PR.
Interview tip โ Trivy shows SeveritySource in its JSON output; mentioning it is a nice detail.
Q166 A pentester found your app's admin panel exposed at /admin on the public domain. What do you change?
Beginner
/admin on the public domain. What do you change?Situation read โ Security misconfiguration (OWASP A05). Admin interfaces should not share the public attack surface.
What I'd do โ
- Block
/adminat the ingress or WAF for public traffic immediately. - Move admin to a separate hostname reachable only through VPN, zero-trust access (Cloudflare Access, AWS Verified Access, IAP) or the internal network.
- Require SSO with MFA for admin users.
- Add the check to DAST and an external attack-surface scan so it is caught next time.
Why โ Even with strong authentication, exposing admin surfaces invites brute force and exploit attempts against the framework.
Interview tip โ Defence in depth: network restriction plus strong authentication.
Q167 A team stores user uploads in S3 and serves them from the main domain. A tester uploaded an HTML file that ran JavaScript. What do you do?
Advanced
Situation read โ Stored XSS through file upload, running in the main app's origin, so it can read session data.
What I'd do โ
- Serve user content from a separate, cookieless domain (for example
usercontent-example.com), so scripts cannot reach app cookies or storage. - Set
Content-Disposition: attachmentand the correctContent-Typeon objects; addX-Content-Type-Options: nosniff. - Validate file types by content (magic bytes), not by extension, and limit allowed types.
- Scan uploads for malware (S3 malware protection in GuardDuty, or ClamAV in a Lambda).
- Use presigned URLs with short expiry for private files.
Why โ Origin isolation is the strongest fix; that is why large providers host user content on separate domains.
Interview tip โ Mention the separate-domain pattern; it shows real-world experience.
Q168 Your Node.js service uses JWTs, and a tester forged a token with "alg": "none". How do you fix it?
Intermediate
"alg": "none". How do you fix it?Situation read โ The verification code accepted whatever algorithm the token declared. Anyone can mint admin tokens.
What I'd do โ
- Pin allowed algorithms in verification:
jwt.verify(token, publicKey, { algorithms: ['RS256'], issuer: 'https://auth.example.com', audience: 'api' }); - Upgrade the JWT library; current versions reject
noneby default. - Validate
exp,issandaud, and keep access tokens short-lived (5โ15 minutes). - Rotate the signing key and invalidate active sessions if forged tokens were used.
- Look for the related key-confusion bug (RS256 public key used as HS256 secret).
Why โ Never let the token tell the server how to verify it.
Interview tip โ "Algorithm allowlist" is the key phrase.
Q169 Leadership asks you to measure how quickly vulnerabilities get fixed. Which metrics do you set up?
Beginner
Situation read โ We need metrics that show speed and backlog without encouraging gaming.
What I'd do โ
- Mean time to remediate (MTTR) by severity, from first detection to fix deployed.
- SLA compliance: percentage of findings fixed inside the SLA window.
- Open findings by age bucket (0โ30, 31โ90, 90+ days), split by fixable and not fixable.
- New versus closed per month (are we keeping up?).
- Percentage of exceptions that expired without renewal.
Why โ MTTR alone hides a growing backlog; age buckets and burn-down show the trend.
Interview tip โ Measure from detection, not from ticket creation.
Q170 A legacy PHP app cannot be patched for months, and it has known vulnerabilities. How do you protect it in the meantime?
Advanced
Situation read โ We need compensating controls around an app we cannot fix, and a plan to retire or rewrite it.
What I'd do โ
- Put it behind a WAF with managed rule sets (OWASP CRS, AWS managed rules) and virtual patches for the known CVEs.
- Restrict access: IP allowlist, VPN or identity-aware proxy if users allow it.
- Isolate the host: separate subnet, no outbound internet except required endpoints, minimal IAM.
- Read-only filesystem where possible; file integrity monitoring on the web root.
- Extra logging and alerting on that app; record a formal risk acceptance with a retirement date.
Why โ Virtual patching buys time; isolation limits the damage if it is still exploited.
Interview tip โ Always tie compensating controls to a deadline, or they become permanent.
Q171 An AppSec engineer wants to run OWASP ZAP full scans against production nightly. Do you agree?
Intermediate
Situation read โ Active scans submit forms and fuzz inputs. In production they can create junk data, send emails and trigger alerts.
What I'd do โ
- Run full active scans in a production-like staging environment with seeded test data.
- In production, run only the passive baseline scan, which does not attack:
docker run --rm -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://app.example.com -r report.html - Whitelist the scanner's IP with the WAF and SOC so alerts are expected.
- Use authenticated scans in staging to cover pages behind login.
Why โ Production safety beats coverage; staging scans find the same code bugs.
Interview tip โ Know the difference between zap-baseline.py and zap-full-scan.py.
Q172 How do you handle a zero-day in a product you use (for example a VPN appliance) where the vendor has no patch yet?
Advanced
Situation read โ Edge appliances are a top target in recent years. With no patch, we reduce exposure and hunt for compromise.
What I'd do โ
- Apply the vendor's published mitigation or workaround immediately.
- Restrict the management interface to internal networks only.
- Run the vendor's integrity checker and hunt for published IOCs in logs.
- Consider temporarily shutting the service or routing users to an alternative (zero-trust access) if exploitation is active.
- Patch on day zero of the fix; plan to replace the appliance class if it keeps happening.
Why โ Appliances often lack EDR, so assume compromise is possible and look for evidence.
Interview tip โ Mention following CISA advisories and the vendor PSIRT feed.
Q173 Developers ask for a list of the OWASP Top 10 risks that DevOps can actually help with. What do you tell them?
Beginner
Situation read โ Several Top 10 (2021) categories are infrastructure and pipeline problems, not only code.
What I'd do โ
- A05 Security Misconfiguration: IaC scanning, hardened defaults, CSPM.
- A06 Vulnerable and Outdated Components: SCA, image scanning, Renovate.
- A08 Software and Data Integrity Failures: signed artifacts, protected CI, provenance.
- A09 Security Logging and Monitoring Failures: central logs, alerting, retention.
- A02 Cryptographic Failures: TLS everywhere, KMS-managed keys, cert-manager.
- A10 SSRF: IMDSv2, egress controls.
Why โ It shows that DevSecOps owns real Top 10 risk, not only CI plugins.
Interview tip โ Mention that OWASP published a 2025 update; know the 2021 list well and what changed.
Q174 A vulnerability is found in an internal shared library used by 60 services. How do you get it fixed everywhere quickly?
Intermediate
Situation read โ The fix is one change; the hard part is rolling it into 60 repos and deploying.
What I'd do โ
- Release a patched library version with a clear security advisory.
- Use Renovate or Dependabot with a grouped, high-priority rule to open PRs in all consumers at once.
- Track adoption with SBOM queries or a dashboard of version per service.
- Escalate remaining repos after the SLA; for unowned ones, the platform team merges.
- Optionally block old versions at build time with a policy in the shared pipeline.
Why โ Automated PRs plus tracking turn a 60-team coordination problem into a dashboard.
Interview tip โ A central dependency bot is the key enabler.
Q175 A customer security questionnaire asks how you prevent the OWASP Top 10 in your SDLC. How do you answer credibly?
Intermediate
Situation read โ Customers want evidence of process, not a list of tools.
What I'd do โ
- Map each category to a control: design (threat modelling), code (SAST, peer review), dependencies (SCA), deploy (IaC scanning, signed images), runtime (WAF, monitoring).
- Provide evidence: SOC 2 report, pentest summary letter, SDLC policy.
- State SLAs for remediation and the frequency of external pentests.
- Keep a maintained answer library (Vanta, Drata, a trust centre) so answers stay consistent.
Why โ Consistent, evidence-backed answers speed up sales and survive follow-up questions.
Interview tip โ A trust centre page saves weeks of questionnaires.
Incident Response and Governance
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q176 You find a ransom note in an S3 bucket and most objects have been deleted. What do you do in the first hour?
Advanced
Situation read โ Cloud ransomware usually means stolen credentials with s3:DeleteObject or s3:PutObject rights. Contain the identity first, then recover data.
What I'd do โ
- Find the principal in CloudTrail data events (or S3 server access logs):
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteObjects \ --start-time 2026-11-08T00:00:00Z --max-results 50 - Disable that access key or attach a deny-all policy to the role; revoke active sessions.
- Add a bucket policy denying writes and deletes to everyone except the IR role.
- Recover: if versioning was on, remove delete markers; otherwise restore from AWS Backup or the replicated bucket.
- Check for exfiltration (
GetObjectvolume) because that changes the notification duties. - Do not pay or contact the attacker without legal and leadership involvement.
Why โ Versioning, Object Lock and cross-account backups decide whether this is a bad day or a business-ending one.
Interview tip โ Mention S3 Object Lock in compliance mode for critical data.
Q177 Your company has its first real security incident and people are all talking at once in Slack. How do you organise the response?
Beginner
Situation read โ Without roles, people duplicate work, destroy evidence and leak details. Structure first.
What I'd do โ
- Name an incident commander who coordinates but does not do hands-on work.
- Assign roles: technical lead, scribe (timeline), communications lead (internal, customers), and a legal/privacy contact.
- Open a private incident channel, separate from the general one, and a running timeline doc.
- Follow the phases: identify, contain, eradicate, recover, lessons learned.
- Schedule regular status updates (every 30โ60 minutes) so leadership stops interrupting responders.
Why โ A clear commander and timeline make decisions faster and keep evidence for later.
Interview tip โ Reference NIST SP 800-61 for the incident handling lifecycle.
Q178 An EC2 instance is confirmed compromised. A colleague wants to terminate it immediately. What do you do instead?
Intermediate
Situation read โ Terminating destroys memory and disk evidence. We need to contain without losing forensics.
What I'd do โ
- Isolate: replace its security groups with an empty "quarantine" group and detach it from the load balancer and Auto Scaling group.
aws autoscaling detach-instances --instance-ids i-0abc --auto-scaling-group-name web --should-decrement-desired-capacity aws ec2 modify-instance-attribute --instance-id i-0abc --groups sg-0quarantine - Enable termination protection and tag it
incident=IR-2026-014. - Capture memory (if tooling is available, e.g. AVML) and snapshot all EBS volumes.
- Detach or revoke the instance profile credentials (revoke older sessions on the role).
- Analyse snapshots in a separate forensics account, never on the live host.
Why โ Evidence tells us how they got in and what they touched; without it we cannot be sure the fix is complete.
Interview tip โ Note that changing security groups does not cut already-tracked connections; NACLs do.
Q179 Falco reports a reverse shell from a pod in EKS. How do you contain it while keeping evidence?
Advanced
Situation read โ Deleting the pod loses everything. We isolate it at the network level and capture its state.
What I'd do โ
- Label the pod and apply a deny-all NetworkPolicy that selects that label:
kubectl label pod api-7d9f -n prod quarantine=true kubectl apply -f - <<'YAML' apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: {name: quarantine, namespace: prod} spec: podSelector: {matchLabels: {quarantine: "true"}} policyTypes: [Ingress, Egress] YAML - Remove app labels so the Service stops routing to it; the ReplicaSet creates a clean replacement.
- Cordon the node; snapshot its volume; capture container filesystem with
kubectl cpor the runtime. - Check the pod's service account permissions and cloud role usage in audit logs and CloudTrail.
- Find the entry point (vulnerable dependency, exposed endpoint) and patch before scaling back.
Why โ Relabelling detaches the pod from traffic and its controller without killing it.
Interview tip โ The "remove labels so the ReplicaSet orphans it" trick impresses interviewers.
Q180 After a security incident, leadership wants to know who to blame. How do you run the post-incident review?
Beginner
Situation read โ Blame makes people hide mistakes next time. We look for system causes.
What I'd do โ
- Write a factual timeline: detection, decisions, actions, with timestamps.
- Ask "why was this possible?" repeatedly to find contributing factors (missing control, unclear ownership, alert ignored).
- Separate what went well from what did not, including detection time.
- Create action items with owners and dates, tracked like any other work.
- Share a redacted version widely so other teams learn.
Why โ Blameless reviews produce honest data, and honest data produces real fixes.
Interview tip โ Report time to detect and time to contain as headline numbers.
Q181 You are asked to run a security tabletop exercise for the engineering team. How do you design it?
Intermediate
Situation read โ A tabletop tests people and process without touching systems. A realistic scenario matters most.
What I'd do โ
- Pick a likely scenario: leaked CI token pushing a malicious image, or ransomware in the main AWS account.
- Invite responders plus legal, comms and a senior leader.
- Reveal the scenario in stages ("injects"): first alert, then evidence of exfiltration, then a journalist calls.
- At each stage ask: who decides, what do you check, what tool, where is the runbook?
- Record gaps (missing access, unknown owners, no log retention) and turn them into tickets.
Why โ It is cheap and surfaces gaps like "nobody has break-glass access" before a real incident does.
Interview tip โ Run one at least yearly; many compliance frameworks expect it.
Q182 A developer's GitHub account was compromised and the attacker pushed a commit to main that adds a postinstall script. What now?
Advanced
main that adds a postinstall script. What now?Situation read โ Source compromise. The malicious code may have been built, published and deployed already.
What I'd do โ
- Suspend the user in the org, revoke their sessions, PATs, SSH keys and OAuth app grants.
- Revert the commit, and stop CI and deployments for affected repos.
- Identify every artifact built from the bad commit (CI run logs, image digests, published packages) and block or unpublish them.
- Roll back deployments to the last known good digest; rotate secrets that the CI job could read.
- Review the org audit log for other actions by that account (new deploy keys, webhooks, branch protection changes).
- Close the gap: require PRs with review on
main, signed commits, and phishing-resistant MFA (passkeys).
Why โ The commit is the smallest part; the artifacts it produced and the access it used are the real exposure.
Interview tip โ Mention auditing the GitHub org audit log for persistence.
Q183 Customer personal data of EU users was exposed. How fast must you act, and who is involved?
Intermediate
Situation read โ Under GDPR, the controller must notify the supervisory authority within 72 hours of becoming aware of a personal data breach, unless it is unlikely to result in risk to individuals.
What I'd do โ
- Bring in the DPO and legal immediately; the 72-hour clock has started.
- Determine scope: data categories, number of records and people, time window, whether data was encrypted.
- Contain and preserve evidence in parallel.
- Legal decides on authority notification and whether individuals must be told (high risk).
- Document everything, including decisions not to notify; GDPR requires a breach record.
Why โ Engineers provide facts fast; legal makes notification decisions. Good logs make the scoping possible.
Interview tip โ Other regimes (state laws in the US, sector rules) have their own timelines; legal tracks them.
Q184 You discover 40 security exceptions that expired months ago and nobody acted. How do you fix the process?
Beginner
Situation read โ Exceptions without enforcement are permanent ignores.
What I'd do โ
- Review each expired exception with the owner: fix, renew with fresh justification, or escalate.
- Make expiry machine-enforced: scanners stop honouring the suppression after its date. For Trivy:
# .trivyignore.yaml vulnerabilities: - id: CVE-2025-12345 expired_at: 2026-12-31 statement: "Not reachable; tracked in SEC-482" - Send reminders 14 days before expiry to the owner and their manager.
- Report expired exceptions on the team security scorecard.
Why โ Automation removes the dependency on someone remembering.
Interview tip โ "Exceptions must expire on their own" is the key line.
Q185 AWS sends an abuse notice saying one of your EC2 instances is scanning other hosts on the internet. What do you do?
Beginner
Situation read โ The instance is almost certainly compromised (or an unapproved tool is running). AWS may restrict the account if we do not respond.
What I'd do โ
- Isolate the instance with a quarantine security group and snapshot volumes for forensics.
- Check GuardDuty findings and VPC Flow Logs for the outbound traffic pattern.
- Find the entry point: exposed SSH, unpatched service, leaked key.
- Rebuild from a clean AMI rather than cleaning the host.
- Reply to the AWS abuse case with what you found and the actions taken.
Why โ A compromised host cannot be trusted after cleanup; rebuild is the safe option.
Interview tip โ Always respond to the abuse report; ignoring it can lead to account suspension.
Q186 An S3 bucket with customer files was public for three weeks. How do you work out what was actually accessed?
Intermediate
Situation read โ The answer depends entirely on which logs existed during those three weeks.
What I'd do โ
- Block public access on the bucket now (
aws s3api put-public-access-block). - Check sources: S3 server access logs, CloudTrail data events (if enabled for the bucket), CloudFront logs if fronted.
- Query with Athena for
GETrequests from principals outside our accounts:SELECT remoteip, key, requestdatetime FROM s3_access_logs WHERE operation = 'REST.GET.OBJECT' AND requester = '-' ORDER BY requestdatetime; - If no logs exist, legal must assume all objects were exposed.
- Enable account-level Block Public Access and access logging for all data buckets.
Why โ Without data-access logs, you cannot prove a negative, and the breach scope becomes "everything".
Interview tip โ This is the best argument for turning on data-event logging for sensitive buckets.
Q187 Your public API is hit by a layer 7 DDoS at 2 million requests per minute. How do you respond?
Intermediate
Situation read โ Application-layer floods look like real traffic, so network-level DDoS protection alone does not stop them.
What I'd do โ
- Identify patterns in edge logs: path, user agent, ASN, country, header fingerprints (JA3/JA4).
- Add WAF rules: rate limits per IP and per path, block or challenge matching signatures, geo rules if justified.
- Cache what can be cached at the CDN; serve static error pages from the edge.
- Protect the origin: allow traffic only from the CDN (origin access control or header secret).
- Engage the provider's DDoS response team if subscribed (AWS Shield Advanced SRT, Cloudflare).
Why โ Pushing the decision to the edge stops the load before it reaches compute and databases.
Interview tip โ Mention that autoscaling during an attack mostly scales the bill.
Q188 A product manager wants to ship a feature with a known high-severity vulnerability because of a customer deadline. How do you handle it?
Beginner
Situation read โ This is a business risk decision, not a technical one. Our job is to make the risk clear and get the right person to own it.
What I'd do โ
- Explain the risk in business terms: what an attacker could do and the likely impact.
- Offer options: ship with a compensating control (feature flag, WAF rule, limited rollout), or delay a few days.
- If they still want to ship, record a formal risk acceptance signed by the accountable owner, with a fix date.
- Track the fix like any SLA item.
Why โ Security advises; the business owner accepts risk. Documented decisions protect everyone.
Interview tip โ Avoid being "the department of no"; present options.
Q189 Your CI/CD SaaS provider announces a breach and advises customers to rotate all secrets. What is your plan?
Advanced
Situation read โ Every secret stored in that provider, and every token it could mint, must be treated as compromised.
What I'd do โ
- Export the inventory of secrets: org, project and context variables, SSH deploy keys, cloud integrations.
- Rotate in risk order: cloud credentials, production database, signing keys, then third-party API tokens.
- Review cloud audit logs (CloudTrail, GCP audit) for use of those credentials from unknown IPs since the breach window.
- Check for persistence: new IAM users, keys, roles, or modified CI configs.
- Long-term: replace stored cloud keys with OIDC federation so there is nothing to steal.
Why โ Rotation without log review misses attackers who already used the keys to create their own access.
Interview tip โ Cite OIDC as the structural fix; it shrinks the blast radius of the next provider breach.
Q190 Security asks which logs you must keep to investigate an incident months later. What do you set up?
Intermediate
Situation read โ Many breaches are discovered months after initial access. Short retention means no answers.
What I'd do โ
- Control plane: CloudTrail (all regions, org trail), Kubernetes API audit logs, IdP sign-in logs, GitHub audit log.
- Network: VPC Flow Logs, DNS query logs (Route 53 Resolver), load balancer and WAF logs.
- Data access: S3 data events and database audit logs for sensitive stores.
- Store in a separate log archive account with Object Lock, 1 year hot and longer in cold storage as required.
- Make them searchable (Athena, a SIEM) and test a query quarterly.
Why โ Immutable, central logs with long retention are the base of every investigation.
Interview tip โ PCI DSS asks for 12 months of audit logs with 3 months immediately available.
Q191 You notice your GitHub Actions minutes doubled and many runs come from PRs by unknown forks. What is happening?
Intermediate
Situation read โ Likely abuse of public CI for crypto mining, or probes trying to reach secrets through PR workflows.
What I'd do โ
- Check the runs: workflow files modified in the PR, unusual binaries, long run times.
- Require approval for workflow runs from outside contributors (repository Actions settings).
- Make sure untrusted PR workflows use
pull_request, notpull_request_target, and have no secrets. - Set
permissions: read-allor narrower as the defaultGITHUB_TOKENscope. - Never run public fork PRs on self-hosted runners.
Why โ Public repos invite free compute abuse; approvals and least-privilege tokens remove the payoff.
Interview tip โ Self-hosted runners on public repos are a well-known escalation path.
Q192 Database audit logs show an engineer exported 2 million customer records to their laptop late at night. How do you proceed?
Advanced
Situation read โ Could be a legitimate task or insider data theft. This needs care, discretion and HR/legal from the start.
What I'd do โ
- Do not confront the person directly; escalate to security leadership, HR and legal.
- Preserve evidence: database audit logs, VPN logs, EDR data from the laptop, DLP alerts.
- Check for a business justification (ticket, manager request).
- If not justified, legal decides on access suspension and next steps; IT restricts access in coordination.
- Fix the control gap: no bulk exports from production without approval, data masked in non-prod, JIT DB access.
Why โ Insider cases have legal and HR implications; acting alone can ruin the investigation.
Interview tip โ Highlight least privilege and JIT access as the prevention.
Q193 Teams complain that the platform team changes Kyverno policies without warning and breaks deployments. How do you govern policy changes?
Intermediate
Situation read โ Policies are code that affects every team. They need the same change process as code.
What I'd do โ
- Keep policies in Git with PR review, including a reviewer from consuming teams for major changes.
- Test policies in CI against sample manifests (
kyverno test) and a dry run against live resources.kyverno apply policies/ --cluster --policy-report - Roll out every new policy in
Auditmode first, publish the violations, then switch toEnforceon an announced date. - Publish a changelog and a channel for policy announcements.
Why โ Audit-first rollout turns surprises into planned migrations.
Interview tip โ "Audit, communicate, enforce" is the rollout pattern.
Q194 An engineer entered their SSO password and MFA code into a fake login page. What do you do?
Beginner
Situation read โ Real-time phishing proxies can capture both the password and the session cookie, so MFA codes do not stop it.
What I'd do โ
- Reset the password and revoke all sessions and tokens in the IdP.
- Review IdP logs for sign-ins from new IPs or devices, and downstream app logs (GitHub, AWS, Slack).
- Check for persistence: new MFA devices, OAuth grants, API tokens.
- Block the phishing domain in DNS filtering and report it.
- Move to phishing-resistant MFA (FIDO2 security keys or passkeys) for everyone with production access.
Why โ OTP codes can be relayed; FIDO2 is bound to the real domain.
Interview tip โ Thank the reporter; fast reporting is what you want to encourage.
Q195 Your company acquires a startup with 12 AWS accounts and unknown security posture. How do you integrate them?
Advanced
Situation read โ Unknown accounts may contain old keys, public resources or an existing compromise. Assess before connecting networks.
What I'd do โ
- Get read access and run an assessment: Security Hub/Prowler, IAM credential report, public resources, CloudTrail status.
- Look for signs of compromise before integration (GuardDuty history, unknown IAM users).
- Invite the accounts into our AWS Organization under a quarantine OU with baseline SCPs.
- Enable org CloudTrail, GuardDuty and Config; move users to our IdP; remove IAM users.
- Only then connect networks (Transit Gateway) with restricted routes.
Why โ Connecting first imports their risk into our environment.
Interview tip โ "Assess, quarantine, baseline, then connect" is a strong sequence.
Q196 Security alerts go to an email inbox that nobody reads. How do you design security on-call?
Intermediate
Situation read โ Alerts without owners are the same as no alerts.
What I'd do โ
- Route high-severity findings (GuardDuty high, Falco critical, root login) to a paging tool with an on-call rotation.
- Send medium findings to a ticket queue with an SLA; low findings to dashboards only.
- Write a runbook link into every alert.
- Tune weekly: alerts with no action taken get fixed or deleted.
- Track pages per week to keep on-call sustainable.
Why โ Routing by severity keeps urgent signals visible and the rotation humane.
Interview tip โ Every page should be actionable; otherwise it is noise.
Q197 A developer pushed an image with an embedded .env file to a public Docker Hub repository. How do you respond?
Beginner
.env file to a public Docker Hub repository. How do you respond?Situation read โ Public images are scraped by bots quickly. Treat every secret in it as leaked.
What I'd do โ
- Rotate every credential in the
.envfile first. - Make the repository private or delete the tag; deletion does not undo downloads.
- Check logs of the affected services for use of the leaked credentials.
- Add a
.dockerignorewith.env, and scan images for secrets in CI:trivy image --scanners secret myorg/app:1.2.0 - 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.
Q198 A security researcher reports they took over promo.example.com, which pointed to a deleted cloud resource. What happened?
Intermediate
promo.example.com, which pointed to a deleted cloud resource. What happened?Situation read โ Subdomain takeover through a dangling DNS record. The CNAME still pointed to a deleted resource (S3 website, Azure app, Heroku), and the attacker claimed that name.
What I'd do โ
- Delete the dangling DNS record immediately.
- Check whether cookies scoped to
.example.comcould have been read by the attacker's page. - Scan all DNS zones for CNAMEs pointing to non-existent resources (tools like
dnsReaper, or a script comparing records to cloud inventory). - Manage DNS in Terraform together with the resource it points to, so they are created and destroyed together.
Why โ Takeovers enable phishing and cookie theft on a trusted domain.
Interview tip โ "DNS and the resource it points to should share a lifecycle" is the lesson.
Q199 Every incident gets labelled "critical" and the team is exhausted. How do you build a security severity matrix?
Beginner
Situation read โ Without clear definitions, severity reflects who shouts loudest.
What I'd do โ
- Define levels with concrete criteria:
- SEV1: confirmed data breach, active attacker in production, or production credentials actively abused.
- SEV2: confirmed compromise with limited scope, or exploitable critical vulnerability on an internet-facing system.
- SEV3: suspicious activity under investigation, or a policy violation without exposure.
- SEV4: informational.
- Attach expectations to each: page or not, response time, who is notified.
- Allow upgrading or downgrading as facts change.
- Review severity choices in post-incident reviews.
Why โ Clear criteria make paging fair and save energy for real emergencies.
Interview tip โ Severity drives response; priority drives order of work.
Q200 You are asked to design the DevSecOps governance model for 50 product teams. What does it look like?
Advanced
Situation read โ Governance must set clear rules and ownership without making security a bottleneck.
What I'd do โ
- Ownership (RACI): product teams own fixing their findings; platform owns pipelines, base images and policies; security owns standards, tooling choices and risk decisions.
- Policies as code: gates, admission policies and SCPs live in Git with review and audit-first rollout.
- Exceptions: time-boxed, owned, approved by severity tier, enforced by tooling.
- Metrics: per-team scorecard (SLA compliance, MTTR, coverage), reviewed monthly with engineering leads.
- Forum: a monthly security council with champions to change standards and resolve disputes.
flowchart LR A["Security standards"] --> B["Policies as code"] B --> C["Shared pipelines and admission"] C --> D["Team findings and scorecards"] D --> E["Monthly security council"] E --> A
Why โ Rules enforced by platforms, plus clear ownership and feedback loops, scale far better than manual reviews.
Interview tip โ Show the loop: standards, enforcement, measurement, review.