Skip to content

Limit WireFormatInfo platform details to a reasonable length#2088

Merged
cshannon merged 2 commits into
apache:mainfrom
cshannon:limit-platform-details
Jun 8, 2026
Merged

Limit WireFormatInfo platform details to a reasonable length#2088
cshannon merged 2 commits into
apache:mainfrom
cshannon:limit-platform-details

Conversation

@cshannon

@cshannon cshannon commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Now that #2083 limits value sizes for properties inside of WireFormatInfo we should add a check to make sure platform details do not go past that limit. Limit has been set to 512 bytes as that should be more than enough as the details are usually less than half that. This is not turned of by default but if someone is using it this will prevent potential future problems for too large a value.

Now that apache#2083 limits value sizes for properties inside of
WireFormatInfo we should add a check to make sure platform details do
not go past that limit. Limit has been set to 256 bytes as that should
be more than enough as the details are usually less than half that.
This is not turned of by default but if someone is using it this will
prevent potential future problems for too large a value.
tabish121
tabish121 previously approved these changes Jun 8, 2026
details = platformInfo.toString();
} catch (Throwable e) {
// truncate to the max allowed length if too long
details = platformInfo.length() > PLATFORM_DETAILS_MAX_LENGTH ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cuts off the details without any indication they were cut off, which is probably fine. I have seen some implementation do this by inserting an ellipsis after a given point and then appending a small bit trailing value such that you get a sort of visual indication that it was clipped. Probably not needed here so just making sure you thought about that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's fine here, it's off by default and its now 512 and shouldn't really be hit but we could improve it later if needed. This is more of just a fail safe. I doubt anyone even turns this setting on to be honest.

@mattrpav

mattrpav commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Some practical limits from a quick search show 256 is right up at the practical usage. 384 or 512 may be slightly better to avoid concatenation for known real-world data values.

Note: Cloud provider kernel version numbers can get long.

System Property Typical Max Length (Characters) Real-World Long Examaple
java.vm.version 45–60 25.0.0-internal-developer_2026_03_2_10_15-b01
java.vendor 25–40 International Business Machines Corp.
java.version 10–20 1.8.0_412-20240417-b01
os.arch 5–10 aarch64 or x86_64
os.name 15–25 Red Hat Enterprise Linux
os.version 15–30 5.4.0-105-generic or 6.1.0-21-amd64

@cshannon

cshannon commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@mattrpav - thanks for pointing that out, i can just bump to 512 which is still not that big. 512 is our default max so I can just make it the same I suppose

static final int MAX_PROPERTY_SIZE = 64;
// Used to validate property values that allocate buffers, limit to 512 bytes
static final int MAX_PROPERTY_BUFFER_SIZE = 512;
public static final int MAX_PROPERTY_BUFFER_SIZE = 512;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch I forgot that you made the default for WireFormatInfo 512 from the original 256

@mattrpav mattrpav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cshannon cshannon merged commit 60af386 into apache:main Jun 8, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Apache ActiveMQ v6.3.0 Jun 8, 2026
@cshannon cshannon deleted the limit-platform-details branch June 8, 2026 18:39
cshannon added a commit that referenced this pull request Jun 8, 2026
Now that #2083 limits value sizes for properties inside of
WireFormatInfo we should add a check to make sure platform details do
not go past that limit. Limit has been set to 512 bytes as that should
be more than enough as the details are usually less than half that.
This is not turned of by default but if someone is using it this will
prevent potential future problems for too large a value.

(cherry picked from commit 60af386)
cshannon added a commit that referenced this pull request Jun 8, 2026
Now that #2083 limits value sizes for properties inside of
WireFormatInfo we should add a check to make sure platform details do
not go past that limit. Limit has been set to 512 bytes as that should
be more than enough as the details are usually less than half that.
This is not turned of by default but if someone is using it this will
prevent potential future problems for too large a value.

(cherry picked from commit 60af386)
@cshannon cshannon changed the title Limit platform details to a reasonable length Limit WireFormatInfo platform details to a reasonable length Jun 8, 2026
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.

3 participants