Bug 2150967 - memory safety violation
Summary: memory safety violation
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: python-zstd
Version: 37
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2169048
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-12-05 17:58 UTC by Alexander Sosedkin
Modified: 2023-12-06 11:38 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-12-06 11:38:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
valgrind log obtained on Fedora 37 (124.28 KB, text/plain)
2022-12-05 18:00 UTC, Alexander Sosedkin
no flags Details

Description Alexander Sosedkin 2022-12-05 17:58:46 UTC
Description of problem:
compressing an empty bytestring violates memory safety

Version-Release number of selected component:
  * python3-zstd-1.4.5.1-6.fc36.x86_64
  * python3-zstd-1.4.5.1-8.fc37.x86_64

How reproducible: reliably

Steps to Reproduce:
1. python3 -c "import zstd; print(repr(zstd.compress(b'')))"
2. valgrind --track-origins=yes python3 -c "import zstd; print(repr(zstd.compress(b'')))" > valgrind.log

Actual results (Fedora 36):
    b"\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
    \x00'ModuleSpec' object has no attribute '_initializ"

Actual results (Fedora 37):
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
    \x00\x00\x00\x00'

Expected results: b'(\xb5/\xfd \x00\x01\x00\x00'

Additional info:
https://github.com/sergey-dryabzhinsky/python-zstd/releases/tag/v1.5.2.6 should have the fix

Comment 1 Alexander Sosedkin 2022-12-05 18:00:37 UTC
Created attachment 1930155 [details]
valgrind log obtained on Fedora 37

Comment 2 Zack Miele 2023-03-16 20:36:24 UTC
This is not a security issue. No memory boundary looks to be crossed here.

The issue here is that python-zstd was using a deprecated function ZSTD_getDecompressedSize() which is obseleted and replaced by ZSTD_getFrameContentSize() in zstd. Instead of failing after ZSTD_getDecompressedSize() returns a 0, python-zstd continued to attempt to compress the data since it may be compressable but have an unknown content size which would make it necessary to use streaming mode. Eventually this returns the smallest size frame returned by ZSTD_COMPRESSBOUND().

As Alexander mentions, this is resolved in 1.5.2.6.

Comment 3 Michel Lind 2023-09-12 19:07:29 UTC
ack. Will prioritize getting this updated, thanks!

Comment 4 Aoife Moloney 2023-11-23 00:42:07 UTC
This message is a reminder that Fedora Linux 37 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 37 on 2023-12-05.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '37'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 37 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 5 Aoife Moloney 2023-12-06 11:38:29 UTC
Fedora Linux 37 entered end-of-life (EOL) status on None.

Fedora Linux 37 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.