Log Redaction Audit
Recursive secret redaction and security audit framework for preventing credential leakage in application logs.
$12
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 Vector | Severity | Recommended Fix |
|---|---|---|
req.headers.authorization | Critical | Use redact() on the metadata object to mask the Bearer token. |
error: err | High | Wrap with redactError(err) to scrub sensitive props and stack traces. |
| Structured Metadata | Medium | Implement 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
- Replace the
console.logcall with a structured logger that implementsredact-logat the transport level. - Verify if
user.idis considered PII in your jurisdiction and add toextraKeysif necessary. - Run a global grep for
headers.authorizationto 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, andAuthorizationat 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
maxDepthandmaxNodesguards 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
- Source analysis involves grepping the codebase for logging calls situated near environment variables, auth headers, and config objects.
- Implementation audit checks that redaction is applied at the transport boundary rather than inconsistently across call sites.
- Secret simulation tests the pipeline by feeding it realistic JWT, PEM, and provider-specific key shapes to verify masking.
- Refinement adds domain-specific terms to
extraKeysfor exotic credential names likeinternalApiToken.
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.logcalls 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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
What's inside
Frequently Asked Questions
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.