Skip to content

Security: koffih/tzaruf

Security

SECURITY.md

Security Policy

πŸ”’ Security Commitment

Tzaruf takes security seriously. We are committed to providing a safe and secure document processing service for all users.

πŸ› Reporting a Vulnerability

Please DO NOT report security vulnerabilities through public GitHub issues.

Instead, please report them via email to: security@tzaruf.dev

You should receive a response within 48 hours. If for some reason you do not, please follow up via email to ensure we received your original message.

What to Include

Please include as much information as possible:

  • Type of vulnerability
  • Step-by-step instructions to reproduce
  • Proof-of-concept or exploit code (if available)
  • Impact of the vulnerability
  • Possible fix or mitigation (if you have suggestions)

⚑ Security Measures

Input Validation

  • MIME Type Detection: We use magic bytes (libmagic) to validate file types, not just file extensions
  • File Size Limits: Configurable maximum file sizes to prevent DoS
  • Path Sanitization: All file paths are validated and sanitized
  • Content Validation: Documents are validated before processing

Sandboxing

  • Isolated Processing: Document conversion runs in isolated processes
  • Non-root Execution: Docker images run as non-root user
  • Resource Limits: Configurable memory and CPU limits

Dependencies

  • Regular Updates: Dependencies are regularly updated
  • Security Scanning: Automated scanning with bandit and safety
  • Dependabot: Automated PR creation for security updates
  • Minimal Dependencies: We minimize dependencies to reduce attack surface

Code Quality

  • Type Safety: Full type hints with mypy strict mode
  • Linting: Ruff and other linters to catch potential issues
  • Code Review: All changes require review
  • Testing: Comprehensive test suite

πŸ” Security Features

Data Privacy

  • βœ… No Telemetry: We don't collect any usage data
  • βœ… No Cloud: Processing is done locally, no cloud services
  • βœ… No Network: No outbound network requests (except for optional OCR models)
  • βœ… Temporary Files: Cleaned up after processing

Cryptography

  • βœ… Encrypted PDFs: Support for password-protected PDFs
  • βœ… Secure Defaults: Security-first default configurations
  • βœ… No Hardcoded Secrets: No credentials in code

🚨 Known Security Considerations

PDF Processing

  • Malicious PDFs: PDFs can contain JavaScript and other active content. We use PyMuPDF which handles this safely, but always be cautious with untrusted PDFs.

  • Encrypted PDFs: Password-protected PDFs require the password to process. We don't attempt to crack passwords.

OCR Engines

  • Model Downloads: EasyOCR downloads models on first use. These are downloaded from official sources but require internet access.

  • GPU Access: If using GPU acceleration, the process needs GPU access which could be a privilege escalation vector in some environments.

File System

  • Temporary Files: Temporary files are created during processing. Ensure your /tmp directory has appropriate permissions.

  • Disk Space: Large documents can consume significant disk space. Monitor available space.

πŸ“‹ Security Checklist for Users

When deploying Tzaruf in production:

  • Run as non-root user
  • Use Docker with appropriate resource limits
  • Set restrictive file permissions
  • Configure maximum file size limits
  • Use firewall rules to restrict network access
  • Regular updates of Tzaruf and dependencies
  • Monitor logs for suspicious activity
  • Use virus scanning on uploaded files
  • Implement rate limiting for API endpoints
  • Use HTTPS for API communications
  • Validate all user inputs
  • Regular security audits

πŸ” Security Best Practices

For Developers

from tzaruf import Forge, ForgeConfig

# Use secure defaults
config = ForgeConfig(
    max_file_size_mb=50,  # Limit file sizes
    allow_encrypted_pdfs=False,  # Disable if not needed
    sanitize_filenames=True,  # Always sanitize
)

forge = Forge(config=config)

# Validate inputs
if not input_path.exists():
    raise ValueError("File not found")

if not input_path.is_file():
    raise ValueError("Not a file")

# Process safely
try:
    result = forge.convert(input_path, output_path)
except Exception as e:
    # Handle errors appropriately
    logger.error("Conversion failed", error=str(e))

For System Administrators

# Run with Docker for isolation
docker run --rm \
  --cpus=2 \
  --memory=4g \
  --read-only \
  --tmpfs /tmp \
  -v /path/to/input:/data:ro \
  -v /path/to/output:/output \
  tzaruf:latest convert /data/input.docx /output/output.pdf

# Use AppArmor/SELinux for additional security
# Set up monitoring and alerting
# Regular backups

πŸ“Š Vulnerability Disclosure Timeline

We follow responsible disclosure:

  1. Day 0: Vulnerability reported to security@tzaruf.dev
  2. Day 1-2: Initial response and acknowledgment
  3. Day 3-14: Vulnerability assessment and fix development
  4. Day 15-30: Fix released and security advisory published
  5. Day 31+: Public disclosure after users have time to update

πŸ† Security Hall of Fame

We appreciate security researchers who help make Tzaruf safer:

  • (Your name could be here!)

πŸ“ž Contact

πŸ“œ Security Updates

Security updates will be:

  • Published in CHANGELOG.md
  • Announced in GitHub Security Advisories
  • Tagged with appropriate CVE numbers if applicable

Last Updated: December 2024

Thank you for helping keep Tzaruf and its users safe! πŸ™

There aren't any published security advisories