Skip to content

fix(redact): mask Stripe secret and restricted keys - #3037

Merged
milind-soni merged 1 commit into
milind-soni:mainfrom
kevin9327:fix/redact-stripe-keys
Oct 18, 2026
Merged

milind-soni merged 1 commit into
milind-soni:mainfrom
kevin9327:fix/redact-stripe-keys

Conversation

@kevin9327

@kevin9327 kevin9327 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What changed

shared/redact.ts gains a key-prefix pattern for Stripe secret and restricted keys (sk_live_, sk_test_, rk_live_, rk_test_), so redactSecretsInText masks them and holdsCredential recognises them.

Base commit: 62a7b7ac72e4f0adae1b373032592df7327d7b26.

Why

The sk- pattern is commented "anthropic / openai / stripe", but it only matches the hyphenated forms (sk-live-…). Real Stripe keys use underscores — sk_live_51H…, rk_live_… — so none of the existing patterns match them:

redactSecretsInText("stripe sk_live_abcdefghijklmnopqrstuvwxyz0123456789")
→ "stripe sk_live_abcdefghijklmnopqrstuvwxyz0123456789"   // unchanged
holdsCredential('stripe.secret = "sk_live_0123456789abcdefABCD"') → false

A Stripe key pasted into a chat, a tool title or an MCP args list therefore reached the protocol log and activity chips in the clear (only KEY=…-style assignments caught it, by name). The new pattern requires the full sk_live_ / sk_test_ / rk_… prefix plus 16+ alphanumerics, keeping with the file's high-precision rule.

Tests

server/redact.test.ts: three Stripe cases in "masks known key prefixes wherever they appear" and one in the holdsCredential positive list (assembled at runtime like the others, to stay clear of push protection).

  • On unmodified main: 2 failed — expected 'stripe sk_live_abcdef…' not to match /sk_live_[a-z]/, and holdsCredential returns false.
  • With the fix: server/redact.test.ts 22/22; vitest run shared server/decision-log.test.ts server/admin-activity.test.ts 34 files / 488 tests pass. Linux only.

AI assistance: this change was prepared with an AI coding assistant and reviewed and tested by me.

Summary by CodeRabbit

  • Bug Fixes
    • Improved redaction of Stripe credentials in text, including live and test secret keys and live and test restricted keys.
    • Stripe live secret keys are now recognized when identifying credential assignments, helping prevent them from appearing unmasked.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@kevin9327 is attempting to deploy a commit to the SupaMaus Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6107d54a-1749-4591-bb14-a3dfdb151cd9
📥 Commits

Reviewing files that changed from the base of the PR and between 62a7b7a and c307b8c.

📒 Files selected for processing: 2
  • server/redact.test.ts
  • shared/redact.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The redaction patterns now detect Stripe live and test secret and restricted keys. Tests verify that text redaction masks these keys and that a Stripe live secret assignment is identified as a credential.

Changes: Stripe credential redaction

Layer / File(s) Summary
Stripe key detection and validation
shared/redact.ts, server/redact.test.ts
The key-prefix patterns detect Stripe live and test secret and restricted keys. Tests cover text redaction and credential detection.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: bradhallett, milind-soni

Merge Risk: ⚪ Minimal · up to c307b

Stripe secret and restricted keys are recognized by the shared redaction and credential-detection logic; no concrete issue blocks merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the primary change: masking Stripe secret and restricted keys.
Description check Passed The description explains what changed, why it changed, and how it was verified. It omits the template checklist and uses a "Tests" heading instead of "How it was verified," but it provides the require…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains what changed, why it changed, and how it was verified. It omits the template checklist and uses a "Tests" heading instead of "How it was verified," but it provides the required verification details and is mostly complete.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kevin9327

Copy link
Copy Markdown
Contributor Author

The three failing vitest shards (ShareTeamDialog "1 playbooks", file-size-ratchet, chat-dir-auto TaskPicker) fail identically on main at 62a7b7a (CI run 39072696208), so they are pre-existing and unrelated to the redact change.

@milind-soni
milind-soni merged commit 170a58b into milind-soni:main Oct 18, 2026
20 of 28 checks passed
z4mbo added a commit to z4mbo/Origin that referenced this pull request Oct 18, 2026
Adapt the Stripe secret/restricted prefix pattern from milind-soni#3037, merge 170a58b. Preserve publishable keys, short examples and stable length-only markers.

The identical regression selection fails five/passes22 before the fix and passes all27 afterward, including a documented isolated fake-provider turn through the real native log writer. Consumer and guard checks pass194 with nine existing Windows skips; client/server types and focused lint pass.

Co-authored-by: Codex <noreply@openai.com>
jencryzthers added a commit to pulsatrixtechnologies/Sagax that referenced this pull request Oct 19, 2026
…, session Claude retirée après échec d'auth, clés Stripe) (#778)

## Résumé

Ports sélectifs des correctifs de sécurité du projet amont OpenMausBot,
classés « Sécurité » dans l'audit du 2026-10-18 (lot `secu-memoire`).
Réécrits chez nous, aucun cherry-pick, rien de `enterprise/`.

- **port de OpenMausBot milind-soni#2856** : la mémoire d'équipe
(`server/team-memory.ts`) était la seule mémoire écrite par un bot sans
masquage. Chaque entrée passe par `redactSecretsInText` avant d'être
enregistrée ou montrée ; en plus de l'amont, une entrée déjà enregistrée
par une version précédente est masquée au chargement et le fichier est
réécrit. La suppression d'un bot appelle `memoryUpkeep.forgetBot` dans
le gestionnaire `bot.deleted` (tous les chemins de suppression) : tours
en attente, lots différés et état d'entretien partent, et une capture
encore en vol n'écrit plus rien pour un bot disparu.
- **port de OpenMausBot milind-soni#2867** : un tour Claude réglé en
`auth_required` retire le processus du pool, comme `update_required`. Un
CLI resté vivant à réessayer son rafraîchissement OAuth partagé bloquait
les autres bots Claude.
- **port de OpenMausBot milind-soni#3037** (postérieur à l'audit, 3 lignes) :
masquage des clés Stripe `sk_live_`, `sk_test_`, `rk_live_` (l'ancien
motif ne couvrait que `sk-`), y compris coupées par « … ».

Non portés, avec raison :
- milind-soni#2707 (garde du corps de `request-sign-in`) : la fonctionnalité
n'existe pas chez nous.
- milind-soni#2708 (approbation de lecture des apps connectées) : recoupe les
règles d'approbation des membres, en refonte par un autre agent
(worktree sagax-member-terminal).
- milind-soni#2756 (plancher de sécurité, 3k lignes) : à décider par JC (lot 11 de
l'audit).

## Licence

Parties d'origine sous Apache 2.0 (LICENSE-APACHE, NOTICE déjà à jour) ;
nos adaptations sous PolyForm NC. Chaque port dit « port de OpenMausBot
#NNNN » en texte.

## Vérification

- Tests ajoutés : `team-memory.test.ts` (masquage à l'écriture et au
chargement), `memory-upkeep.test.ts` (bot supprimé oublié),
`redact.test.ts` (Stripe), `drivers/claude.test.ts` (le processus du CLI
meurt après `auth_required` ; échoue sans le correctif, passe avec).
- `team-memory`, `redact`, `memory-upkeep` : 78/78. `claude.test.ts` :
vert sauf « pays the cold start at process boot » (minutage < 300 ms,
charge machine 369), sans lien.
- `pnpm lint`, `pnpm typecheck` verts. Valeurs de test manifestement
fausses.
- Relecture de sécurité indépendante : aucun bloquant ; ses 2 importants
(test qui ne vérifiait rien, entrées déjà enregistrées non masquées) et
2 mineurs (forgetBot sur tous les chemins, préfixes Stripe coupés) sont
corrigés dans le 2e commit.

## Notes de version

- FR : Sécurité : les secrets sont masqués dans la mémoire d'équipe (y
compris les entrées déjà enregistrées), un bot supprimé ne laisse plus
d'état d'entretien de mémoire, une session Claude dont
l'authentification a échoué est fermée au lieu de bloquer les autres
bots, et les clés Stripe sont masquées.
- EN: Security: secrets are masked in team memory (including entries
already saved), a deleted bot leaves no memory upkeep state behind, a
Claude session whose sign-in failed is closed instead of blocking other
bots, and Stripe keys are masked.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Jean-Christophe Proulx <jencryzthers@Jean-Christophes-Macbook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants