📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Tell me about a security incident you were involved in, such as a secret or connection string committed to Git. How was it found, what did you do in the first hour, how did you work out whether it had been used, and what changed afterwards?

A STAR story for a leaked secret: revoke and rotate first, history rewriting as a secondary step, checking access logs for misuse, Notifiable Data Breaches assessment, and moving to managed identity and secret scanning.

Mid-Level RealWorldScenario Intermediate managed-identity real-world secret-scanning secrets-management security-incident star-story

🎯 Key points

  • Treated the secret as compromised the moment it was pushed: rotate/revoke first
  • Rewriting Git history is cleanup, not containment (clones, forks, caches keep it)
  • Checked for misuse: Azure SQL auditing, storage logs, Entra sign-in logs, provider dashboards
  • Escalated to security lead; NDB assessment if personal data could be accessed (contain, assess, notify, review; assess within 30 days)
  • Fixed the cause: managed identity / Key Vault, no long-lived secrets in config
  • Layered prevention: GitHub push protection or GitHub Advanced Security for Azure DevOps, pre-commit scanner (gitleaks, TruffleHog), org-wide history scans
  • Blameless post-incident review, shared with other teams, plus secure-coding onboarding and refreshers
  • Numbers: minutes to rotate, exposure window, secrets removed across repos

⏱ 30-second answer

My story is a [storage account key / SQL connection string] committed to [a repo] and caught by [GitHub secret scanning / a reviewer] [N hours] later. The first rule is that a pushed secret is compromised, so I rotated it first (new key, update Key Vault, restart apps) in [20] minutes, before touching Git history. Then I checked whether it had been used: [storage analytics logs / Azure SQL auditing] showed only our own app's access. I involved [the security lead] because the resource held personal data, and we documented an NDB assessment concluding no eligible breach. The real fix was removing the secret entirely with managed identity, and turning on push protection. Result: [secrets in repos from N to 0]. The trade-off: rotating immediately can cause a short outage if you don't know every consumer, which is why secret inventory matters.

🗣 Full answer (senior)

How I would answer this in an interview

"At [company], [a developer] committed an appsettings.Development.json containing the [production storage account key] to [our GitHub repo]. GitHub secret scanning flagged it about [two hours] later and I was [the senior engineer on the team / on call].

I treated the key as compromised straight away, because once it's pushed you can't know who has cloned it. I regenerated the key in Azure, updated the secret in Key Vault, and restarted the [three] apps that used it; that took about [20] minutes and caused [a few seconds] of errors on one app I'd missed at first. Only then did I clean the history, and I was clear with the team that rewriting history is housekeeping, not containment.

Next I checked for misuse. Storage diagnostic logs in Log Analytics showed every request in that window came from our own app's IP ranges, with no listing or downloads from elsewhere. Because the account held [customer documents], I brought in [our security lead] and we wrote up an assessment under the Notifiable Data Breaches scheme: contain, assess, notify, review. We concluded there was no unauthorised access, so no notification was required, and kept the record.

The real fix was making the key unnecessary: the apps moved to managed identity with RBAC on the storage account, and we disabled shared-key access. We turned on push protection and added gitleaks to the pre-commit hooks. A scan of all [40] repos found [six] other old secrets, which we rotated. The developer wasn't blamed; the process had made it too easy. My lesson: the best secret is one that doesn't exist."


First-hour order of operations

Step Why first
1. Revoke / rotate Ends the attacker's window
2. Update consumers (Key Vault, app settings) Restores service
3. Check for misuse in logs Decides whether it's a data breach
4. Escalate (security lead, privacy officer) Legal and NDB obligations
5. Clean history (git filter-repo, BFG) Reduces future exposure only

Australian context

Under the Privacy Act 1988, if there are reasonable grounds to suspect an eligible data breach (unauthorised access likely to cause serious harm), the entity must make reasonable efforts to assess it within 30 days, and notify the OAIC and affected individuals as soon as practicable if it is eligible. The OAIC's response steps are contain, assess, notify, review, and it treats 30 days as a maximum, not a target.

Production example

Template: [storage key] exposed for [2 h]; rotated in [20] min; logs showed no external access; NDB assessment documented, no notification required; [6] more old secrets found and rotated across [40] repos; shared-key access disabled.

🔍 What the interviewer is checking

Checks whether you contain a leaked secret correctly and quickly, check for misuse, escalate appropriately under Australian privacy obligations, and remove the root cause.

Green flags

  • Rotates first; knows history rewriting isn't containment
  • Checks logs for misuse and escalates
  • Mentions NDB assessment when personal data is involved
  • Moves to managed identity and push protection; blameless

Red flags

  • "We deleted the commit" as the fix
  • Keeps it quiet
  • Blames the developer

📚 Learn in depth

1. What the interviewer is really assessing

This checks security instincts (contain first), honesty and escalation (you didn't hide it), knowledge of Australian obligations under the Notifiable Data Breaches scheme, and whether you fixed the class of problem rather than the instance.

2. Why rewriting history doesn't contain the leak

git push -> GitHub -> forks, clones on laptops, CI caches, PR diffs, mirrors, scrapers
                         (bots scan public GitHub for keys within minutes)
Rewrite history -> only removes it from YOUR copy going forward

Only revoking the credential makes the leaked copy useless.

3. Checking for misuse

  • Azure Storage: diagnostic logs (StorageBlobLogs) for caller IPs, auth type AccountKey, operations.
  • Azure SQL: auditing to Log Analytics; failed and successful logins by client IP.
  • Entra ID: sign-in logs for service principals if a client secret leaked.
  • Third parties (Stripe test keys, SendGrid): their dashboards and API logs.

If logs don't cover the window, you have to assume access was possible, which changes the NDB assessment.

4. Frameworks for telling it

STAR. A security story benefits from showing the order of actions clearly. Avoid naming or blaming the colleague.

5. How it is scored

Weak: "we deleted the commit." Good: rotated the key. Strong: rotated first, checked logs, escalated. Excellent: removed the need for the secret (managed identity), added push protection and scanned other repos, handled it blamelessly.

6. Adapting the story

Also answers "a time you handled something sensitive", "a time you raised a problem with leadership" and "a time you improved security". Non-technical version: "A password was accidentally published in our code. I changed it within 20 minutes, checked nobody had used it, and changed our setup so there's no password to leak."

Try it yourself

  1. Run gitleaks detect on one of your repos (including history).
  2. Enable GitHub secret scanning and push protection on a test repo and try pushing a fake key.
  3. Switch a sample app from a storage connection string to DefaultAzureCredential.
  4. Query StorageBlobLogs in Log Analytics for AuthenticationType == "AccountKey".
  5. Write and time your STAR version.

💻 Code

Removing the secret entirely: managed identity instead of a connection string.

using Azure.Identity;
using Azure.Storage.Blobs;

var builder = WebApplication.CreateBuilder(args);

// Before: builder.Configuration["Storage:ConnectionString"] held the account key.
// After: no secret at all. Managed identity in Azure, developer login locally.
builder.Services.AddSingleton(_ => new BlobServiceClient(
    new Uri(builder.Configuration["Storage:BlobEndpoint"]!),   // e.g. https://acct.blob.core.windows.net
    new DefaultAzureCredential()));                              // needs 'Storage Blob Data Contributor' role

var app = builder.Build();
app.Run();
# Contain first: rotate the leaked key, then disable shared-key access once apps use identity
az storage account keys renew -g rg-docs -n stdocsprod --key primary
az storage account update -g rg-docs -n stdocsprod --allow-shared-key-access false

# Prevent: scan history and block future pushes
gitleaks detect --source . --log-opts="--all"
STAR template
S: [Secret] for [resource with what data] committed to [repo], found by [scanner/person] after [time].
T: I [was on call / owned the response].
A: Rotated in [N min]; updated [consumers]; checked [logs] for misuse; escalated to [role]; NDB assessment;
   cleaned history; moved to [managed identity]; enabled [push protection, gitleaks]; scanned [N repos].
R: [No misuse found]; [N] other secrets rotated; [secrets in config: N -> 0].

Illustrative only: storage key exposed 2 h; rotated in 20 min; no external access in logs; managed identity rollout.

⚠ Common mistakes

  • Mistake: Deleting the commit or rewriting history first. Why it is wrong: Copies already exist; the key still works. Instead: Rotate first, clean history later.
  • Mistake: Assuming a private repo makes it safe. Why it is wrong: Every collaborator, CI system and laptop has a copy. Instead: Treat it as compromised.
  • Mistake: Not checking whether it was used. Why it is wrong: You can't make the breach assessment without evidence. Instead: Check storage, SQL and sign-in logs.
  • Mistake: Keeping it within the team. Why it is wrong: Privacy obligations may apply and security needs to know. Instead: Escalate to the security lead or privacy officer.
  • Mistake: Rotating without knowing all consumers. Why it is wrong: Surprise outages. Instead: Keep an inventory; Key Vault references make rotation one change.
  • Mistake: Relying on one scanning tool. Why it is wrong: Each detects different patterns, and local hooks can be skipped. Instead: Layer server-side push protection (GitHub, or GitHub Advanced Security for Azure DevOps) with a pre-commit scanner (gitleaks or TruffleHog) and periodic org-wide history scans.
  • Mistake: Blaming the developer, or treating it as one person's mistake. Why it is wrong: People hide the next mistake, and the conditions that made it easy stay. Instead: A blameless post-incident review that asks why a production key was reachable from a dev settings file at all.
  • Mistake: Skipping the learning loop. Why it is wrong: Other teams repeat it, and new starters never hear about it. Instead: Share the write-up, add secrets handling (user-secrets, Key Vault, managed identity) to onboarding, and run a short refresher when tooling changes.
  • Mistake: Vague timeline and no numbers. Why it is wrong: Speed is the point of the story. Instead: Minutes to rotate, exposure window, repos scanned.

🏛 Senior insight: trade-offs

What makes this sound senior is the order of actions (contain, check, escalate, clean), transparency with security and privacy owners, and removing the class of risk (no long-lived secrets, push protection, org-wide scanning). Showing you know the NDB scheme's steps and the 30-day assessment window, and that you documented the decision, is a strong Australian-context signal.

The other senior layer is culture. Run a blameless post-incident review with the team: what made it easy (a production key reachable from a dev config file, no local secret store, no push protection), what you changed, and what other teams should check. Share it beyond the team, fold it into onboarding (user-secrets locally, Key Vault and managed identity in Azure), and measure the outcome (secrets found by scans per quarter trending to zero). A team that reports leaks quickly because it isn't punished for them is worth more than any scanner.

Control Stops Cost Limitation
Managed identity + RBAC Secrets existing at all (Azure resources) Role setup, local dev via az login Third-party APIs still need keys
Key Vault references Secrets in config files Low Secret still exists and can leak elsewhere
Push protection (GitHub / GitHub Advanced Security for Azure DevOps) Known secret patterns reaching the remote Licence for private repos Custom formats need custom patterns
Pre-commit scanner (gitleaks, TruffleHog) Secrets before commit Developer setup Can be bypassed locally
Short-lived credentials Value of a leaked secret Rotation automation Not every provider supports it
Blameless review + onboarding Repeat incidents, hidden mistakes Time Needs leadership support

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions personal data or the Notifiable Data Breaches scheme. Why: Checks their understanding of NDB obligations and first steps.
    How to answer

    Contain first: disable the feature or purge the cache. Tell the privacy officer straight away and follow the organisation's data breach response plan. Under the Privacy Act 1988 NDB scheme, a suspected eligible breach must be assessed within 30 days; if it is likely to cause serious harm and remedial action hasn't removed the risk, notify the OAIC and affected individuals as soon as practicable. Engineers provide the facts: which fields, how many people, which recipients, the time window, and evidence from audit and response logs. Document every step and decision, and preserve evidence: don't delete logs. Failing to assess or notify is an interference with privacy, and serious interferences can attract large civil penalties since the 2022 amendments.

  2. When: Candidate says they moved to managed identity. Why: Checks they can actually implement secretless access to Key Vault, SQL and Storage.
    How to answer

    Managed identity gives the app an Entra ID identity that Azure manages, so there is no secret to store or rotate. In code, Azure.Identity gets tokens: DefaultAzureCredential tries managed identity in Azure and the developer's az login or Visual Studio sign-in locally. Then:

    • Key Vault: grant Key Vault Secrets User and use AddAzureKeyVault.
    • Blob Storage: grant Storage Blob Data Contributor and create BlobServiceClient with the credential.
    • Azure SQL: CREATE USER [app-name] FROM EXTERNAL PROVIDER, add it to database roles, and use Authentication=Active Directory Default in the connection string.

    Use a user-assigned identity when several apps share access or it must survive redeploys. The trade-off is setup effort in RBAC and SQL users in exchange for no secrets at all.

  3. When: Candidate mentions rotating API keys or third-party keys that can't use managed identity. Why: Checks how they store, scope and rotate keys that must exist.
    How to answer

    An API key is a long random secret that identifies a calling application, not a user. It suits partner integrations, internal tools and webhooks where OAuth would be overkill, but it is a static bearer secret, so design for leaks.

    • Generate 256 random bits with RandomNumberGenerator, add a prefix and key id (sk_live_<id>_<secret>) so you can look it up and secret scanners can spot it.
    • Store only a hash (SHA-256 is fine for high-entropy keys), show the key once, and compare with FixedTimeEquals.
    • Scope each key, set an expiry, allow two active keys for rotation, track last use.
    • Implement an AuthenticationHandler that turns a valid key into claims; policies decide access.

    The trade-off: keys are simple for partners but never expire on their own; OAuth client credentials give short-lived tokens.

🛠 Real-world problems: how you handle them

Production storage key committed to the repo
Situation
[Document service] storing [customer identity documents] in [an Azure Storage account in Australia East]. A developer committed `appsettings.Development.json` with the production account key to [the private GitHub repo]. I was [the senior engineer / on call].
Signals
GitHub secret scanning alert [~2 h] after the push; the alert email to repo admins; no unusual activity visible in the app.
Investigation
Identified all consumers of the key from Key Vault references and app settings ([3] apps, [1] Function). After rotation, queried StorageBlobLogs in Log Analytics for the exposure window: all `AccountKey` requests came from our App Service outbound IPs; no list or read operations from unknown IPs. Ruled out wider exposure: repo private, no forks, [N] collaborators. Checked other repos with gitleaks.
Resolution
Mitigation: regenerated the primary key within [20] minutes, updated Key Vault, restarted consumers (missed one Function at first; [~30 s] of errors). Escalated to [the security lead]; documented an NDB assessment (contain, assess, notify, review) concluding no eligible data breach. Cleaned history with git filter-repo. Real fix: moved all consumers to managed identity with Storage Blob Data roles and disabled shared-key access on the account.
Prevention
GitHub push protection enabled org-wide; gitleaks pre-commit hook in the repo template; quarterly org-wide secret scan; `.gitignore` for local settings files and use of user-secrets in development; Azure Policy denying storage accounts with shared-key access enabled; incident write-up shared blamelessly.

How to tell it (STAR)

**S:** At [company], a production storage key for [customer documents] was committed to our repo, and secret scanning flagged it [two hours] later. **T:** As [the senior engineer on call] I had to contain it and work out whether any data had been exposed. **A:** I treated the key as compromised and rotated it first, updating Key Vault and the apps that used it in about [20] minutes. Then I checked the storage logs for that window and found only our own apps had used the key. Because personal data was involved, I brought in [our security lead] and we documented a Notifiable Data Breaches assessment. After that I moved the apps to managed identity, disabled key access on the account, and turned on push protection and pre-commit scanning. **R:** No data was accessed, we found and rotated [six] older secrets across [40] repos, and the storage account no longer has a usable key to leak.

More in Production Incidents

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me