Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 30, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

At the moment, if one is able to inject a forged payload into a queue, one can trigger any handler via the messenger consumer, including eg RunProcessHandler. This is not a security issue in Symfony itself because queues should be protected from arbitrary payload injection. But it'd still be nice to harden this.

This PR adds a new sign attribute to the messenger.message_handler DI tag (which can be set either via explicit config or via #[AsMessageHandler]).

When at least one handler does so, a SigningSerializer decorator is added to all transport serializers. This then computes the signature when encoding a message bound to such handlers, and verifies it when decoding one.

The sign attribute is enabled for RunProcessHandler and RunCommandHandler, and can be for any others of yours.

Submitting for 7.4 as having a hardened LTS looks important to me.

@nicolas-grekas nicolas-grekas added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Nov 1, 2025
@fabpot
Copy link
Member

fabpot commented Nov 1, 2025

Thank you @nicolas-grekas.

@fabpot fabpot merged commit da42259 into symfony:7.4 Nov 1, 2025
9 of 12 checks passed
@fabpot fabpot deleted the msg-sign branch November 1, 2025 16:13
This was referenced Nov 2, 2025
@nicodemuz
Copy link
Contributor

@nicolas-grekas Can I ask how will this behave if I have an existing queue with messages and then enable this in production? Will those existing messages not be processed as they are missing the signature?

What is the recommended way to enable this in production for existing queues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Messenger ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants