Quick revision
The short answer
I would rotate every exposed secret first, because a secret in Git history must be treated as known to attackers, and clean history only where it helps. Then I would pick one standard store, such as Vault or a cloud secret manager, with workload identity instead of static credentials, and give teams a starter or a documented config import so they all use it the same way. Secret scanning in CI and pre-commit hooks stops new leaks, and progress is tracked per service, with deadlines and exceptions approved by security.
What to remember
In this answer, we saw that the first step after finding secrets in Git is to rotate them, because cleaning history cannot undo copies that already exist, and history cleanup follows only where it helps. We then set one standard store with workload identity instead of static credentials, shipped a starter and documented config import so teams adopt it easily, blocked new leaks with CI scanning and pre-commit hooks, and tracked every service with risk-based deadlines and security-approved, expiring exceptions.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would rotate every exposed secret first, because a secret in Git history must be treated as known to attackers, and clean history only where it helps. Then I would pick one standard store, such as Vault or a cloud secret manager, with workload identity instead of static credentials, and give teams a starter or a documented config import so they all use it the same way. Secret scanning in CI and pre-commit hooks stops new leaks, and progress is tracked per service, with deadlines and exceptions approved by security.
Why this question is asked
An audit finding like this is common in organisations that grew fast: secrets were committed years ago to get something working, and environment variables became the default way to pass everything. The finding is not only a compliance problem; any of those secrets may already be in a laptop backup, a fork or a CI cache. Interviewers ask this leadership question because the answer needs correct priorities under pressure, a standard that teams can adopt, and a rollout that finishes rather than stalls. In this answer, we will set the order of work, handle the exposed secrets, choose the standard, make it easy to adopt, prevent new leaks, and run the rollout with tracking and exceptions.
1Getting the Order Right
The instinct after such an audit is to start by cleaning Git history, because that is what the report shows. But removing a secret from history does not undo its exposure: every existing clone, fork, mirror and CI cache still contains it. The risk is the secret being valid, not the secret being visible. So the first move is to make the exposed secrets useless by rotating them, and only then to work on the standard that prevents the problem from coming back.
- Inventory exposed secrets40 repositories, scanner output, owners
- Rotate by riskproduction databases and cloud keys first
- Clean history where it helpspublic or widely shared repositories
- Choose the standard store and identityVault or cloud secret manager
- Ship a starter and docsone way to read secrets
- Block new leaksCI scanning and pre-commit hooks
- Migrate and track per servicedeadlines, approved exceptions
7 steps in order. Play them, or step through them one at a time.
2Rotate the Exposed Secrets First
We run a secret scanner over the full history of all 40 repositories to build an inventory: which secret, where, which system it opens and who owns it. Then we rank by damage: production database passwords, cloud access keys and payment provider keys come first, test credentials for disposable systems last. Each secret is rotated, the old value is revoked, and access logs are checked for use of the old credential in the period it was exposed.
Cleaning history comes after rotation and only where it helps, for example a repository that is public or shared with many partners, because rewriting history breaks every clone and open pull request. For internal repositories with rotated secrets, the value is low and the disruption high, so often we simply record that the secret is revoked.
3Choosing the Standard Store and Workload Identity
We pick one standard store for the fleet: HashiCorp Vault if we run across several clouds or on premises, or the cloud provider's secret manager if we live in one cloud. One store matters more than which one, because a single standard is what lets us build one starter, one set of docs and one audit trail.
The second part of the standard is how a service proves who it is to the store. If the service needs a static token to read its secrets, we have only moved the problem: that token becomes the secret in an environment variable. So the standard uses workload identity: the platform gives each service an identity, such as a Kubernetes service account or a cloud IAM role, and the store grants access based on it. No credential needs to be distributed to read the secrets.
4Making the Standard Easy to Adopt
Teams adopt a standard when it is less work than their current approach. So the platform team ships a starter, or at least a documented spring.config.import pattern, that makes reading a secret one line of configuration, and a Helm chart or operator that sets up the identity and delivery.
Notice that the application only sees files, and the chart only holds references. Delivering secrets through a CSI driver or agent means the Java code does not depend on the store's client library, and a future change of store does not touch the services.
5Blocking New Leaks
While the migration runs, new secrets must not enter Git. We add secret scanning to CI for every repository, failing a build that contains a credential pattern, and offer pre-commit hooks so developers catch mistakes before pushing. Server-side push protection, if our Git hosting offers it, is stronger still, because it does not depend on developers installing anything.
For environment variables, the standard simply says that secret values may not be set as plain values in deployment files, and a policy check in the deployment pipeline rejects manifests with literal values for keys that look like secrets.
6Tracking Progress, Deadlines and Exceptions
A fleet-wide standard stalls without visibility. I would publish a dashboard per service: exposed secrets rotated, reads secrets from the standard store, no plain secret environment variables, scanning enabled. Each team sees its own row and the overall percentage. Deadlines are set by risk, for example 30 days for internet-facing and payment services and 90 days for the rest.
Some services will not make the deadline: a legacy system that cannot read files, a vendor product with its own configuration. Those get exceptions, but only approved by security, recorded with a reason, a compensating control such as tighter network access, and an expiry date. An exception without an expiry becomes permanent, which is how the original problem grew.
| Service | Rotated | Standard store | Plain env secrets | Status |
|---|---|---|---|---|
| payments | yes | yes | none | done |
| orders | yes | in progress | 2 | due in 30 days |
| legacy-billing | yes | no | 4 | exception until March, approved |
| search | n/a | yes | none | done |
7Follow-up questions
Why not start by moving everything to the new store?
Because migration takes months and rotation takes days. Until the exposed secrets are rotated, anyone holding an old clone can use them. Rotation removes the immediate risk; the standard prevents recurrence.
How do you get teams to prioritise this over features?
Make the work small and visible. The starter reduces each migration to a few hours, the dashboard shows each team's status to its leadership, and deadlines come from security policy rather than from the platform team. Pairing the first few teams with platform engineers also shows that the path works.
What if a secret cannot be rotated quickly?
Treat it as an active risk: restrict network access to the system it opens, increase monitoring for its use, record the decision with security, and set a firm date. Some vendor credentials need a support ticket to rotate, so that work starts on day one.
8Conclusion
In this answer, we saw that the first step after finding secrets in Git is to rotate them, because cleaning history cannot undo copies that already exist, and history cleanup follows only where it helps. We then set one standard store with workload identity instead of static credentials, shipped a starter and documented config import so teams adopt it easily, blocked new leaks with CI scanning and pre-commit hooks, and tracked every service with risk-based deadlines and security-approved, expiring exceptions.
Open with
My first priority would be rotation, not history cleanup. A secret that was ever in Git history has to be treated as known, because clones, forks and CI caches still contain it.
Then, if they want more
So I would scan the full history of the 40 repositories, build an inventory with owners, and rotate by risk, starting with production databases, cloud keys and payment keys. I would revoke the old values and check access logs for their use. I would rewrite history only where it helps, like a public repository, because it disrupts every clone.
Then I would set one standard store, Vault or our cloud's secret manager, with workload identity. Services authenticate with their service account or IAM role, so we do not just move a static token into an environment variable.
To make adoption easy, the platform team ships a starter or a documented spring.config.import pattern, for example a config tree written by a CSI driver, plus a Helm chart where teams only reference secrets.
To stop new leaks, I would add secret scanning in CI, pre-commit hooks and push protection, and a policy check that rejects plain secret values in deployment manifests.
Finally, I would track every service on a dashboard, set deadlines by risk, say 30 days for payment and internet-facing services, and allow exceptions only with security approval, a compensating control and an expiry date.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "An audit finds secrets in Git history in 40 repositories and in plain environment...": https://scrivio-interview-library.netlify.app/spring-boot/externalized-configuration/38e570ed31/