Skip to content

Validate TCP message string lengths#1746

Merged
kevinherron merged 1 commit into
eclipse-milo:mainfrom
kevinherron:codex/propose-fix-for-unbounded-string-allocation-vulnerability
May 17, 2026
Merged

Validate TCP message string lengths#1746
kevinherron merged 1 commit into
eclipse-milo:mainfrom
kevinherron:codex/propose-fix-for-unbounded-string-allocation-vulnerability

Conversation

@kevinherron
Copy link
Copy Markdown
Contributor

Motivation

  • Fix a remotely-triggerable denial-of-service in OPC UA TCP Hello/Error decoding where attacker-controlled string lengths could cause large/unbounded heap allocations and negative-size allocations.
  • Restore protocol and encoding limits (endpoint URL max bytes and message-size limits) and ensure frame-bounds checking happens before any allocation.

Description

  • HelloMessage: validate constructor using UTF-8 encoded byte length, encode endpoint URL using UTF-8 byte length, and in decode reject negative lengths, enforce MAX_ENDPOINT_URL_LENGTH, and verify the declared length fits in buffer.readableBytes() before allocating and reading bytes.
  • ErrorMessage: encode reason using UTF-8 byte length, make decode throw UaException, reject negative lengths, enforce a message-size limit (EncodingLimits.DEFAULT_MAX_MESSAGE_SIZE), and verify remaining frame bytes before allocation.
  • Tests: add new ErrorMessageTest and extend HelloMessageTest with cases for negative lengths, truncated frames, and oversized lengths to cover the regression.
  • Misc: adjust imports and signatures (throws UaException) where needed to propagate decoding errors.

Codex Task

@kevinherron kevinherron added this to the 1.1.4 milestone May 17, 2026
@kevinherron kevinherron merged commit e6062c0 into eclipse-milo:main May 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant