Query Binding Masking and whereBinary() in Laravel 13.27
Laravel 13.27 introduces automatic sensitive binding masking in query logs and Telescope, alongside a dedicated whereBinary() builder method.
Enhanced Privacy & Binary Queries in Laravel 13.27
Laravel 13.27 brings two major database improvements: Query Binding Masking for masking secret attributes in database logs and a new whereBinary() method on the Eloquent Query Builder.
Masking Sensitive Query Bindings
When logging executed SQL queries in development or production diagnostics, sensitive parameters (like passwords, API keys, or SSNs) could previously leak into plain text logs. With Laravel 13.27, attributes marked as hidden or sensitive on models are automatically redacted in query logs:
use App\Models\User;
use Illuminate\Support\Facades\DB;
// Query logging with automatic masking enabled
DB::listen(function ($query) {
logger()->info($query->sql, $query->maskedBindings());
});
User::where('api_token', 'secret_token_12345')->first();
// Log Output: select * from "users" where "api_token" = [REDACTED]
Using the whereBinary() Builder Method
use App\Models\Document;
$hash = hash('sha256', 'payload-contents', true); // Raw binary
$document = Document::whereBinary('checksum', '=', $hash)->first();