Skip to content

bindings/blst.swg: don't release Python str buffer before the call - #305

Closed
arib06 wants to merge 1 commit into
supranational:masterfrom
arib06:swig-python-str-uaf
Closed

arib06 wants to merge 1 commit into
supranational:masterfrom
arib06:swig-python-str-uaf

Conversation

@arib06

@arib06 arib06 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

the str branch of the C++ blst::bytes_t Python typemap calls Py_DECREF on the PyUnicode_AsUTF8String temporary right after taking a pointer into it, so the wrapped method (P{1,2}.hash_to, core_verify, Pairing.aggregate, SecretKey.keygen, ...) reads freed memory and freearg then releases the object a second time; hashing str messages in a loop against their .encode() form segfaults or aborts the interpreter on the current tree, so the early release is dropped and run.me now checks str/bytes agreement.

The C++ blst::bytes_t typemap decrements the reference to the UTF-8
copy of a 'str' argument right after taking a pointer into it, so the
wrapped method reads freed memory and the freearg typemap releases the
object a second time. Leave the release to freearg.
@dot-asm dot-asm closed this in a7493a8 Oct 28, 2026
@dot-asm

dot-asm commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Oops! I've removed one, but missed this one. Thanks!

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.

2 participants