Skip to content

Fix use-after-free bug when processing a dynamic Python proto with extensions.#220

Closed
copybara-service[bot] wants to merge 0 commit intomainfrom
cl/895870274
Closed

Fix use-after-free bug when processing a dynamic Python proto with extensions.#220
copybara-service[bot] wants to merge 0 commit intomainfrom
cl/895870274

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service bot commented Apr 7, 2026

Fix use-after-free bug when processing a dynamic Python proto with extensions.

When a dynamic Python proto with extensions is passed through pybind11_protobuf,
the C++ bridge creates a DescriptorPool backed by the Python pool. During
proto parsing on the C++ side, extension lookup calls back into the Python
pool via FindExtensionByNumber. If the intermediate FieldDescriptor wrapper
returned by FindExtensionByNumber is not kept alive while its .file attribute
is accessed and serialized, the UPB runtime may free the wrapper before
DescriptorPoolDatabase::CopyToFileDescriptorProto finishes, leading to a
heap-use-after-free.

This change contains the fix and a regression test that crashes under ASan without
the fix and passes under ASan with the fix.

@copybara-service copybara-service bot force-pushed the cl/895870274 branch 2 times, most recently from c200c74 to 0efaa0e Compare April 7, 2026 14:16
@copybara-service copybara-service bot closed this Apr 7, 2026
@copybara-service copybara-service bot deleted the cl/895870274 branch April 7, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants