Skip to content

CAMEL-24578: Configure Avro ClassSecurityValidator at runtime for camel-avro-rpc - #26026

Merged
davsclaus merged 6 commits into
apache:mainfrom
atiaomar1978-hub:feature/CAMEL-24578-avro-class-security-validator
Sep 2, 2026
Merged

CAMEL-24578: Configure Avro ClassSecurityValidator at runtime for camel-avro-rpc#26026
davsclaus merged 6 commits into
apache:mainfrom
atiaomar1978-hub:feature/CAMEL-24578-avro-class-security-validator

Conversation

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor

Summary

Fixes CAMEL-24578: camel-avro-rpc (and camel-avro) fail with Apache Avro 1.12.2 because ClassSecurityValidator rejects IPC handshake and application model classes unless the SERIALIZABLE_PACKAGES JVM property is set manually.

This PR configures Avro's ClassSecurityValidator at runtime so routes work out of the box:

  • AvroClassSecuritySupport (in camel-avro) maintains an in-memory allowlist and extends the global Avro validator
  • camel-avro-rpc: trusts org.apache.avro.ipc on component init; infers model packages from protocol class, namespace, and schema types
  • camel-avro data format: trusts packages from schema / instance class; trusts marshal graph class at runtime
  • New option serializablePackages on Avro RPC endpoints (and data format @Metadata) for additional trusted packages, annotated security = "insecure:serialization"
  • Tests run without Surefire -Dorg.apache.avro.SERIALIZABLE_PACKAGES=... vmargs (68 RPC tests + unit tests pass)
  • Upgrade guide updated to document automatic configuration and the new option

Review feedback addressed

  • Allowlist stored in private in-memory sets (not a re-readable system property)
  • IPC trust scoped to org.apache.avro.ipc (RPC component only)
  • Wildcard * rejected explicitly
  • @BeforeEach test isolation via resetForTesting()
  • Negative test for classes outside configured protocol packages

Test plan

  • mvn test -pl components/camel-avro,components/camel-avro-rpc/camel-avro-rpc-component -am
  • All 68 camel-avro-rpc tests pass without JVM serializable-packages vmargs
  • New AvroClassSecuritySupportTest and AvroClassSecurityWithoutVmArgsTest

AI-generated PR description by Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Bugbot review

Result: No bugs found.

Bugbot reviewed the branch changes for CAMEL-24578 (Avro 1.12.2 ClassSecurityValidator runtime configuration) focusing on security boundaries, thread safety, setGlobal() usage, and test coverage.

No actionable defects were reported.


AI-generated comment by Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Implementation summary

This PR fixes CAMEL-24578 by configuring Apache Avro 1.12.2 ClassSecurityValidator at runtime for camel-avro-rpc and camel-avro.

Key changes

Area Change
AvroClassSecuritySupport In-memory trusted package/class allowlist; extends Avro global validator via ClassSecurityValidator.composite()
camel-avro-rpc Auto-trusts org.apache.avro.ipc on component init; infers packages from protocol class, namespace, and schema types
camel-avro Trusts schema/instance packages on init; trusts marshal graph class at runtime
New option serializablePackages on RPC endpoint + data format (security = "insecure:serialization")
Tests Removed Surefire SERIALIZABLE_PACKAGES vmargs — 68/68 RPC tests pass without JVM flags
Docs Upgrade guide 4.23 updated

Files touched

  • components/camel-avro/src/main/java/org/apache/camel/avro/support/AvroClassSecuritySupport.java (new)
  • components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroComponent.java
  • components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
  • components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
  • components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java
  • Tests: AvroClassSecuritySupportTest, AvroClassSecurityWithoutVmArgsTest
  • docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc

AI-generated comment by Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Grok code review — findings and resolutions

Grok reviewed the initial implementation and flagged several issues. Below is each finding and how it was addressed in commit 5167d720ad0.

Security / correctness

# Grok finding Resolution
1 Allowlist stored in mutable System.setProperty re-read on every isTrusted() call — any code could widen trust at runtime Fixed. Trusted packages/classes now stored in private in-memory ConcurrentHashMap sets inside AvroClassSecuritySupport
2 setGlobal() clobbers prior validators; state leaks across tests Mitigated. resetForTesting() restores ClassSecurityValidator.DEFAULT; tests use @BeforeEach isolation
3 Data-format serializablePackages DSL example in upgrade guide did not compile Fixed. Upgrade guide now shows valid Java API usage with AvroDataFormat.setSerializablePackages()
4 Marshal without preconfigured schema never trusts graph class Fixed. AvroDataFormat.marshal() calls trustClassName(graph.getClass().getName()) before schema resolution
5 serializablePackages=* silently no-op Fixed. Wildcard rejected with IllegalArgumentException
6 Auto-trust of entire org.apache.avro too broad; applied from data format too Fixed. IPC trust scoped to org.apache.avro.ipc and only invoked from AvroComponent.doInit() (not data format)
7 Missing security = "insecure:serialization" on serializablePackages Fixed. Added to @UriParam and @Metadata

Architecture note (accepted trade-off)

Finding Status
camel-avro-rpccamel-avro dependency to share AvroClassSecuritySupport Accepted. Keeps a single JVM-wide allowlist registry; avoids duplicate static state in two JARs

Test improvements made

  • Added @BeforeEach resetForTesting() for test isolation
  • Added HandshakeRequest IPC trust test in AvroClassSecurityWithoutVmArgsTest
  • Added negative test (untrusted TestPojo outside protocol packages)
  • Added wildcard rejection test
  • Migrated to AssertJ in security tests
  • All 68 existing RPC integration tests pass without Surefire SERIALIZABLE_PACKAGES vmargs

Remaining follow-ups (non-blocking)

  • Walk nested schema namespaces for union/record fields with cross-namespace references (future enhancement)
  • Wire serializablePackages through Camel DSL model/reifier for YAML/XML route config (currently available via Java API and URI params)

AI-generated comment by Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Testing evidence

mvn test -pl components/camel-avro,components/camel-avro-rpc/camel-avro-rpc-component -am

Results:

  • camel-avro: 5 new unit tests in AvroClassSecuritySupportTest — all pass
  • camel-avro-rpc: 68 tests (including 4 new security tests) — all pass
  • Surefire -Dorg.apache.avro.SERIALIZABLE_PACKAGES=... vmargs removed from both module POMs

New test classes:

  • org.apache.camel.avro.support.AvroClassSecuritySupportTest
  • org.apache.camel.component.avro.AvroClassSecurityWithoutVmArgsTest

AI-generated comment by Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub
atiaomar1978-hub marked this pull request as ready for review September 2, 2026 01:09
@davsclaus

Copy link
Copy Markdown
Contributor

the data format needs to add thee new option in the core model as well, and then also to regen many files because of that

@davsclaus davsclaus 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.

Reviewed against the project's rules/conventions (this does not replace CodeRabbit/Sourcery/SonarCloud or a dedicated security review). I built and ran camel-avro and camel-avro-rpc-component in a worktree — both compile and all tests (existing + new) pass. I also checked CAMEL-24578 and the prior Avro-1.12.2-bump commit: this is legitimate follow-up work on an intentional stop-gap, not a revert of prior design.

1. Generated metadata is out of sync (will fail CI's uncommitted-changes check). I regenerated the downstream artifacts locally and got real diffs the PR doesn't include:

  • catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json — missing the new serializablePackages entry.
  • dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java — missing the fluent serializablePackages(...) builder method.
  • dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java — same.

These three need mvn install (or the project's catalog/endpoint-dsl/component-dsl regen step) run and the results committed, in that order.

2. The new option is missing from the camel-avro data-format model, so it isn't usable from XML/YAML/fluent-Java DSL. org.apache.camel.model.dataformat.AvroDataFormat in core/camel-core-model (the @XmlRootElement model class backing <avro/> in XML DSL, YAML DSL, and the DataFormatDefinition fluent builder) was not updated to add a serializablePackages field/attribute alongside instanceClassName, schema, etc. As it stands, serializablePackages on the camel-avro data format is only reachable by constructing org.apache.camel.dataformat.avro.AvroDataFormat directly in Java and calling the setter — not from .marshal().avro(...)'s model-backed configuration, XML routes, or YAML routes. This needs the field added to the model class (with @XmlAttribute/@Metadata), its Builder counterpart, and the associated generated resources (core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/avro.json, YAML DSL deserializer, XML schema) regenerated.

3. (Positive, no action needed) The camel-avro-rpc component-level configuration already works correctly for serializablePackages — it follows the existing AvroConfiguration/getOrCreateConfiguration() pattern shared by reflectionProtocol, singleParameter, etc., so it's already settable once on the component (e.g. camel.component.avro.serializable-packages=...) and inherited by every endpoint created from it, consistent with sibling options. Good reuse of the existing pattern.

4. Security design concern (see inline comments). AvroClassSecuritySupport is a JVM-wide static singleton shared by every CamelContext/route/data-format instance, and AvroDataFormat.marshal() unconditionally trusts the outgoing body's runtime class (and, via prefix matching, its whole package) forever, with no way to revoke in production. That's a meaningful weakening of the exact protection Avro 1.12.2's ClassSecurityValidator introduced, and it can leak trust across otherwise-unrelated routes/contexts in the same JVM. Given this touches the deserialization-security boundary, I'd like a security-minded committer to take a second look at that design before merge, per the project's security review checklist.

5. (Minor) Test convention. Both camel-avro and camel-avro-rpc-component add assertj-core purely for the two new test classes even though every existing test in both modules uses JUnit 5 assertions — a style outlier plus an unjustified new dependency (see inline comments). There's also an avoidable per-call allocation in the trust-check hot path (see inline comment).

None of this is a knock on the effort — the underlying problem (Avro 1.12.2 breaking camel-avro/camel-avro-rpc without a trust config) is real and the fix direction (programmatic ClassSecurityValidator configuration) matches what CAMEL-24578 asked for. It needs the generated-metadata sync, the data-format model gap, and the trust-scoping/lifetime question resolved before this changes production security posture and ships a complete, DSL-usable option.

Separately: CI hasn't run on this PR yet (gh pr checks reports no checks) — worth confirming it's green (likely needs workflow approval for this contributor) independent of the above.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Comment thread components/camel-avro/pom.xml Outdated
Comment thread components/camel-avro-rpc/camel-avro-rpc-component/pom.xml Outdated
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Review feedback addressed — commit e7f7c32bd79 (base: main)

AI-generated comment by Cursor Agent on behalf of @atiaomar1978-hub

All actionable items from @davsclaus's CHANGES_REQUESTED review are addressed in the latest commit on this PR (targeting main).

Fixes applied

# Review item Resolution
1 Generated metadata out of sync (catalog, endpoint DSL, component DSL) Regenerated and committed — serializablePackages in avro.json, AvroEndpointBuilderFactory, AvroComponentBuilderFactory
2 serializablePackages missing from core AvroDataFormat model Added @XmlAttribute + @Metadata, Builder, AvroDataFormatReifier wiring; regen includes YAML deserializer + XML schema
3 setGlobal() clobbers custom validators Captures existing ClassSecurityValidator.getGlobal() on first trust and composes; test shouldPreserveExistingGlobalValidator
4 Per-validate TreeSet allocation Cached normalizedPackagePrefixes, rebuilt only on allowlist change
5 Unconditional marshal-time trust Trust graph class only when actualSchema == null
6 AssertJ outlier in test modules JUnit 5 assertions; removed assertj-core from both POMs

Tests (against main merge-base)

mvn test -pl components/camel-avro,components/camel-avro-rpc/camel-avro-rpc-component -am

All tests pass without Surefire SERIALIZABLE_PACKAGES vmargs.

Ready for re-review.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

✅ Generated files are up to date

An earlier CI run reported uncommitted generated changes; the latest run no longer does.

@Croway Croway 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.

Thanks for tackling this, it's a much better experience than requiring -Dorg.apache.avro.SERIALIZABLE_PACKAGES. I ran the trust logic against avro-1.12.2 with a few probes and found six issues worth addressing before merge (three are security-relevant since the allowlist is JVM-global and irrevocable, three are functional regressions vs. main). Details inline.

Claude Code on behalf of Croway

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-avro
  • components/camel-avro-rpc/camel-avro-rpc-component
  • components/camel-avro
  • components/camel-jackson-avro
  • components/camel-jackson3-avro
  • core/camel-core-model
  • core/camel-core-reifier
  • core/camel-java-io
  • core/camel-util
  • core/camel-xml-io
  • core/camel-yaml-io
  • docs
  • dsl/camel-componentdsl
  • dsl/camel-endpointdsl
  • dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers
  • dsl/camel-yaml-dsl/camel-yaml-dsl

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


🔬 Scalpel shadow comparison — Scalpel: 577 tested, 21 compile-only — current: 571 all tested

Maveniverse Scalpel detected 598 affected modules (current approach: 571).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 577 modules (16 direct + 561 downstream), skip tests for 21 (generated code, meta-modules)

Modules Scalpel would test (577)
  • archetypes
  • camel-a2a
  • camel-activemq
  • camel-activemq6
  • camel-ai-observability
  • camel-ai-observability-api
  • camel-ai-parent
  • camel-ai-resource
  • camel-ai-tool
  • camel-alibaba-common
  • camel-alibaba-eventbridge
  • camel-alibaba-fc
  • camel-alibaba-kms
  • camel-alibaba-mns
  • camel-alibaba-oss
  • camel-alibaba-ots
  • camel-alibaba-parent
  • camel-alibaba-sls
  • camel-alibaba-sms
  • camel-amqp
  • camel-api
  • camel-api-component-maven-plugin
  • camel-arangodb
  • camel-archetype-api-component
  • camel-archetype-component
  • camel-archetype-dataformat
  • camel-archetype-java
  • camel-archetype-main
  • camel-as2
  • camel-as2-api
  • camel-as2-parent
  • camel-asn1
  • camel-asterisk
  • camel-atmosphere-websocket
  • camel-atom
  • camel-attachments
  • camel-avro
  • camel-avro-rpc
  • camel-avro-rpc-jetty
  • camel-avro-rpc-parent
  • camel-avro-rpc-spi
  • camel-aws-bedrock
  • camel-aws-cloudtrail
  • camel-aws-common
  • camel-aws-config
  • camel-aws-parameter-store
  • camel-aws-parent
  • camel-aws-secrets-manager
  • camel-aws-security-hub
  • camel-aws2-athena
  • camel-aws2-comprehend
  • camel-aws2-cw
  • camel-aws2-ddb
  • camel-aws2-ec2
  • camel-aws2-ecs
  • camel-aws2-eks
  • camel-aws2-eventbridge
  • camel-aws2-iam
  • camel-aws2-kinesis
  • camel-aws2-kms
  • camel-aws2-lambda
  • camel-aws2-mq
  • camel-aws2-msk
  • camel-aws2-polly
  • camel-aws2-redshift
  • camel-aws2-rekognition
  • camel-aws2-s3
  • camel-aws2-s3-vectors
  • camel-aws2-ses
  • camel-aws2-sns
  • camel-aws2-sqs
  • camel-aws2-step-functions
  • camel-aws2-sts
  • camel-aws2-textract
  • camel-aws2-timestream
  • camel-aws2-transcribe
  • camel-aws2-translate
  • camel-azure-common
  • camel-azure-cosmosdb
  • camel-azure-eventgrid
  • camel-azure-eventhubs
  • camel-azure-files
  • camel-azure-functions
  • camel-azure-key-vault
  • camel-azure-parent
  • camel-azure-schema-registry
  • camel-azure-servicebus
  • camel-azure-storage-blob
  • camel-azure-storage-datalake
  • camel-azure-storage-queue
  • camel-barcode
  • camel-base
  • camel-base-engine
  • camel-base64
  • camel-bean
  • camel-bean-validator
  • camel-beanio
  • camel-bindy
  • camel-bonita
  • camel-box
  • camel-box-api
  • camel-box-parent
  • camel-braintree
  • camel-browse
  • camel-caffeine
  • camel-camunda
  • camel-cassandraql
  • camel-catalog
  • camel-catalog-common
  • camel-cbor
  • camel-chatscript
  • camel-chunk
  • camel-cli-connector
  • camel-cli-debug
  • camel-clickhouse
  • camel-clickup
  • camel-cloudevents
  • camel-cluster
  • camel-cm-sms
  • camel-coap
  • camel-cometd
  • camel-componentdsl
  • camel-console
  • camel-consul
  • camel-controlbus
  • camel-core
  • camel-core-all
  • camel-core-catalog
  • camel-core-engine
  • camel-core-languages
  • camel-core-model
  • camel-core-processor
  • camel-core-reifier
  • camel-core-xml
  • camel-couchbase
  • camel-couchdb
  • camel-cron
  • camel-crypto
  • camel-crypto-pgp
  • camel-csv
  • camel-cxf-common
  • camel-cxf-parent
  • camel-cxf-rest
  • camel-cxf-soap
  • camel-cxf-spring-common
  • camel-cxf-spring-rest
  • camel-cxf-spring-soap
  • camel-cxf-spring-transport
  • camel-cxf-transport
  • camel-cyberark-vault
  • camel-dapr
  • camel-dataformat
  • camel-dataset
  • camel-datasonnet
  • camel-dataweave
  • camel-debezium-common
  • camel-debezium-common-parent
  • camel-debezium-db2
  • camel-debezium-maven-plugin
  • camel-debezium-mongodb
  • camel-debezium-mysql
  • camel-debezium-oracle
  • camel-debezium-parent
  • camel-debezium-postgres
  • camel-debezium-sqlserver
  • camel-debug
  • camel-dependencies
  • camel-dfdl
  • camel-dhis2
  • camel-dhis2-api
  • camel-dhis2-parent
  • camel-diagram
  • camel-direct
  • camel-disruptor
  • camel-djl
  • camel-dns
  • camel-docker
  • camel-docling
  • camel-drill
  • camel-dropbox
  • camel-dsl-modeline
  • camel-dsl-support
  • camel-duckdb
  • camel-dynamic-router
  • camel-ehcache
  • camel-eip-documentation-enricher-maven-plugin
  • camel-elasticsearch
  • camel-elasticsearch-rest-client
  • camel-endpointdsl
  • camel-event
  • camel-exec
  • camel-fastjson
  • camel-fhir
  • camel-fhir-api
  • camel-fhir-parent
  • camel-file
  • camel-file-watch
  • camel-flatpack
  • camel-flink
  • camel-flowable
  • camel-fop
  • camel-fory
  • camel-freemarker
  • camel-ftp
  • camel-ftp-common
  • camel-geocoder
  • camel-git
  • camel-github2
  • camel-google-bigquery
  • camel-google-calendar
  • camel-google-common
  • camel-google-drive
  • camel-google-firestore
  • camel-google-functions
  • camel-google-mail
  • camel-google-parent
  • camel-google-pubsub
  • camel-google-secret-manager
  • camel-google-sheets
  • camel-google-speech-to-text
  • camel-google-storage
  • camel-google-text-to-speech
  • camel-google-vertexai
  • camel-google-vision
  • camel-graphql
  • camel-grok
  • camel-groovy
  • camel-grpc
  • camel-gson
  • camel-hashicorp-vault
  • camel-hazelcast
  • camel-health
  • camel-hivemq
  • camel-hl7
  • camel-http
  • camel-http-base
  • camel-http-common
  • camel-huawei-parent
  • camel-huaweicloud-common
  • camel-huaweicloud-dms
  • camel-huaweicloud-frs
  • camel-huaweicloud-functiongraph
  • camel-huaweicloud-iam
  • camel-huaweicloud-imagerecognition
  • camel-huaweicloud-obs
  • camel-huaweicloud-smn
  • camel-huggingface
  • camel-ibm-cos
  • camel-ibm-parent
  • camel-ibm-secrets-manager
  • camel-ibm-watson-discovery
  • camel-ibm-watson-language
  • camel-ibm-watson-speech-to-text
  • camel-ibm-watson-text-to-speech
  • camel-ibm-watsonx-ai
  • camel-ibm-watsonx-data
  • camel-ical
  • camel-iggy
  • camel-ignite
  • camel-infinispan
  • camel-infinispan-common
  • camel-infinispan-embedded
  • camel-infinispan-parent
  • camel-influxdb
  • camel-influxdb2
  • camel-iso8583
  • camel-jackson
  • camel-jackson-avro
  • camel-jackson-protobuf
  • camel-jackson3
  • camel-jackson3-avro
  • camel-jackson3-protobuf
  • camel-jackson3xml
  • camel-jacksonxml
  • camel-jactl
  • camel-jandex
  • camel-jasypt
  • camel-java-io
  • camel-java-joor-dsl
  • camel-javascript
  • camel-jaxb
  • camel-jbang-console
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jcache
  • camel-jcr
  • camel-jdbc
  • camel-jetty
  • camel-jetty-common
  • camel-jfr
  • camel-jgroups
  • camel-jgroups-raft
  • camel-jira
  • camel-jms
  • camel-jmx
  • camel-jolt
  • camel-jooq
  • camel-joor
  • camel-jpa
  • camel-jq
  • camel-jsch
  • camel-jslt
  • camel-json-validator
  • camel-jsonapi
  • camel-jsonata
  • camel-jsonb
  • camel-jsonpath
  • camel-jsoup
  • camel-jt400
  • camel-jta
  • camel-jte
  • camel-kafka
  • camel-kamelet
  • camel-kamelet-main-support
  • camel-keycloak
  • camel-knative
  • camel-knative-api
  • camel-knative-http
  • camel-knative-parent
  • camel-kserve
  • camel-kubernetes
  • camel-kudu
  • camel-langchain4j-agent
  • camel-langchain4j-agent-api
  • camel-langchain4j-chat
  • camel-langchain4j-core
  • camel-langchain4j-embeddings
  • camel-langchain4j-embeddingstore
  • camel-langchain4j-embeddingstore-api
  • camel-langchain4j-tokenizer
  • camel-langchain4j-web-search
  • camel-language
  • camel-launcher-container
  • camel-ldap
  • camel-ldif
  • camel-log
  • camel-lra
  • camel-lucene
  • camel-lumberjack
  • camel-lzf
  • camel-mail
  • camel-mail-microsoft-oauth
  • camel-main
  • camel-management
  • camel-management-api
  • camel-mapstruct
  • camel-master
  • camel-maven-plugin
  • camel-mcp-server
  • camel-mcp-server-api
  • camel-mdc
  • camel-metrics
  • camel-micrometer
  • camel-micrometer-observability
  • camel-micrometer-prometheus
  • camel-microprofile-config
  • camel-microprofile-fault-tolerance
  • camel-microprofile-health
  • camel-microprofile-parent
  • camel-milo
  • camel-milvus
  • camel-mina
  • camel-mina-sftp
  • camel-minio
  • camel-mllp
  • camel-mock
  • camel-mongodb
  • camel-mongodb-gridfs
  • camel-mustache
  • camel-mvel
  • camel-mybatis
  • camel-nats
  • camel-neo4j
  • camel-netty
  • camel-netty-http
  • camel-oaipmh
  • camel-oauth
  • camel-observability-services
  • camel-observation
  • camel-ocsf
  • camel-ognl
  • camel-olingo2
  • camel-olingo2-api
  • camel-olingo2-parent
  • camel-olingo4
  • camel-olingo4-api
  • camel-olingo4-parent
  • camel-once
  • camel-openai
  • camel-openapi-java
  • camel-openapi-rest-dsl-generator
  • camel-openapi-validator
  • camel-opensearch
  • camel-openstack
  • camel-opentelemetry
  • camel-opentelemetry-metrics
  • camel-opentelemetry2
  • camel-optaplanner
  • camel-paho
  • camel-paho-mqtt5
  • camel-parquet-avro
  • camel-pdf
  • camel-pg-replication-slot
  • camel-pgevent
  • camel-pgvector
  • camel-pinecone
  • camel-platform-http
  • camel-platform-http-jolokia
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-plc4x
  • camel-pqc
  • camel-printer
  • camel-protobuf
  • camel-pubnub
  • camel-pulsar
  • camel-python
  • camel-python3
  • camel-qdrant
  • camel-quartz
  • camel-quickfix
  • camel-quickjs
  • camel-reactive-streams
  • camel-reactor
  • camel-redis
  • camel-ref
  • camel-resilience4j
  • camel-resilience4j-micrometer
  • camel-resourceresolver-github
  • camel-rest
  • camel-rest-openapi
  • camel-rest-postman
  • camel-restdsl-openapi-plugin
  • camel-robotframework
  • camel-rocketmq
  • camel-rss
  • camel-rxjava
  • camel-saga
  • camel-salesforce
  • camel-salesforce-codegen
  • camel-salesforce-maven-plugin
  • camel-salesforce-parent
  • camel-sap-netweaver
  • camel-saxon
  • camel-scheduler
  • camel-schematron
  • camel-seda
  • camel-servicenow
  • camel-servicenow-maven-plugin
  • camel-servicenow-parent
  • camel-servlet
  • camel-shell
  • camel-shiro
  • camel-sjms
  • camel-sjms2
  • camel-slack
  • camel-smb
  • camel-smooks
  • camel-smpp
  • camel-snakeyaml
  • camel-snmp
  • camel-soap
  • camel-solr
  • camel-spiffe
  • camel-splunk-hec
  • camel-spring
  • camel-spring-ai-chat
  • camel-spring-ai-embeddings
  • camel-spring-ai-image
  • camel-spring-ai-parent
  • camel-spring-ai-vector-store
  • camel-spring-batch
  • camel-spring-cloud-config
  • camel-spring-jdbc
  • camel-spring-ldap
  • camel-spring-main
  • camel-spring-parent
  • camel-spring-rabbitmq
  • camel-spring-redis
  • camel-spring-security
  • camel-spring-ws
  • camel-spring-xml
  • camel-sql
  • camel-ssh
  • camel-state-store
  • camel-state-store-parent
  • camel-stax
  • camel-stitch
  • camel-stream
  • camel-streamcaching-test
  • camel-stringtemplate
  • camel-stripe
  • camel-stub
  • camel-support
  • camel-swift
  • camel-syslog
  • camel-tahu
  • camel-tarfile
  • camel-telegram
  • camel-telemetry
  • camel-telemetry-dev
  • camel-tensorflow-serving
  • camel-test-infra-all
  • camel-test-infra-artemis
  • camel-test-infra-cli
  • camel-test-infra-core
  • camel-test-infra-jetty
  • camel-test-infra-qdrant
  • camel-test-infra-smb
  • camel-test-junit5
  • camel-test-junit6
  • camel-test-main-junit5
  • camel-test-main-junit6
  • camel-test-parent
  • camel-test-spring-junit5
  • camel-test-spring-junit6
  • camel-thrift
  • camel-thymeleaf
  • camel-tika
  • camel-timer
  • camel-tooling-maven
  • camel-toon
  • camel-tracing
  • camel-twilio
  • camel-twitter
  • camel-ubl
  • camel-undertow
  • camel-undertow-spring-security
  • camel-univocity-parsers
  • camel-util
  • camel-validator
  • camel-velocity
  • camel-vertx
  • camel-vertx-common
  • camel-vertx-http
  • camel-vertx-parent
  • camel-vertx-websocket
  • camel-wal
  • camel-wasm
  • camel-weather
  • camel-weaviate
  • camel-web3j
  • camel-webhook
  • camel-whatsapp
  • camel-wordpress
  • camel-workday
  • camel-xchange
  • camel-xj
  • camel-xml-io
  • camel-xml-io-dsl
  • camel-xml-jaxb
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring
  • camel-xml-jaxp
  • camel-xmlsecurity
  • camel-xmpp
  • camel-xpath
  • camel-xslt
  • camel-xslt-saxon
  • camel-yaml-dsl
  • camel-yaml-dsl-common
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • camel-yaml-io
  • camel-zendesk
  • camel-zip-deflater
  • camel-zipfile
  • camel-zookeeper
  • camel-zookeeper-master
  • components
  • docs
  • sync-properties-maven-plugin
Modules with tests skipped (21)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl-maven-plugin
  • coverage
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

Build reactor — dependencies compiled but only changed modules were tested (16 modules)
  • Camel :: Avro
  • Camel :: Avro RPC
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Component DSL
  • Camel :: Core Model
  • Camel :: Core Reifier
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Jackson 3 Avro
  • Camel :: Jackson Avro
  • Camel :: Java DSL IO
  • Camel :: Util
  • Camel :: XML IO
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML IO

⚙️ View full build and test results

@gnodet gnodet 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.

Sound approach to configuring Avro's ClassSecurityValidator at runtime, replacing the JVM-property workaround. The auto-inference of trusted packages from schema/protocol configuration is well-designed. Security annotations and wildcard rejection are correct. Thread safety is properly handled.

A few observations:

Module coupling (medium): The new compile dependency from camel-avro-rpc-component on camel-avro (the data format module) couples two previously independent modules solely to share AvroClassSecuritySupport. Consider placing the utility in a shared location such as camel-avro-rpc-spi (which already exists) or a minimal camel-avro-support module.

FQCN usage (low): Line 158 of AvroClassSecuritySupport.java uses java.util.stream.Collectors and java.util.LinkedHashSet inline instead of import statements, violating the project convention. The build's OpenRewrite step may auto-fix this.

Catalog metadata leak (low): serializablePackages appears in catalog metadata for avroJackson and avroJackson3, but the reifier only passes it for ApacheAvro. Users of Jackson-based Avro data formats would find it silently ignored. Adding serializablePackages to the excludeProperties of JacksonAvroDataFormat's @Metadata annotation would fix the catalog.

Redundant call (low): ensureAvroIpcPackagesTrusted() is called in both AvroComponent.doInit() and AvroEndpoint.configureClassSecurity(). The endpoint call is always redundant since the component initializes first. Harmless but unnecessary.

📋 PR Metadata

Aspect Current Suggested
Labels components, core, catalog, docs, dsl + security
Milestone (none) 4.23.0

🤖 This review was generated by Claude Code on behalf of Guillaume Nodet

@davsclaus

Copy link
Copy Markdown
Contributor

@atiaomar1978-hub can you look at @gnodet comments there are valid and would be good to correct before merging

@cursor
cursor Bot force-pushed the feature/CAMEL-24578-avro-class-security-validator branch from 515450f to 69f78c2 Compare September 2, 2026 15:35
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Croway + davsclaus review feedback addressed — rebased on main

AI-generated comment by Cursor Agent on behalf of @atiaomar1978-hub

Latest commits rebase this PR onto current main (69f78c23799) and address all six inline findings from @Croway plus remaining items from @davsclaus / @gnodet.

Croway findings — fixed

# Issue Fix
1 JDK packages leak via reflection protocol error types trustProtocol() skips type.isError() schemas; isSystemPackage() filters java.*/javax.*/jdk.*/sun.*
2 Schema-less marshal trusts body package before validation Marshal now calls loadSchema() first; only then trustClassNameOnly() (exact class, no package)
3 Later setGlobal() silently discarded refreshGlobal() re-adopts getGlobal() when it differs from installedGlobal
4 Non-named root schemas fail at startup trustSchema() walks graph; ARRAY/UNION/MAP roots no longer call getNamespace()
5 Prefix matching shadows parent packages Iterate all normalized prefixes instead of single lower() lookup
6 Nested named types not trusted on unmarshal trustSchema() / trustProtocol() walk fields, array items, map values, union branches

Other review items

  • Removed redundant ensureAvroIpcPackagesTrusted() from endpoint (component init only)
  • Excluded serializablePackages from Jackson Avro catalog metadata (avroJackson / avroJackson3)
  • Expanded unit tests (prefix matching, global validator preservation, non-named schemas, JDK filtering)

Tests

mvn test -pl components/camel-avro,components/camel-avro-rpc/camel-avro-rpc-component

All unit tests pass without Surefire SERIALIZABLE_PACKAGES vmargs.

Ready for re-review.

@davsclaus

Copy link
Copy Markdown
Contributor

Did we fix this

Catalog metadata leak (low): serializablePackages appears in catalog metadata for avroJackson and avroJackson3, but the reifier only passes it for ApacheAvro. Users of Jackson-based Avro data formats would find it silently ignored. Adding serializablePackages to the excludeProperties of JacksonAvroDataFormat's @metadata annotation would fix the catalog.

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

@davsclaus will double confirm.

@davsclaus

Copy link
Copy Markdown
Contributor

Confirmed fixed ✅ — verified against the branch head (69f78c23799):

  • excludeProperties now includes serializablePackages in both JacksonAvroDataFormat classes (camel-jackson-avro and camel-jackson3-avro).
  • The generated catalog dataformats/avroJackson.json and both component avroJackson.json files contain no serializablePackages entry (the avro/ApacheAvro dataformat correctly still carries it).
  • This matches the reifier, which only passes serializablePackages (alongside instanceClassName/schema) when library == ApacheAvro — so excluding it from the Jackson variants is the correct, consistent treatment.

Generated output is consistent with the source, so the catalog metadata leak is resolved.

Reviewed by Claude Code on behalf of @davsclaus

cursoragent and others added 6 commits September 2, 2026 15:59
Configure Apache Avro ClassSecurityValidator automatically for
camel-avro-rpc and camel-avro so Avro 1.12.2 works without requiring
the SERIALIZABLE_PACKAGES JVM property. Trust org.apache.avro IPC
packages on component init and infer model packages from configured
protocol or schema classes. Add serializablePackages option for extra
packages, tests without surefire vmargs, and upgrade guide updates.

Co-authored-by: Cursor Agent <noreply@cursor.com>
Store trusted packages in memory instead of a mutable system property,
scope IPC trust to org.apache.avro.ipc, mark serializablePackages as
insecure:serialization, trust marshal graph classes at runtime, and
expand tests with AssertJ and HandshakeRequest coverage.

Co-authored-by: Cursor Agent <noreply@cursor.com>
Add serializablePackages to core AvroDataFormat model and regenerate
catalog, endpoint/component DSL, YAML deserializer, and XML schema.
Preserve pre-existing ClassSecurityValidator on first trust, cache
normalized package prefixes, scope marshal-time trust to dynamic schema
paths, migrate security tests to JUnit assertions, and remove assertj
test dependencies.

Co-authored-by: Cursor Agent <noreply@cursor.com>
Walk schema and protocol graphs for trusted types, skip JDK/error
schemas, fix prefix matching, preserve externally installed global
validators, trust marshal body only after GenericContainer validation
using exact class names, and exclude serializablePackages from Jackson
Avro catalog metadata.

Co-authored-by: Cursor Agent <noreply@cursor.com>
…update

Co-authored-by: Cursor Agent <noreply@cursor.com>
@cursor
cursor Bot force-pushed the feature/CAMEL-24578-avro-class-security-validator branch from 69f78c2 to 2af134d Compare September 2, 2026 16:10
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Rebased onto main + review threads addressed — 2af134d

AI-generated comment by Cursor Agent on behalf of @atiaomar1978-hub

Rebase

Branch rebased onto latest upstream main (4bb91e7) and force-pushed. HEAD: 2af134d1c7d5600396fc6437d55d29ce8f794751.

Review status

Reviewer Status
@davsclaus All inline threads replied — metadata regen, core model option, global validator composition, cached prefixes, JUnit assertions
@Croway All 6 security/functional threads addressed in 9440ae54 (schema walk, system-package filter, exact-class marshal trust, prefix iteration, external validator preservation)
@gnodet Jackson Avro catalog leak fixed via excludeProperties; FQCN imports cleaned; redundant endpoint IPC call removed (component-only init)

Tests

mvn test -pl components/camel-avro,components/camel-avro-rpc/camel-avro-rpc-component -am

All pass without -Dorg.apache.avro.SERIALIZABLE_PACKAGES vmargs.

Ready for merge pending CI.

@davsclaus davsclaus added this to the 4.23.0 milestone Sep 2, 2026
@davsclaus davsclaus added the enhancement New feature or request label Sep 2, 2026
@davsclaus
davsclaus merged commit d5160fd into apache:main Sep 2, 2026
6 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.

5 participants