Skip to content

Security: programmersd21/inspect-rs

Security

SECURITY.md

Security Policy

Supported Versions

Version Supported
0.1.x

Security Considerations

Secrets and Sensitive Data

inspect-rs provides mechanisms to mark fields as sensitive or secret using attributes:

#[derive(Inspect)]
struct Credentials {
    #[inspect(secret)]
    password: String,
    
    #[inspect(sensitive)]
    api_key: String,
}

Important: The library can only redact values that are explicitly marked. It cannot automatically determine if arbitrary data is sensitive. You are responsible for:

  1. Marking sensitive fields with appropriate attributes
  2. Ensuring custom Inspect implementations don't leak secrets
  3. Configuring renderers appropriately for your security requirements

Resource Exhaustion

inspect-rs includes configurable limits to prevent resource exhaustion:

  • max_depth: Prevent stack overflow from deep nesting
  • max_items: Limit collection traversal
  • max_nodes: Limit total nodes visited
  • max_string_length: Truncate long strings
  • max_bytes: Limit byte slice lengths

Always configure appropriate limits when inspecting untrusted data.

Custom Implementations

When implementing Inspect for your own types:

  1. Never accidentally expose secrets or sensitive data
  2. Respect the context's limits
  3. Handle cycles appropriately
  4. Avoid panicking in inspection code

Cycle Detection

The library tracks visited memory addresses to detect cycles. This is a best-effort mechanism. Do not rely on it for security-critical isolation between values.

Reporting a Vulnerability

If you discover a security vulnerability in inspect-rs, please report it responsibly:

  1. Do not open a public GitHub issue
  2. Email the maintainers directly at: [SECURITY_EMAIL]
  3. Include:
    • A description of the vulnerability
    • Steps to reproduce
    • Potential impact
    • Suggested fix (if any)

We will:

  • Acknowledge receipt within 48 hours
  • Provide an initial assessment within 1 week
  • Work with you to understand and address the issue
  • Credit you in the security advisory (unless you prefer to remain anonymous)

Security Best Practices

When using inspect-rs:

  1. Mark sensitive fields: Use #[inspect(secret)] and #[inspect(sensitive)]
  2. Configure limits: Don't use unlimited inspection on untrusted data
  3. Review custom implementations: Audit any custom Inspect implementations
  4. Choose renderers carefully: Not all renderers may respect sensitivity markers
  5. Avoid logging secrets: Don't accidentally log inspected output containing secrets
  6. Test security: Verify that secrets are actually redacted in your output

Scope

inspect-rs is an introspection library, not a security framework. It provides tools to help you avoid accidentally exposing sensitive data, but cannot protect against:

  • Deliberate misuse
  • Bugs in your custom implementations
  • Side-channel attacks
  • Memory dumps or debugger access
  • Serialization of raw memory

Always follow security best practices appropriate for your application's threat model.

There aren't any published security advisories