Log Redaction Audit

    by Khristian Kopachelli

    1

    Recursive secret redaction and security audit framework for preventing credential leakage in application logs.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Log Redaction Audit

    Example session with this skill installed

    Audit this snippet for potential log leaks and suggest redaction: console.log('User login failed', { user: user.id, auth: req.headers.authorization, error: err });

    • Read your context and instructions
    • Compiled the log redaction audit

    The provided snippet contains a critical leak vector by logging the authorization header and the raw error object. In many frameworks, logging the error object raw includes the full stack trace and potentially the request body that triggered the failure.

    Log Redaction Audit Report

    Leak VectorSeverityRecommended Fix
    req.headers.authorizationCriticalUse redact() on the metadata object to mask the Bearer token.
    error: errHighWrap with redactError(err) to scrub sensitive props and stack traces.
    Structured MetadataMediumImplement a boundary-level logger wrapper instead of inline object logging.

    Implementation Suggestion

    import { redact, redactError } from 'redact-log';
    
    // Problematic line:
    // console.log('User login failed', { user: user.id, auth: req.headers.authorization, error: err });
    
    // Audited & Fixed implementation:
    const logMetadata = redact({ 
      user: user.id, 
      auth: req.headers.authorization, 
      error: redactError(err) 
    });
    
    logger.error('User login failed', logMetadata);
    

    Next steps

    1. Replace the console.log call with a structured logger that implements redact-log at the transport level.
    2. Verify if user.id is considered PII in your jurisdiction and add to extraKeys if necessary.
    3. Run a global grep for headers.authorization to find similar unsanitized logging calls.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Secrets leak into logs constantly through thrown errors, request headers, or debug prints of config objects. This skill provides a systematic audit framework and implementation guide for intercepting credentials before they reach your log store. It focuses on a two-layer defense: intelligent key-based tokenization and high-precision pattern matching for known secret formats.

    What it does

    • Secret detection identifies PEM blocks, JWTs, Bearer tokens, and specific provider keys (AWS, Stripe, GitHub, OpenAI) in free text.
    • Recursive redaction masks sensitive keys like sessionKey, api_key, and Authorization at any nesting depth in JSON objects.
    • Error scrubbing cleans stack traces and error properties to prevent request data echoes from appearing in logs.
    • Pathological input protection uses maxDepth and maxNodes guards to prevent hanging on circular or massive data structures.
    • Customizable masking allows for domain-specific extraKeys, regex patterns, and allowlists to reduce false positives.

    How it works

    1. Source analysis involves grepping the codebase for logging calls situated near environment variables, auth headers, and config objects.
    2. Implementation audit checks that redaction is applied at the transport boundary rather than inconsistently across call sites.
    3. Secret simulation tests the pipeline by feeding it realistic JWT, PEM, and provider-specific key shapes to verify masking.
    4. Refinement adds domain-specific terms to extraKeys for exotic credential names like internalApiToken.

    Frameworks & tools

    This skill utilizes the redact-log pattern and is designed for TypeScript/JavaScript environments. It integrates with standard logging libraries via wrappers and provides regex patterns for CLI auditing using grep.

    Why this beats prompting it yourself

    Generic prompts often miss the nuances of error object serialization and nested JSON structures. This skill uses a proven two-layer model that tokenizes keys to avoid "over-redacting" similar words while ensuring free-text patterns catch high-entropy strings like PEM blocks that key-matching alone misses.

    Use cases

    • Auditing a PR that introduces new logging to ensure no credentials leak.
    • Preparing compliance evidence for SOC2 or GDPR by demonstrating log sanitization.
    • Implementing a centralized log wrapper to scrub errors before they hit Sentry or Datadog.
    • Scanning legacy codebases for console.log calls that output raw request headers.

    Known limitations

    Redaction is best-effort pattern matching and not a mathematical proof of security. Exotic credential names like cred2 require manual configuration via extraKeyPatterns to be caught.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 5 days ago

    Permissions

    Terminal / Shell
    Environment Variables
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    This skill solves the 'leaky log' problem by providing a systematic framework to identify and mask credentials, JWTs, and sensitive JSON keys before they are stored in external services like Datadog or Sentry.

    The skill is optimized for TypeScript and JavaScript environments, providing specific logic for handling nested JSON objects and error serialization common in these ecosystems.

    You receive a comprehensive audit guide, a suite of high-precision regex patterns for secret detection, recursive redaction logic for nested data, and a simulation set for testing your pipeline's effectiveness.

    While it includes deep support for standard keys like 'api_key' or 'Authorization,' you can easily extend the protection by adding domain-specific terms to the 'extraKeys' configuration or providing custom regex patterns.

    Yes, the framework includes built-in 'maxDepth' and 'maxNodes' guards specifically designed to prevent performance bottlenecks or hangs when processing circular references or large data structures.

    The framework facilitates compliance evidence for SOC2 and GDPR by establishing a verifiable, two-layer defense that demonstrates proactive measures to prevent PII and credential leakage.

    New in Security

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.