Laravel MongoDB 5.12.0 Introduces Native Queryable Encryption Support

The mongodb/laravel-mongodb package released version 5.12.0 on October 26, 2026, adding first-class support for MongoDB Queryable Encryption. This update allows developers to declare encrypted fields directly in connection configurations, enabling the driver to handle encryption, decryption, and queries transparently without altering Eloquent model structures. The release includes new Artisan commands for managing encrypted collections and data keys, while also addressing security vulnerabilities and fixing various bugs related to query macros and type coercion. Notably, it enforces stricter security by blocking server-side JavaScript operators and requires MongoDB 8.0 or later for range queries on encrypted data.
Key points
- Queryable Encryption is now supported, allowing encrypted fields to be defined in the connection configuration with automatic handling by the MongoDB driver.
- New Artisan commands, 'mongodb:encryption:create-collection' and 'mongodb:encryption:status', facilitate the creation and verification of encrypted collections and their metadata.
- Security improvements include blocking dangerous server-side JavaScript operators like '$where' and '$function' in database queries to prevent potential exploits.
- Breaking changes affect schema methods such as 'hasTable()' and 'dropIfExists()', which now apply connection prefixes, potentially causing migrations to re-run if not handled correctly.
- The release fixes issues with eager loading MorphTo relations, ensuring that query macros and constraints are properly replayed, and addresses a security vulnerability identified as CVE-2026-118510.
Background
This release follows recent updates in the MongoDB ecosystem, such as the October 2026 launch of MongoDB Compass 1.53.0, which introduced light mode and connection enhancements. While Compass focuses on the user interface and connection management, this Laravel package update targets backend integration and data security for PHP developers using MongoDB with Laravel.
Why it matters
This update significantly enhances data security for Laravel applications using MongoDB by integrating Queryable Encryption, a feature that allows sensitive data to be encrypted at rest and in transit while remaining queryable. By automating the encryption process through connection configurations and providing dedicated Artisan commands, the release reduces the complexity of implementing robust data protection. Additionally, the security hardening measures, such as blocking server-side JavaScript operators, mitigate potential attack vectors, making the package more resilient against common exploits. These changes are critical for developers handling sensitive data, as they ensure compliance with security standards and reduce the risk of data exposure.
What to watch
Developers using this package should upgrade to version 5.12.0 to leverage Queryable Encryption and the security fixes. They must review their schema methods to account for the new prefix application, which may require adjustments to prevent migrations from re-running. Additionally, users should ensure their MongoDB environment meets the version requirements for Queryable Encryption, specifically MongoDB 8.0 or later for range queries. Monitoring the status of encrypted collections using the new Artisan commands will help verify that configurations are correctly applied and that no data is stored in plaintext.
Want the full story? Read the original reporting
Read on MongoDB | Alerts