Safeguard
Security Guides•

Should Laravel queued jobs be encrypted with ShouldBeEncrypted?

Encrypt a Laravel job with ShouldBeEncrypted when its payload holds personal data or tokens. Learn what it protects, what it does not, and the cost.

Safeguard Security Team
4 min read

Add the ShouldBeEncrypted interface to a Laravel job when its payload contains personal data, tokens or anything you would not want readable in Redis or a database table. Laravel then encrypts the job before it is pushed to the queue. It protects data at rest in the queue, not data inside your code.

What is in a queued job

A queued job is a serialized object sitting in a store until a worker picks it up. That store might be Redis, a jobs table, SQS or Beanstalkd. Anyone with read access to it, a backup of it, or a debugging dashboard that shows payloads can read what the job carries.

The Laravel documentation also describes how models are handled. If you pass an Eloquent model into a job constructor, only its identifier is serialized, and the model is fetched again when the job runs. That keeps payloads small and keeps most record data out of the queue. Plain arrays, strings and DTO properties are different: they are stored as given.

How to turn it on

use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendStatementEmail implements ShouldQueue, ShouldBeEncrypted
{
    // ...
}

The documentation says Laravel will automatically encrypt the job before pushing it onto the queue. It uses the same encrypter as the rest of the framework, so it depends on your APP_KEY.

When it makes sense

Payload contentEncrypt the job?Better first step
Model id onlyUsually not neededKeep passing ids
Email address or nameConsider itPass the id and load the record in the job
API token or password reset secretYes, or avoid putting it in the jobLook it up at run time
Large file contentsAvoidStore the file, pass a path

The cleanest control is to keep sensitive values out of the payload. Pass an id, and read the sensitive column when the job runs. Encryption is the backstop for the cases where that is not practical.

What it does not do

It does not hide data from anyone who can run code in your application, since workers decrypt the payload to run it. It does not protect job names and queue names. It also ties job readability to your key, so a key rotation matters. Laravel supports APP_PREVIOUS_KEYS so that older values can still be decrypted, but jobs sitting in a long retry window deserve a check after any rotation.

A short review routine

  1. List jobs that carry request data, user data or credentials in their properties.
  2. For each, ask whether an id would be enough.
  3. Add ShouldBeEncrypted to the remainder.
  4. Check where failed jobs are stored, since the failed job record keeps a copy of the payload.
  5. Restrict who can open any queue dashboard in production.

Quick check

Does ShouldBeEncrypted slow jobs down?

It adds an encrypt and decrypt step per job. For most workloads that is small next to the job itself, but measure it if you process very high volumes.

Are failed jobs encrypted too?

The docs describe encryption before the job is pushed to the queue. Check what your failed jobs table actually stores in a test environment before assuming.

Safeguard's asset discovery and policy gates can help you keep an inventory of the services and queues your applications depend on. Run a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.