Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Encryption Bundle Laravel Package

cleverage/encryption-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/Doctrine-Centric: The bundle is tightly coupled with Symfony’s Doctrine ORM, making it ideal for applications already using this stack. It introduces transparent encryption for fields via custom Doctrine types (encrypt_string, encrypt_text), aligning with Symfony’s declarative approach.
  • Field-Level Encryption: Suitable for PII, sensitive business logic, or compliance-driven data (e.g., GDPR, HIPAA) where granular encryption is required without application-layer changes.
  • Key Management Model: Leverages user-specific cipher keys (derived from hashed passwords) to enable collaborative decryption within organizations while isolating data between users. This is a novel approach compared to static keys or per-record keys.
  • Limitation: Not designed for file storage (despite the README mention); the encrypt_* types are for string/text fields only. Clarification needed on "file encryption" claims.

Integration Feasibility

  • Low Friction for Symfony Apps: Requires minimal changes—just Doctrine entity annotations and bundle configuration. No middleware or service overrides needed for basic use.
  • Dependency Risks:
    • Symfony 2.x Only: Last release in 2021 (pre-Symfony 5/6). May conflict with modern Symfony versions or Doctrine ORM updates.
    • PHP Session Dependency: Cipher keys are stored in PHP sessions, which could cause issues in:
      • Headless/CLI environments (e.g., cron jobs, queues).
      • Distributed setups without shared sessions (e.g., multi-server deployments).
      • Long-running processes (session timeouts may truncate access).
  • Database Schema Impact: No schema migrations required, but backward compatibility could break if Doctrine types are misconfigured.

Technical Risk

Risk Area Severity Mitigation Strategy
Symfony 2.x Obsolescence High Fork/maintain or evaluate alternatives (e.g., FOSUserBundle + custom encryption).
Session Key Storage Medium Supplement with environment variables for admin keys or use a cache layer (e.g., Redis) for key persistence.
Password Hashing Dependency Medium Ensure alignment with Symfony’s UserChecker/PasswordHasher interfaces.
No Asymmetric Support Low Accept limitation or layer on top (e.g., RNCryptor).
Performance Overhead Low Benchmark encryption/decryption latency for high-throughput fields.

Key Questions

  1. Symfony Version Compatibility:
    • Does the bundle work with Symfony 5/6? If not, what’s the effort to upgrade?
    • Are there breaking changes in Doctrine’s type system since 2021?
  2. Key Rotation:
    • How is key rotation handled for users changing passwords? Is re-encryption automatic?
  3. Multi-Tenancy:
    • Can cipher keys be scoped per tenant/organization, or is it strictly user-based?
  4. Auditability:
    • Are encryption/decryption events logged for compliance?
  5. Alternatives:
    • Why not use Doctrine Extensions (e.g., Gedmo) or database-level encryption (e.g., PostgreSQL pgcrypto)?
  6. Testing:
    • Are there unit/integration tests for edge cases (e.g., session loss, concurrent writes)?

Integration Approach

Stack Fit

  • Best For:
    • Symfony 2.x applications using Doctrine ORM.
    • Use cases requiring field-level encryption without application logic changes.
    • Teams prioritizing developer simplicity over fine-grained control.
  • Poor Fit:
    • Non-Symfony PHP apps (e.g., Lumen, Slim).
    • Projects needing file encryption (use Vault or AWS KMS instead).
    • High-security environments where session storage of keys is unacceptable.

Migration Path

  1. Assessment Phase:
    • Audit existing Doctrine entities to identify sensitive fields.
    • Verify Symfony version compatibility (or plan a fork).
  2. Pilot Implementation:
    • Start with non-critical fields (e.g., notes, comments) to test performance and key management.
    • Use feature flags to toggle encryption for gradual rollout.
  3. Configuration:
    • Add bundle to composer.json and enable in config/bundles.php.
    • Configure sidus_encryption in config/packages/sidus_encryption.yaml (e.g., cipher algorithm, key derivation iterations).
    • Example:
      sidus_encryption:
          cipher: AES-256-CBC
          iterations: 10000
      
  4. Entity Migration:
    • Add @ORM\Column(type="encrypt_string") annotations to fields.
    • Example:
      class Patient {
          /**
           * @ORM\Column(type="encrypt_string")
           */
          private string $ssn;
      }
      
  5. Key Management:
    • Ensure user entities have a password field (used for key derivation).
    • Consider adding a backup key for admins (stored securely outside sessions).

Compatibility

  • Doctrine ORM: Requires Doctrine 2.x. Conflicts possible with modern Doctrine extensions (e.g., doctrine/orm:^2.10).
  • Symfony Security: Relies on Symfony’s password hashing. May need adjustments for custom user providers.
  • Database: No schema changes, but indexes on encrypted fields are useless (performance impact for queries).
  • Caching: Encrypted data cannot be cached effectively (e.g., APCu, Redis). Use selective caching for non-sensitive fields.

Sequencing

  1. Phase 1: Add bundle and configure for a subset of entities.
  2. Phase 2: Implement key rotation logic for password changes.
  3. Phase 3: Extend to high-sensitivity fields (e.g., PII).
  4. Phase 4: Monitor performance and audit logs; adjust cipher parameters if needed.

Operational Impact

Maintenance

  • Bundle Maintenance: High risk due to abandonment (last release 2021). Plan for:
    • Forking the repo to fix compatibility issues.
    • Dependency updates (e.g., Symfony 5/6, Doctrine 2.10+).
  • Key Management:
    • Password Changes: Requires re-encryption of all data for a user (resource-intensive).
    • Lost Keys: Irrecoverable data if a user’s password hash is lost (no backup mechanism by default).
  • Documentation: Minimal. Expect to document internal processes (e.g., key rotation, troubleshooting).

Support

  • Debugging:
    • Encrypted fields appear as ***** in logs/debuggers, complicating troubleshooting.
    • No built-in decryption tools for admins (must use application code).
  • Vulnerability Response:
    • If a cipher weakness is found (e.g., in key derivation), all encrypted data must be re-encrypted.
    • No built-in key revocation for compromised users.
  • Community: Nonexistent (0 stars, 0 dependents). Support limited to issue tracker or forking.

Scaling

  • Performance:
    • Encryption Overhead: Each read/write triggers AES operations. Benchmark for high-throughput fields (e.g., created_at encrypted would be costly).
    • Session Storage: Keys in PHP sessions may become a bottleneck in high-concurrency environments.
  • Horizontal Scaling:
    • Stateless Servers: Keys must be re-fetched on session loss (e.g., after load balancer restart).
    • Multi-Region: Session replication adds latency; consider distributed caching for keys.
  • Database:
    • Encrypted fields cannot be indexed, limiting query performance for filtered searches.

Failure Modes

Scenario Impact Mitigation
Session Timeout User loses decryption key. Implement key caching (Redis).
Password Reset All user data must re-encrypt. Batch re-encryption via cron.
Database Corruption Encrypted blobs may become invalid. Regular backups + validation checks.
Symfony/Doctrine Upgrade Bundle breaks. Fork and maintain.
Key Leak (Session Hijacking) Attacker decrypts data for active users. Use HTTPS, short session lifetimes.

Ramp-Up

  • Developer Onboarding:
    • 1–2 days to understand encryption flow (key derivation, session storage).
    • 1 week to implement for a pilot entity.
  • Security Team Review:
    • High scrutiny due to
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui