So halten Sie Secrets und personenbezogene Daten aus Claude Code heraus
Claude Code liest alles, was eine Aufgabe berührt, inklusive .env-Dateien, Logs oder Support-Exporte. In Arbeitsordnern liegen jedoch oft API-Keys, Datenbankpasswörter und Kundendaten, die so ungewollt als Kontext ins Modell gelangen. Es gibt Wege, das zu verhindern.

Veröffentlicht am 15. Okt. • Zuerst erschienen auf shanjeevrajendran.github.io
Claude Code liest alles, was eine Aufgabe berührt. Bittet man es, einen fehlgeschlagenen Job zu beheben, öffnet es die.env-Datei, verfolgt das Log und durchsucht den Support-Export. Alles, was es liest, geht als Kontext an das Modell.
Aber meine Arbeitsordner enthalten API-Schlüssel, Datenbank-Passwörter und Support-Tickets mit den Namen, E-Mail-Adressen und Heimatadressen von Kunden. Ich wollte nicht, dass davon irgendetwas meinen Rechner verlässt, nur weil Claude eine Datei ansehen musste, die es zufällig enthielt.
Scanner für Geheimnisse helfen bei Schlüsseln mit bekannter Form. Sie helfen nicht, wenn der Name eines Kunden in einem Ticket oder eine Adresse in einer Log-Zeile steht. Für einen regulären Ausdruck sieht das wie gewöhnlicher Text aus.
Deshalb habe ich Cloakroom gebaut: ein Claude-Code-Plugin, das Geheimnisse und personenbezogene Daten maskiert, bevor das Modell sie sieht, und die echten Werte wieder einsetzt, wenn Claude schreibt.
Claude Code erlaubt einem Plugin, Hooks vor und nach jedem Tool-Aufruf auszuführen. Cloakroom setzt genau auf diesen Hooks auf. Wenn Claude eine Datei liest oder einen Befehl ausführt, läuft die Ausgabe zuerst durch Cloakroom. Es sucht nach:
Jeder gefundene Wert wird durch einen Platzhalter ersetzt. Hier ist eine Support-Notiz und eine Config-Zeile, auf der Festplatte und so, wie Claude sie erhält:
# auf der Festplatte Nadia Petrov called about a double charge. Reach her at nadia.petrov@gmail.com, 18 Larkspur Lane, Charlotte NC. DATABASE_URL=postgres://admin:Hunter2x9@10.0.4.12/prod # was Claude sieht PII_PERSON_1 called about a double charge. Reach her at PII_EMAIL_1, PII_ADDRESS_1. DATABASE_URL=postgres://admin:PII_SECRET_1@10.0.4.12/prox Enter fullscreen mode Exit fullscreen mode Claude kann die Aufgabe trotzdem erledigen. Es weiß, dass es eine Person, eine E-Mail und ein Passwort gibt und wo sich jedes davon befindet. Es kennt nur nicht die Werte. Ein Wert behält für die gesamte Sitzung denselben Platzhalter, sodass PII_PERSON_1 in einer Datei dieselbe Person in der nächsten ist.
Viele personenbezogene Daten stecken in Bildern: ein eingescanntes Formular, ein Foto eines Ausweises. Cloakroom kann keine Pixel prüfen, also liest es sie stattdessen. Eine gescannte PDF-Seite oder ein Foto, das Claude öffnet, läuft per OCR auf deinem eigenen Rechner, und Claude erhält den maskierten Text statt des Bildes. Die OCR-Modelle werden mit dem Paket ausgeliefert, sodass nichts hochgeladen wird. Ein Foto eines Formulars mit der Aufschrift Patient: Nadia Petrov DOB 03/14/1986 erreicht Claude als Patient: PII_PERSON_1 DOB PII_DATE_1.
OCR liest Ziffern falsch, deshalb wird in diesem Text jede lange Ziffernfolge als Kontonummer maskiert. Handschrift wird nach wie vor schlecht erkannt.
Maskierung allein zerstört Dinge. Wenn Claude schreibt Hi PII_PERSON_1, in einen Antwortentwurf, ist das für dich nutzlos.
Deshalb landen die Originalwerte in einem verschlüsselten Tresor für die Sitzung, mit dem Schlüssel im sicheren Speicher deines Betriebssystems (Keychain auf macOS, Credential Manager auf Windows, Secret Service auf Linux). Wenn Claude eine Datei schreibt oder einen Befehl ausführt, der einen Platzhalter enthält, setzt der Hook kurz vor der Ausführung des Tools den echten Wert lokal wieder ein. Der Entwurf auf deiner Festplatte sagt Hi Nadia Petrov,. Das Modell hat den Namen nie gesehen.
Prompts sind etwas anderes. Claude Code erlaubt einem Hook, einen Prompt zu blockieren, aber nicht umzuschreiben. Wenn du also einen Schlüssel oder eine E-Mail direkt in den Chat einfügst, stoppt Cloakroom diesen Prompt und sagt dir, was er gefunden hat. Packe die Details stattdessen in eine Datei und bitte Claude, sie zu lesen, oder beginne den Prompt mit cr!, um ihn unangetastet zu senden.
Ein Detektor, der zu viel maskiert, wird abgeschaltet. Meiner markierte Order 4471 als Kontonummer, was harmlos ist und nur im Weg steht.
cloakroom dashboard öffnet eine lokale Seite, die jeden maskierten Aufruf auflistet. Markiere einen Alert als korrekt, als Fehlalarm oder als etwas, das übersehen wurde. Ein Fehlalarm schlägt eine Regel „dieses nie maskieren“ vor; eine Übersehung schlägt eine Regel „dieses immer maskieren“ vor. Nach dem Freigeben der Regel erreicht diese Bestellnummer Claude von da an als Klartext. Regeln, die einen Schlüssel, ein Passwort oder eine Kartennummer demaskieren würden, warten immer auf dein Ja, und ein Undo stellt alles wieder her.
Das Erkennungsmodell selbst ändert sich nie. Deine Markierungen werden zu Regeln davor, verschlüsselt wie der Tresor.
Regex reicht nicht aus. Schlüssel sind einfach. Namen, Adressen und personenbezogene Daten in Freitext brauchen ein Modell. Ich verwende ein kleines, das auf deinem Rechner läuft. Der Preis sind ein einmaliger Download und einige Fehlalarme, weshalb die Markierungen und Regeln existieren.
Die Wiederherstellung ist der schwierige Teil. Die Erkennung bekommt die Aufmerksamkeit, aber die eigentliche Arbeit lag darin, das Zurückschreiben zuverlässig zu machen: derselbe Platzhalter überall in einer Sitzung, die richtige Form für die Eingabe jedes Tools und Randfälle wie Claudes Edit-Tool, das Text gegen die Datei prüft, bevor irgendein Hook läuft.
Fail closed. Wenn Cloakroom etwas nicht prüfen kann (das Modell lädt noch, der Dienst ist ausgefallen, die OCR läuft in ein Timeout), werden Tool-Aufrufe zurückgehalten statt durchgewunken. Prompts greifen auf die schnellen Regeln zurück, sodass du nie ausgesperrt bist.
Verschlüsselte Ausgabe zählt. Ein Befehl wie base64.env oder xxd macht aus einem Geheimnis etwas, auf das kein Muster passt. Cloakroom dekodiert diese Ausgaben und prüft sie ebenfalls.
Weiß, was es nicht ist. Cloakroom verhindert versehentliche Offenlegung: den Schlüssel in einer Datei, die Claude zufällig geöffnet hat, die Kundenliste in einem Log. Es ist keine Sandbox, und ein Modell, das entschlossen ist, Daten Stück für Stück zu leaken, liegt außerhalb des Geltungsbereichs.
Es ist quelloffen, läuft lokal, benötigt kein Konto und funktioniert auf macOS, Windows und Linux. Innerhalb von Claude Code:
/plugin marketplace add shanjeevrajendran/cloakroom /plugin install cloakroom@cloakroom Enter fullscreen mode Exit fullscreen mode Es schützt Schlüssel und Kartennummern innerhalb von Sekunden und lädt dann das lokale Modell im Hintergrund für Namen und Adressen herunter.
Ich würde gerne hören, was es übersieht und was es zu stark maskiert: https://github.com/shanjeevrajendran/cloakroom
Expand Auten Auten Auten Follow Auten gibt deinem KI-Agenten Hände: Es klickt, tippt und liest einen echten Bildschirm auf deinem Computer (Mac/Windows/Linux) und Android-Telefon (Beta). Funktioniert mit jedem MCP-Client. Beigetreten am 7. Okt. 2026 • 15. Okt. Dropdown-Menü Link kopieren Ausblenden Der Schritt des Zurückschreibens beim Schreiben ist der Teil, den ich so noch nicht gesehen hatte. Maskierung allein ist einfach; den echten Wert in den Entwurf zurückzubekommen, ohne dass das Modell ihn je hält, ist der nützliche Punkt.
Eine Frage von der anderen Seite: Wir bauen Auten, einen Computer-Use-MCP-Server (der Agent klickt und liest einen echten Bildschirm), sodass vieles, was das Modell erreicht, Bildschirminhalt statt Datei-Lesevorgängen ist. Wir haben dasselbe Problem und sind bei einer engeren Regel gelandet: Passwörter werden lokal von einem dedizierten Tool eingegeben und gehen nie an das Modell, aber der Bildschirmtext, den der Agent liest, geht trotzdem durch.
Sieht der PostToolUse-Hook von Cloakroom auch MCP-Tool-Ergebnisse, einschließlich Bildblöcken von Screenshot-Tools, oder nur die Ausgaben der integrierten Read/Bash/Grep-Tools? Wenn er einen MCP-Screenshot per OCR maskieren könnte, bevor das Modell ihn erhält, würde das eine Lücke schließen, die viele Computer-Use-Setups haben.
Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.
Original (Englisch) anzeigen
Posted on Oct 15 • Originally published at shanjeevrajendran.github.io
Claude Code reads whatever a task touches. Ask it to fix a failing job and it opens the.env, tails the log, greps the support export. Everything it reads goes to the model as context.
But my working folders hold API keys, database passwords, and support tickets with customers' names, emails and home addresses. I didn't want any of that leaving my machine just because Claude needed to look at a file that happened to contain it.
Secret scanners help with keys that have a known shape. They don't help with a customer's name in a ticket, or an address in a log line. To a regex, those look like ordinary text.
So I built Cloakroom: a Claude Code plugin that masks secrets and personal data before the model sees them, and puts the real values back when Claude writes.
Claude Code lets a plugin run hooks before and after every tool call. Cloakroom sits on those hooks. When Claude reads a file or runs a command, the output goes through Cloakroom first. It looks for:
Each value it finds is swapped for a placeholder. Here's a support note and a config line, on disk and as Claude gets them:
# on disk Nadia Petrov called about a double charge. Reach her at nadia.petrov@gmail.com, 18 Larkspur Lane, Charlotte NC. DATABASE_URL=postgres://admin:Hunter2x9@10.0.4.12/prod # what Claude sees PII_PERSON_1 called about a double charge. Reach her at PII_EMAIL_1, PII_ADDRESS_1. DATABASE_URL=postgres://admin:PII_SECRET_1@10.0.4.12/prod Enter fullscreen mode Exit fullscreen mode Claude can still do the job. It knows there's a person, an email and a password, and where each one sits. It just doesn't know the values. A value keeps the same placeholder for the whole session, so PII_PERSON_1 in one file is the same person in the next.
A lot of personal data lives in pictures: a scanned form, a photo of an ID. Cloakroom can't check pixels, so it reads them instead. A scanned PDF page or a photo that Claude opens goes through OCR on your own machine, and Claude gets the masked text instead of the image. The OCR models ship inside the package, so nothing is uploaded. A photo of a form that says Patient: Nadia Petrov DOB 03/14/1986 reaches Claude as Patient: PII_PERSON_1 DOB PII_DATE_1.
OCR misreads digits, so in that text every long run of them is masked as an account number. Handwriting still reads poorly.
Masking alone breaks things. If Claude writes Hi PII_PERSON_1, into a reply draft, that's useless to you.
So the original values go into an encrypted vault for the session, with the key in your OS's secure store (Keychain on macOS, Credential Manager on Windows, Secret Service on Linux). When Claude writes a file or runs a command that contains a placeholder, the hook swaps the real value back in, locally, just before the tool runs. The draft on your disk says Hi Nadia Petrov,. The model never saw the name.
Prompts are different. Claude Code lets a hook block a prompt but not rewrite it, so if you paste a key or an email straight into the chat, Cloakroom stops that prompt and tells you what it found. Put the detail in a file and ask Claude to read it instead, or start the prompt with cr! to send it as is.
A detector that masks too much gets switched off. Mine flagged Order 4471 as an account number, which is harmless and gets in the way.
cloakroom dashboard opens a local page listing every masked call. Label an alert as correct, a false alarm, or something it missed. A false alarm suggests a "never mask this" rule; a miss suggests an "always mask this" one. Approve the rule and that order number reaches Claude as plain text from then on. Rules that would unmask a key, password or card number always wait for your yes, and undo puts everything back.
The detection model itself never changes. Your labels become rules in front of it, encrypted like the vault.
Regex isn't enough. Keys are easy. Names, addresses and free-text personal data need a model. I use a small one that runs on your machine. The cost is a one-time download and some false alarms, which is why the labels and rules exist.
Restore is the hard part. Detection gets the attention, but the real work was making write-back reliable: the same placeholder everywhere in a session, the right shape for each tool's input, and edge cases like Claude's Edit tool checking text against the file before any hook runs.
Fail closed. If Cloakroom can't check something (the model still loading, the service down, OCR timing out), tool calls are held back rather than waved through. Prompts fall back to the fast rules, so you're never locked out.
Encoded output counts. A command like base64.env or xxd turns a secret into something no pattern matches. Cloakroom decodes those dumps and checks them too.
Know what it isn't. Cloakroom stops accidental exposure: the key in a file Claude happened to open, the customer list in a log. It isn't a sandbox, and a model determined to leak data piece by piece is out of scope.
It's open source, runs locally, needs no account, and works on macOS, Windows and Linux. Inside Claude Code:
/plugin marketplace add shanjeevrajendran/cloakroom /plugin install cloakroom@cloakroom Enter fullscreen mode Exit fullscreen mode It protects keys and card numbers within seconds, then downloads the local model in the background for names and addresses.
I'd like to hear what it misses and what it over-masks: https://github.com/shanjeevrajendran/cloakroom
Expand Auten Auten Auten Follow Auten gives your AI agent hands: it clicks, types and reads a real screen on your computer (Mac/Windows/Linux) and Android phone (beta). Works with any MCP client. Joined Oct 7, 2026 • Oct 15 Dropdown menu Copy link Hide The restore-on-write step is the part I hadn't seen done before. Masking alone is easy; getting the real value back into the draft without the model ever holding it is the useful bit.
Question from the other side of this: we build Auten, a computer-use MCP server (the agent clicks and reads a real screen), so a lot of what reaches the model is screen content rather than file reads. We hit the same problem and ended up with a narrower rule: passwords are typed locally by a dedicated tool and never go to the model, but the screen text the agent reads still does.
Does Cloakroom's PostToolUse hook see MCP tool results too, including image blocks from screenshot tools, or only the built-in Read/Bash/Grep outputs? If it can OCR and mask an MCP screenshot before the model gets it, that would cover a gap a lot of computer-use setups have.