Skip to content

Remove "java.lang" package as a default allowed serializable package#2026

Merged
cshannon merged 1 commit into
apache:mainfrom
cshannon:serializable-classes-hardening
May 20, 2026
Merged

Remove "java.lang" package as a default allowed serializable package#2026
cshannon merged 1 commit into
apache:mainfrom
cshannon:serializable-classes-hardening

Conversation

@cshannon
Copy link
Copy Markdown
Contributor

Many classes in the java.lang package should not ever need to be serialized so this commit removes the default package and instead includes an allow list of classes that are ok to serialize that are part of the package. Users have the option to restore the previous behavior by appending "java.lang" back to the serialized packages property if desired.

The main goal of this is to restrict the allowed list to help prevent any future issues that could be uncovered by allowing unnecessary types to be serialized.

Many classes in the java.lang package should not ever need to be
serialized so this commit removes the default package and instead
includes an allow list of classes that are ok to serialize that are
part of the package. Users have the option to restore the previous
behavior by appending "java.lang" back to the serialized packages
property if desired.
@cshannon cshannon requested review from jbonofre and mattrpav May 19, 2026 20:53
Copy link
Copy Markdown
Contributor

@mattrpav mattrpav left a comment

Choose a reason for hiding this comment

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

LGTM


private void checkSecurity(Class clazz) throws ClassNotFoundException {
if (trustAllPackages() || clazz.isPrimitive()) {
if (trustAllPackages() || clazz.isPrimitive() || ALLOWED_JDK_TYPES.contains(clazz)) {
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 is a good change to permanently support these core types

@cshannon cshannon merged commit e9ed448 into apache:main May 20, 2026
27 of 30 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Apache ActiveMQ v6.3.0 May 20, 2026
cshannon added a commit to cshannon/activemq that referenced this pull request May 20, 2026
…pache#2026)

Many classes in the java.lang package should not ever need to be
serialized so this commit removes the default package and instead
includes an allow list of classes that are ok to serialize that are
part of the package. Users have the option to restore the previous
behavior by appending "java.lang" back to the serialized packages
property if desired.

(cherry picked from commit e9ed448)
cshannon added a commit to cshannon/activemq that referenced this pull request May 20, 2026
…pache#2026)

Many classes in the java.lang package should not ever need to be
serialized so this commit removes the default package and instead
includes an allow list of classes that are ok to serialize that are
part of the package. Users have the option to restore the previous
behavior by appending "java.lang" back to the serialized packages
property if desired.

(cherry picked from commit e9ed448)
cshannon added a commit that referenced this pull request May 20, 2026
…2026) (#2027)

Many classes in the java.lang package should not ever need to be
serialized so this commit removes the default package and instead
includes an allow list of classes that are ok to serialize that are
part of the package. Users have the option to restore the previous
behavior by appending "java.lang" back to the serialized packages
property if desired.

(cherry picked from commit e9ed448)
cshannon added a commit that referenced this pull request May 20, 2026
…2026) (#2028)

Many classes in the java.lang package should not ever need to be
serialized so this commit removes the default package and instead
includes an allow list of classes that are ok to serialize that are
part of the package. Users have the option to restore the previous
behavior by appending "java.lang" back to the serialized packages
property if desired.

(cherry picked from commit e9ed448)
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