[Bug]: Avro 1.12.2 breaks AvroCoder with SecurityException (AVRO-4189)

Đang mở
#41,888 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start with AvroCoder and AvroDatumFactory, then read SdkHarnessOptions#getAvroSerializableClasses and the Avro compatibility tests under sdks/java/extensions/avro. Reproduce with Avro 1.12.2 using a reflective POJO or SpecificRecord; done means non-GenericRecord encoding and decoding work without the SecurityException, with regression coverage for the supported cases.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

avro bug java P2
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
Ngôn ngữ chính
Java
Star
8.7k
Fork
4.8k
Merge trung bình
3 ngày 20 giờ
Pull request đã merge (30 ngày)
446

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/beam

Tất cả issue của apache/beam

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.