Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickletools doesn't error on EXT4 negative argument #127045

Closed
Legoclones opened this issue Nov 20, 2024 · 2 comments
Closed

Pickletools doesn't error on EXT4 negative argument #127045

Legoclones opened this issue Nov 20, 2024 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@Legoclones
Copy link
Contributor

Legoclones commented Nov 20, 2024

Bug report

Bug description:

All extension codes must be positive (enforced when using copyreg.add_extension and in both pickle.py and _pickle.c implementations), but pickletools doesn't throw an error if EXT4 has a negative argument.

I can make a pull request to change the argument from int4 to uint4, but that means pickletools accepts extension codes that are 0x7fffffff or higher, while pickle.py and _pickle.c don't. I could also change those modules so they process the 4 bytes as unsigned also, if no one has any objections to that.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

@Legoclones Legoclones added the type-bug An unexpected behavior, bug, or error label Nov 20, 2024
@serhiy-storchaka
Copy link
Member

I think that it is not an issue that pickletools is more lenient than pickle.

@Legoclones
Copy link
Contributor Author

@serhiy-storchaka Okay, that's fine. I've been doing some research into discrepancies between the 3 pickle implementations so that reverse engineering/identifying malicious pickles has less holes that someone could abuse. I've reported a number of them already across my various issues and I have a few more still. A lot of them are edge cases that are hard to detect and require custom pickles, but I figured it's better to report them and have us decide it's not worth it to fix than not report it and it's something you all would like us to change.

I have also been going opcode by opcode and writing my own supplements to the "documentation" (documentation meaning the code comments in pickletools), and I'll also make an issue/pull request here soon with a bunch of updates to correct, modify, or add to the documentation.

As for this specific EXT4 issue, if we don't care that pickletools is more lenient than others I'll go ahead and close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

2 participants