Skip to content

Update Stomp transports with improved validation#2064

Merged
cshannon merged 1 commit into
apache:mainfrom
cshannon:stomp-validation
Jun 1, 2026
Merged

Update Stomp transports with improved validation#2064
cshannon merged 1 commit into
apache:mainfrom
cshannon:stomp-validation

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.

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.
@cshannon cshannon merged commit 1493db9 into apache:main Jun 1, 2026
9 of 10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Apache ActiveMQ v6.3.0 Jun 1, 2026
@cshannon cshannon deleted the stomp-validation branch June 1, 2026 21:58
cshannon added a commit to cshannon/activemq that referenced this pull request 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)
cshannon added a commit to cshannon/activemq that referenced this pull request 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants