Repository navigation
Description
What happened?
Apache Avro 1.12.2 (AVRO-4189
) adds ClassSecurityValidator.validate(c) to every ClassUtils.forName() call, trusting only a couple of core JDK classes by default.
This breaks Beam's AvroCoder and AvroDatumFactory for all non-GenericRecord types—both reflective POJOs (@defaultcoder(AvroCoder.class) / AvroCoder.of(MyPojo.class), failing on encode() and decode()) and SpecificRecords (failing on SpecificDatumReader construction)—including built-in Beam types (KafkaCheckpointMark, Spanner Change Streams models, and Beam examples like AutoComplete and TrafficMaxLaneFlow):
Caused by: java.lang.SecurityException: Forbidden org.apache.beam.examples.complete.TrafficMaxLaneFlow$LaneInfo! This class is not trusted to be included in Avro schemas.
at org.apache.avro.util.ClassSecurityValidator.validate(ClassSecurityValidator.java:60)
at org.apache.avro.util.ClassUtils.forName(ClassUtils.java:99)
at org.apache.avro.specific.SpecificData.getClass(SpecificData.java:391)
at org.apache.avro.reflect.ReflectData.populateEncoderCache(ReflectData.java:1069)
at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:166)
at org.apache.beam.sdk.extensions.avro.coders.AvroCoder.encode(AvroCoder.java:476)
SdkHarnessOptions#getAvroSerializableClasses (-Dorg.apache.avro.SERIALIZABLE_CLASSES) only defaults to 6 JDK types and cannot practically list every user POJO, nested/collection type (java.util.List), and internal Beam IO class.
Suggested Fix
-
Auto-allowlist declared AvroCoder / AvroDatumFactory type graphs (details pending. probably would need some mechanism of coder registry / JvmInitializer)
-
Add --avroSerializablePackages to SdkHarnessOptions / sdks/java/container/boot.go as an escape hatch for dynamic/polymorphic subtypes.
-
Add Avro 1.12.2 test coverage in sdks/java/extensions/avro.
We already have avro compat test targets. Consider add this new version.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
- Component: Python SDK
- Component: Java SDK
- Component: Go SDK
- Component: Typescript SDK
- Component: IO connector
- Component: Beam YAML
- Component: Beam examples
- Component: Beam playground
- Component: Beam katas
- Component: Website
- Component: Infrastructure
- Component: Spark Runner
- Component: Flink Runner
- Component: Prism Runner
- Component: Hazelcast Jet Runner
- Component: Google Cloud Dataflow Runner
Activity
sakshammalik260-cse commentedon Dec 3, 2026
.take-issue
sakshammalik260-cse commentedon Dec 3, 2026
Hi @Abacn, I've reproduced the issue with Avro 1.12.2, resulting in 32 test failures.
I'm looking at automatic registration of declared types while preserving existing security policies and compatibility with older Avro versions.
Should automatic registration be limited to Avro's default security policy, leaving custom predicates untouched?
I'd appreciate your thoughts before proceeding with the implementation.
sakshammalik260-cse commentedon Dec 5, 2026
Hi @Abacn, a quick progress update:
I've implemented the Avro 1.12.2 compatibility test target and the
avroSerializablePackagesoption. All 199 tests pass on each existing Avro compatibility version, while 61 failures remain on 1.12.2.During automatic type-graph registration experiments, I found that Avro's global Boolean trust predicate cannot distinguish an explicit denial from an unregistered class. Predicate composition can therefore override custom restrictions, and conditional replacement introduces a potential race with concurrent policy updates.
Would a default-only registration mechanism during controlled JVM initialization be an acceptable approach, or should we pursue a supported policy-extension API in Avro itself?
I'd appreciate your guidance before proceeding with the remaining implementation.
sakshammalik260-cse commentedon Dec 5, 2026
.free-issue