Back to Learning Area

Secrets & Security: What Must Never Go Into a Repository

Why a key that has once been published cannot be taken back - and which step therefore stays with you, however well the agent works.

  • Concepts
  • 12 min
  • Intermediate

Plain Language

This preview is in Plain Language. The whole portal is also available in Plain Language. You can change the language at the top. Or use the button below. Our Plain Language texts are AI-assisted and editorially reviewed. They follow the core principles of easy-to-read language, but they are not certified Easy Read: a review panel of people with learning difficulties does not test them.

Preview: Secrets: What Must Never Go Into a Repository

What a secret is

A secret is a value. Your program uses it to sign in somewhere. You do not spot it by its looks. Ask yourself: my project becomes public now. Would any access be lost? Then the value is a secret.

Printed is printed

Deleting takes nothing away. It only adds a new state. Rewriting does not change the old commits. And it never reaches copies held by others. Only one step helps: make the key invalid at the service.

The step with no way back

Do not sort by danger. Sort by way back. The agent may edit and build. You decide about publishing. Does a check ask you? Then that is your decision.

The agent has finished building a small tool. It packs everything into one commit and uploads it. Among the files is one you have never opened: the agent created it on day one, and inside sits the value your tool uses to identify itself to a paid service. Nothing crashes, no warning appears. The screen looks like a good day.

How often this happens can only be estimated, and the estimate comes from the companies that go looking: one vendor's detection engine counted about 28.65 million newly added hardcoded credentials across roughly 1.94 billion public commits in 2025. That is good for the order of magnitude and nothing more - it measures what a single program can recognise. What happens afterwards matters more anyway, because that has been studied, and the finding ages better than any count.

That credentials do not belong in the code is something you know from the vibecoding article. What stayed open there is the question that, from the upload onwards, is the only one with a useful answer. It is not: how do I get this back? It is: what does this value still open?

The Sentence From the Git Article

The Git article states this sentence three times: at the commit, in the interactive part, and once more as a warning. Even if you delete the file afterwards, the saved version survives. Three times the claim, not once the reason. That is exactly where this article begins.

Three things the sentence does not carry, and each gets its own section here: why this is so, how far that survival reaches, and what still changes anything afterwards.

You bring one picture with you from the Git article: Git is the camera, the platform is the photo album in the cloud. An album takes pictures in and keeps them - that is exactly what it is built for.

What it has no handle for: taking back one that has long since arrived with everyone subscribed to the album. You can delete the picture on your side, and for you it really does disappear. For the others, nothing changes at all.

So one sentence governs the rest of this article: nothing is taken out of a history. Things are only added to it.

What Is Actually Being Decided Here

Publishing is not an action with a strong undo. It is an action with no undo - because a commit is named after its own contents, and because copies are outside your reach the moment they exist.

From that follows the sorting by which you decide what an agent may do on its own: not by danger, but by way back. Anything a second action of the same kind can catch again, you may hand over. The one step for which that does not hold stays with you.

Note

What You Will Be Able to Do

  1. Decide for any given value whether it is a secret - via the publish test, without having to recognise it by its appearance.
  2. Explain why a commit survives the deletion of its file, and say what the status report is a statement about and what it is not.
  3. Name what rewriting the history does not reach, and identify invalidation as the only step that changes the situation.
  4. Sort an action by whether it is reversible - and argue why that is not the same sorting as one by danger or by rights.
  5. Apply the five-point checklist before a project of your own goes public for the first time.

The Key Is Not in the Blueprint

Some things are made to be handed on and some are not, and you cannot tell by looking at them. An architect files the building plan with the authorities, puts it up in a display case, sends it to three firms - that is exactly what it is for. The key to the finished house makes none of those journeys. It sits in a different drawer, in a different quantity, under different rules. Both belong to the same building. But only one of them is for passing around. The other is what actually lets somebody in.

Your project's code is the plan. Publishing it is normal; a whole part of this world lives on it. Publishing the key along with it is not the same thing in a more dangerous version. It is a different kind of act.

Definition

Secret

In plain words

A value your program uses to sign in somewhere: to a service, to a database, to a paid interface.

This test has one property that makes it usable: it works on files you have never read. You do not have to understand what is in them. You only have to know whether access would travel along with them.

And if you do not know that, the shortcut is a question to the agent: what does this project use to sign in to other services, and which files hold those values? The answer is your list - and you do not have to read a line of code for it.

Five Shapes a Secret Takes

API key A value your program uses to identify itself to somebody else's interface.
Access token A pass issued by a service - often time-limited, sometimes with no expiry date. Time-limited does not mean harmless.
Private key file A file that makes a sign-in possible without anyone typing a password.
Database access Address, user name and the value that opens the door. The last one is the one that counts.
Configuration file A settings file with the access built in, because that was convenient during setup.

Caution

It Is Only a Test Key for a Tiny Project

In a large research study from 2019, the overwhelming majority of the credentials found appeared under one single owner each. So they were not sample values copied a thousand times out of some tutorial, but genuine keys, each belonging to its own owner; a good 89 per cent of everything found was rated genuinely sensitive by the authors. Both proportions refer to the set found in that one study. Still, the reason sits at the end and not in the number: a key does not know how big your project is. It only knows what it opens.

The second wrong assumption sounds reasonable and is the more dangerous one: I would see a password in the code. But the values in question do not look like passwords. For the same reason, the 2019 study counted only credentials with a recognisable format - it excluded passwords because a password can be any string at all. The honest conclusion: do not hunt for secrets by eye; make sure they never sit in the saved content in the first place.

Where the Picture Breaks

Ask how many copies of a front-door key exist, and somebody can tell you. A key is a thing, and things can be counted, collected, kept in one place. A digital access key is a string, and for a string that question no longer exists: it multiplies by being looked at, and nothing goes missing on your side. So the problem here is not the way back but the count - nobody knows how many people are holding it by now. What follows from that is the section after next.

The Ignore Rule and Its Limit

The everyday form of all this is unspectacular: credentials sit in a file of their own, usually called .env; that file is not saved along with the project, and the program reads it at startup. This is not a security product but a filing habit - it just happens to remove an entire class of failure.

Caution

The File Is in the Ignore List, So It Is Not in the Repository

The manual for that list - the file is called .gitignore - says the opposite right in its first two sentences: an ignore list names files Git is not yet recording; files it already records are not affected. So the rule only works forwards. The case that goes wrong is therefore always the same one: the file was there first.

And now the part you have to know: when the rule comes to nothing, nothing happens. No error, no notice, no warning. The file keeps appearing in the status report (git status, in the Git article) whenever it changes, but it looks like any other changed file there. That is exactly why it goes unnoticed - not because it is invisible, but because it is unremarkable. And the next collective command takes it along again.

The documented repair is a step of its own: the file is released from being recorded, and only then does the rule bite. Be honest with yourself about it - that repairs the future. It changes nothing about what has already been uploaded; the earlier commit and its contents stay readable.

The Git article recommends the ignore list, and that recommendation is right. What does not fit into a one-line warning is the case where the file was already there - and that is precisely the case that feels safest.

From here you keep two questions apart that like to collapse into one. Is it still being recorded? And: is it still in there? Only the first has an answer on your own machine.

Printed Is Printed

Your file goes into the evening edition. A year later somebody in the newspaper archive pulls that very edition off the shelf. Nothing on the page tells them that a correction ran the next morning: the correction has its own edition, its own date, its own place on the shelf. It lies beside the old text, not on top of it. A history is exactly that kind of shelf. Why it technically cannot work otherwise takes six links. Not one of them is a rule somebody laid down.

Note

The Chain in Six Links

  1. 1. An object is named after its contents
  2. 2. Deleting adds instead of taking away
  3. 3. Rewriting changes nothing, it writes replacements
  4. 4. The rewrite never reaches the copies
  5. 5. A key is a claim, not a tool
  6. 6. So: invalidate the value and replace it

Link 1: An Object Is Named After Its Contents

In case you skipped the deep dive in the Git article: every stored object gets a name calculated from its contents. Same contents, same name. Different contents, different name.

A commit is such an object: the stored state, its predecessor, the people involved, your message - and the name follows from that. This has a consequence the Git article does not draw: you cannot change the contents and keep the name. The same property that makes a history tamper-evident makes it unforgettable.

Link 2: Deleting Adds Instead of Taking Away

That is why deleting takes nothing away. You delete the file, you save the deletion - and the number of commits goes up. The new commit describes a state without the file. The old one is untouched and still retrievable by its name.

Caution

I Deleted the File and Uploaded Again, So It Is Gone

Many people think this. It is not an assumption about users but what the researchers observed at scale - and the reason they concluded that the secrets remained accessible. The status report says something about the state right now. About what is stored, it says nothing.

What the status report shows

The state right now. The file has vanished from it, so it no longer appears. A statement about one single point in time.

A statement about your expectation

What stays retrievable

Every object ever stored, named after its contents - and that in every copy of this repository there is.

A statement about the contents

Link 3: Rewriting Writes Replacements

The next thought is the advanced one and deserves respect before it gets its correction: then I will just rewrite the history. Except that a rewrite changes not one single old commit - that is impossible, see link 1. It writes replacements and moves a pointer. Afterwards the old material hangs off no branch, but it is not gone: on the machine that did the rewriting it stays retrievable until a housekeeping routine comes by - with Git's default settings not before about a month; some rewriting tools, however, clean up right away on their own. And that is the harmless half.

Caution

Then I Will Just Rewrite the History, That Is the Proper Fix

It feels like the expert move and it really is the most laborious of them all. It still only works where you can reach. What a rewrite does not reach is everything that is no longer yours.

Link 4: It Never Reaches the Copies

Two words for that, in case they are new: a clone is a complete copy of your repository on somebody else's machine. A fork is a complete copy in somebody else's account on the platform itself - made with one click, independent of you from then on.

Your rewrite reaches neither of them. And at this point the newspaper picture is being too kind: in a newspaper archive you have to know which edition to look in. Here the commit's name is enough. Whoever holds it gets the old state back out of the platform's cached views. What is left to you is in the platform's own guidance: contact the owners of the forks one by one. How to reach them, it will not tell you.

The platform's guidance lists it: clones on other machines, forks in other accounts, cached views from which the commit stays retrievable directly by its name, and pull requests that reference it. A pull request is the proposal to adopt a change; it holds on to the reference to the commit even when the branch has long since moved on.

The part nobody expects sits in the same guidance: you have to contact the fork owners individually, and the platform will not hand you their contact details. Support also removes cached views only where the risk cannot already be settled by replacing the affected credentials. With that, the platform itself states the order in which this works.

That leaves the thought everyone has first: then I will delete the whole repository, or switch it to private. Both take it off the platform's front door, no more than that. Clones already taken stay, forks stay. And a value somebody has read does not become unread because the page disappears.

Link 5: A Key Is a Claim

And now the step that is the only one to change anything - and it changes nothing about what was published. An access key is not a tool that opens something by itself. It is a claim: I am allowed to do this. Whether it holds is decided by the service on the other side, freshly with every request.

Link 6: Change the Lock

You cannot retrieve the published string. But you can make sure the service no longer honours it - and then it is what it always was without that service: a string. This is the sentence from the first section, now with a mechanism behind it: when a key is lost you change the lock instead of chasing the copies.

That does not happen in your project but at the service the key unlocks - where it was issued, in the account area. There you will usually find both: a button that invalidates it, and one that issues a new one.

Caution

Tiny Project, Nobody Looks in There

Here the newspaper breaks a second time: it suggests a slow, scattered readership. Measured, it looks different, in two things that must not be confused. First, in the 2019 study, between the upload and the moment a string can be found through the platform's own search there was a median of about twenty seconds - that measures how quickly something becomes findable, not how quickly somebody attacks. Second, from an experiment in which a research team exposed keys of its own under controlled conditions: there are automated systems that continuously clone and scan public repositories. So whoever finds you was not looking for you. What gets looked at is everything lying open - and your project lies open.

Worked Through: The Timeline of One Single Key

In the evening the project goes online; within seconds the value may already be findable through the platform's search. Two hours later you notice, delete the file and save the deletion - that changes the state right now and nothing else. The next day you rewrite the history and push it up over the old state - that changes what is convenient to see and leaves every copy untouched. And then you invalidate the value at the service: the first step in that sequence that changes anything about what a stranger can still do with it.

How often that step is actually taken has been measured - and the result is the reason this article exists.

of the secrets found were not removed within the roughly two weeks observed

81 %

And among the repositories observed, not one rewrote its history: what was cleaned up was cleaned up in exactly the way that removes nothing. Both proportions refer to the set found in a study from 2019.

That invalidating still helps even late on has an uncomfortable reason: where nobody replaces the value, the old one keeps opening things. The same vendor whose detection engine produced the figure in the opening re-tested credentials years after they were published and found a large share of them still valid.

Check

Quick Self-Check

Can you explain this in your own words? Tick what you've got.

0 of 3 done

The Step With No Way Back Is Yours

Before every handover to an agent there is a question, and it is not the expected one. Not: how dangerous is this? But: is there a way back? Reversible means a second action of the same kind catches the first - edit a file and edit it again, save locally and save again. The Git article already gave you this: a commit is local at first. Not reversible are publishing, deploying, deleting an account, sending a message.

If you have read the article on harness engineering, the picture will look familiar: there a key card opens three doors and not the fourth, and that is the question of rights. Here it is about a different property of the same door - whether it can be opened again behind you. The harness article asks what an agent may touch. This one asks which touch cannot be taken back.

Many rights, full way back

An agent locally overwrites your entire working folder, whose state you had committed beforehand. That needs far-reaching rights and looks like a disaster - and it can be restored piece by piece.

It may do this alone

Barely any rights, no way back

An agent uploads one single small text file to a public repository. That needs almost nothing - and from then on everything in this article applies.

Stays with you

Same person, same afternoon, opposite answers. The difference is not the size. It is the axis. The second scene is no thought experiment. In September 2026 a security firm reported that agents had put screenshots meant to prove a change into public repositories, some of them creating a new one on their own to do it. More than 13,000 internal images from over 300 organisations were left in the open.

That leaves the objection: if I give the agent enough rules, this will not happen. The harness article covers that point at length, so just one sentence here - even an instruction followed perfectly does not answer who performs the step that has no way back. That question is not answered by better instructions but by your keeping the step.

On top of that, an agent that reads project content can also be steered by that content. What that looks like is in the article on prompt injections.

Where the Door Stops Being a Door

There is a moment when a door stops being a door. Before it, the door is a passage: you walk through, you come back, you walk through again. After the click it is a wall with a handle on it. The handle is still there; it just belongs to the other side now. Half a metre lies between the two states.

First break: you can see a door swing shut. On screen the step with no way back looks exactly like the one with it - uploading looks like saving. That is why the sorting has to be decided beforehand instead of being felt in the moment.

Second break: a door's lock is physics, a label is a claim. What that means for the machines standing in front of the step is in the next section.

What the Machines Do Not Take Off You

Machine checks in front of the irreversible step are real and worth their money. The platform's push protection stops an upload that carries recognised credentials before it lands - and the stated reason is exactly the one from this article: afterwards it would already be part of the history. For uploads to public repositories this protection is on by default.

Caution

The Platform Scans, So I Am Covered

Two limits, both from the documentation itself, and they have nothing to do with each other. First, such a check recognises the patterns it knows. It has only been stopping credentials without a fixed pattern, such as passwords, since late October 2026 - as a paid preview for organisations, and only if someone switches it on. Second, a person with write access can get past it by stating a reason; that event raises an alert only where the protection is additionally switched on at repository level. On top of that comes the automatic quarantine some providers apply to exposed keys: it exists, it covers particular providers and formats, and it fires after publication. Both are useful. Neither is a floor to stand on.

The interesting moment is the prompt. A check that asks you for a reason hands the irreversible act back to a human being at exactly that instant. That is not an obstacle and not a formality - that is the point where the decision is yours again.

The Model Context Protocol provides every tool with a machine-readable label for whether it can destroy what already exists or only adds something. What is interesting is the default: if nobody states otherwise, a tool counts as potentially destructive. The formal baseline assumption of the ecosystem is therefore that an undeclared action can do damage - and that is a published default, not an opinion. What the label does not ask about is the way back: a tool that uploads or sends a message only adds something and may therefore declare itself non-destructive - even though it is exactly the step with no way back.

The specification requires that labels coming from an untrusted source be treated as untrusted. The accompanying text from the protocol authors puts it more plainly: these labels are hints and not enforcement, and an untrusted source can simply state something untrue. The same specification therefore says there should always be a human in the loop who can deny a tool invocation. The label routes the decision to a person. It does not make the decision safe.

Test Bench: Which Layer Stops the Key?

Check

Quick Self-Check

Can you explain this in your own words? Tick what you've got.

0 of 2 done

Back to That One File

The file from the opening would have had two opportunities. On day one the single question: if this folder were public in the next minute - what would be given away? The file would have come up in the answer, even though you had never opened it. And later, when the ignore rule was added, a look at whether an ignore rule still does anything for it at all.

If it has already happened, exactly one step changes anything about it, and it is not the one that feels like tidying up: invalidate the value at the service that issued it, and enter a new one.

Everything that can be done again, you may hand over. The one thing that cannot be done again is yours.

Note

Checklist Before Publishing for the First Time

  1. Ask the one question first. If this folder were public in the next minute - what would be given away? Whatever you name in the answer is what this article is about.
  2. Ask the agent what the project uses to sign in to other services and which files hold those values. The answer is your list - and you do not have to read a line of code for it.
  3. An ignore rule works forwards only, and only for what is not yet being recorded. If it fails to bite, nobody tells you: if the file changes, it keeps showing up in the status report and looks like any other one there.
  4. If something did get out: invalidate first, tidy up second. That happens at the service that issued the key. Removing the file is cosmetics - the platform's support only helps with removal where replacing is not enough.
  5. The step with no way back stays with you. Editing, building, saving locally: hand over as much as you like. Publishing is a human decision - and when a machine check asks you to confirm, that question is the decision, not an obstacle.

Check

Quiz: Secrets & Security

Not completed

Two values sit next to each other in your project: the name of the payment service your tool uses, and a string your program uses to sign in there. Which of them is a secret?

Select one answer

Answer Key: 1) B · 2) B · 3) B · 4) C · 5) B