CodekeeperTransaction Services

InsightsSecurity, privacy and regulation

Secrets in source code: a small finding with large consequences

Passwords, keys and tokens written into source code are among the most frequent findings in technical due diligence, and among the least understood by the people who have to price them. The consequences of such a finding depend on two facts: whether the secret still works, and who has been able to read it.

6 min readUpdated Codekeeper Transaction Services

What counts as a secret

A secret is any piece of text that grants access. Software needs many of them: the password to the production database, the key for the payment provider's interface, the token that lets the build system publish releases, the private key behind a certificate, the credentials of a cloud account.

These values are supposed to live outside the code, in a secrets manager or in protected configuration. In practice developers under time pressure paste them into a file to make something work, intending to tidy up later. Often the file is committed to the repository first.

Not every secret is equal. A key for a test environment with invented data is a minor matter. A cloud administrator key, a production database password or a signing key for software updates gives its holder control over customer data or over the product itself.

Why deleting a secret does not remove it

Version control systems such as git keep every version of every file. When a developer removes a password from a file and commits the change, the current version is clean and every earlier version still contains the password.

Each copy of the repository carries that full history. So the password is on the laptop of every developer who has worked on the code, in the accounts of contractors who left years ago, in backups, in the build system, and in any third-party tool that was ever given access. If the repository was public at any time, even briefly, the secret should be treated as published.

Rotation is the fix, and it should be evidenced

The only reliable remedy is rotation: revoke the exposed credential at the service that issued it and create a new one that is stored properly. Once the old key no longer works, its presence in history is harmless.

For each secret found, a buyer therefore wants three answers:

  1. Is it still valid, or has it been revoked?
  2. What could it reach, and at what level of privilege?
  3. Is there any sign it was used by someone who should not have had it?

The first answer should be supported by something better than recollection, for example the issue date of the current key at the provider, or a change record. The third depends on whether access logs exist for the period, which is a question that also matters when reading a target's incident history.

Rotation is sometimes harder than it sounds. A key embedded in a mobile app already installed on customers' phones, or shared with dozens of integration partners, cannot be changed in an afternoon. That difficulty is itself a finding, because it means the company could not respond quickly if the key were abused.

What the finding says about practice

One old test password proves little. Dozens of credentials across several years, some of them recent, describe how the team works.

It suggests there is no secrets manager, or that it is not used consistently. It suggests code review does not catch what it should, and that no automated check runs before code is accepted.

The opposite pattern is equally informative. A history in which secrets appear in the early years, then stop, with the old ones revoked, shows a team that recognized the problem and fixed its process. Diligence should report that as a strength. It is one of the things source code analysis reveals that policy documents do not.

How scanning finds secrets

Secret scanning reads every commit on every branch, not only the current files. The first method is pattern matching: many providers issue keys in a recognizable format, so the scanner knows what a key for a given cloud or payment service looks like. The second is statistical: long strings that look random are flagged as probable keys even when their format is unknown.

Raw results need review. Scanners flag example values in documentation, placeholder strings and test data that only resemble credentials. They can also miss secrets that are unusually formatted or lightly disguised. Someone has to sort the real from the false, classify each real one by what it opens, and put the question of validity to the seller.

Scanning covers what is in the repositories provided. Secrets kept in chat messages, wikis, shared documents or personal notes are outside it, and the report should say so.

What it means for the transaction

Secrets rarely change a valuation by themselves. They change the conditions of closing and the handover plan.

SituationUsual treatment
Live secrets with limited reachRotation before closing, confirmed by the seller
Live secrets for production or cloud administrationRotation as a condition precedent, plus a review of access logs
Signs of unauthorized useInvestigation before closing, then a discussion of price and indemnity
Secrets that cannot be rotated quicklyA costed remediation item in the first hundred days

Closing changes who should hold the keys in any case. Every credential the seller's people know should be replaced as control passes, which is part of a proper handover of repositories, domains and cloud accounts.

Contract terms on these points vary by transaction and jurisdiction. This is general information, not legal advice, and counsel should settle the wording.

How we approach it

Every report we produce, at every level, scans the code and its full git history for secrets. In the Analyst-Verified Report an in-house analyst removes the false positives, rates what remains in the context of the company's stage, and pairs material findings with the market-standard remedy. That is data-backed negotiation support, not advisory.

The seller responds beside each finding, on the record, so a statement that a key has been rotated is documented where both sides can read it. The data room stays synchronized with the seller's systems and a delta scan runs on every change, so new secrets are caught before closing too.

The repositories we hold are sensitive for the same reason. Code is cloned and scanned in sandboxes with no network egress, and access is read-only and scoped by role, as set out on our security page. On Professional and Complete engagements, the structured handover of credentials runs against a checklist with dual sign-off.

Questions we are asked

The seller says the keys were deleted years ago. Is that enough?

No. Deleting a key from the code leaves it in the history and in every copy. What matters is whether the key was revoked at the service that issued it. Ask for evidence of rotation.

Should the repository history be rewritten before a sale?

It is rarely worth the disruption, and it should not be done during diligence, because the history is evidence for ownership and other findings. Revoking the exposed credentials solves the security problem without altering the record.

Do private repositories make this a non-issue?

They reduce the audience and do not remove the risk. Former staff, contractors, connected tools and backups all hold copies.

This article is general information for people working on software transactions. It is not legal, financial or insurance advice.

Dealmaking is your craft. The technology is ours.

Tell us about the transaction and its timetable. We will set out the scope we would advise, and what the first report would cover.