Skip to content

[5.19.x] Update Stomp transports with improved validation (#2064)#2066

Merged
cshannon merged 1 commit into
apache:activemq-5.19.xfrom
cshannon:2064-backport-5.19.x
Jun 2, 2026
Merged

[5.19.x] Update Stomp transports with improved validation (#2064)#2066
cshannon merged 1 commit into
apache:activemq-5.19.xfrom
cshannon:2064-backport-5.19.x

Conversation

@cshannon
Copy link
Copy Markdown
Contributor

@cshannon cshannon commented Jun 1, 2026

This update makes the following changes to improve validation for the Stomp transport:

  • Verifies that the first frame seen by the server is either a CONNECT (or FRAME) frame.
  • Verifies that a duplicate CONNECT (or FRAME) frame is not received.
  • Adds validation to make sure a content-length header that is set is not negative.
  • Adds a new server mode (default true) to the Stomp wireformat to handle the validation differences between clients and servers. Client mode is only used for testing (currently). Also adds the option to configure using the StompWireFormatFactory in case there is a future use case.
  • Centralizes the state tracking for frame size validation and for the new validation checks inside StompWireFormat so that it is shared by NIO, non-NIO and WS transports.
  • Adds tests to verify everything for the NIO transports, non-NIO transprots and WS transports.

If any of these new validation checks throw a protocol error then it is marked as a fatal exception, an error is sent to the client and connection closed. Both NIO and non-NIO will stop parsing the rest of the frame on error, but only NIO transport errors will stop reading the frame from the socket buffer because non NIO requires reading the entire frame into a buffer first to validate.

(cherry picked from commit 1493db9)
Backport of #2064

This update makes the following changes to improve validation for the
Stomp transport:

* Verifies that the first frame seen by the server is either a CONNECT
  (or FRAME) frame.
* Verifies that a duplicate CONNECT (or FRAME) frame is not received.
* Adds validation to make sure a content-length header that is set is
  not negative.
* Adds a new server mode (default true) to the Stomp wireformat to
  handle the validation differences between clients and servers. Client
  mode is only used for testing (currently). Also adds the option to
  configure using the StompWireFormatFactory in case there is a future use
  case.
* Centralizes the state tracking for frame size validation and for the
  new validation checks inside StompWireFormat so that it is shared by
  NIO, non-NIO and WS transports.
* Adds tests to verify everything for the NIO transports, non-NIO
  transprots and WS transports.

If any of these new validation checks throw a protocol error then it
is marked as a fatal exception, an error is sent to the client and
connection closed. Both NIO and non-NIO will stop parsing the rest of
the frame on error, but only NIO transport errors will stop reading
the frame from the socket buffer because non NIO requires reading the
entire frame into a buffer first to validate.

(cherry picked from commit 1493db9)
@cshannon cshannon force-pushed the 2064-backport-5.19.x branch from e752e1f to 5bed364 Compare June 1, 2026 23:59
@cshannon
Copy link
Copy Markdown
Contributor Author

cshannon commented Jun 2, 2026

This backport also includes #2067

@cshannon cshannon changed the title Update Stomp transports with improved validation [5.19.x] Update Stomp transports with improved validation (#2064) [5.19.x] Jun 2, 2026
@cshannon cshannon changed the title Update Stomp transports with improved validation (#2064) [5.19.x] [5.19.x] Update Stomp transports with improved validation (#2064) Jun 2, 2026
@cshannon cshannon merged commit 63ca733 into apache:activemq-5.19.x Jun 2, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Apache ActiveMQ v5.19.8 Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant