← Back to Pull requests

fix(redaction): catch Google, Stripe and Hugging Face keys and env-style secret assignments #32

Closed
unknown closed this pull request without merging on Nov 25, 2026 13:09 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 12:23 UTC
Author

Bug


Thread summaries, facets and insights go through lib/redaction.js before they're sent to the model (llm-insights.js) and written into the report. The patterns caught sk- keys, GitHub, AWS, Slack and npm tokens, Bearer tokens and passwords. They missed several shapes that are common in Codex sessions, and those passed through verbatim:
  • Google API keys (AIza…, e.g. GEMINI_API_KEY=AIza…);

  • Stripe secret and restricted keys (sk_live_…, rk_test_…). The underscore form doesn't match the sk- pattern;

  • Hugging Face tokens (hf_…);

  • any value without a recognisable prefix assigned to an env-style secret variable, such as OPENROUTER_API_KEY=… or SENTRY_AUTH_TOKEN: "…".
  • Fix


  • New patterns for the three key shapes.

  • An upper-case _API_KEY | _SECRET | _SECRET_KEY | _ACCESS_TOKEN | _AUTH_TOKEN | _TOKEN assignment pattern. It keeps the variable name and replaces only the value. It skips:

  • - values that are already redacted;
    - variable references ($X, ${{ secrets.X }});
    - unquoted values shorter than 8 characters (CSRF_TOKEN=on);
    - names like MAX_TOKENS.

    Tests


    Two new cases in test/redaction.test.js:
  • exact output for each new shape, with a redaction count of 6. This fails on main;

  • a negative case: workflow ${{ secrets… }}, $VAR, MAX_TOKENS=4096 and CSRF_TOKEN=on are left unchanged.
  • npm test (153), lint, typecheck and npm run check pass. A 100 KB adversarial input redacts in about 1 ms, so there's no regex blow-up.

    The gap was found in a manual review assisted by AI (an AI coding agent working on Mangesh's behalf).

    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/mangeshraut712/codex-insights/pull/32" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Touches privacy-critical regex used before insights hit external models; wrong boundaries could miss secrets or over-redact, though behavior is heavily test-covered.

    > Overview

    Expands secret redaction so session summaries and LLM-bound data no longer leak Google (AIza…), Stripe (sk_live_ / rk_test_), Hugging Face (hf_…), or generic uppercase env assignments (OPENROUTER_API_KEY=…, SENTRY_AUTH_TOKEN: "…"), including bare names like API_KEY / TOKEN / SECRET_KEY.

    > Adds an ENV_SECRET_ASSIGNMENT pass that keeps the variable name and replaces only the value, with guards for ${{ secrets… }}, $VAR, short values (CSRF_TOKEN=on), empty assignments, and line boundaries; it runs after URL credential redaction so passwords containing , or ; are not split incorrectly.

    > New test/redaction.test.js cases lock in expected placeholders, negative cases, comma-in-sentence behavior, and redactSessionSummary serialization.

    > <sup>Reviewed by Cursor Bugbot for commit a192c14e6c168f23e6d11430081965b299b0b7b8. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 415 lines (+311 / -104) across 5 files Reviewer: mangeshraut712 Review duration: 45m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.73) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.73 · 415 lines diff across 5 files
    0.73
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.361
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.073
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #32"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 73.1% (HIGH) · Higher = larger blast radius
    73.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.9% · Safe to merge
    28.9%