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

Remove eval from cli #1758

Merged
merged 3 commits into from
Jan 10, 2021
Merged

Remove eval from cli #1758

merged 3 commits into from
Jan 10, 2021

Conversation

152334H
Copy link
Contributor

@152334H 152334H commented Jan 10, 2021

Removal eval()

POC

$ pwn shellcraft amd64.crash --address '__import__("os").system("echo hi")'
hi
5f5e5d5b5b5a59584831e4ffe4

safeeval is used elsewhere in pwntools, so it may be helpful to replace the use of eval() here with safeeval.expr().

The above test case will (correctly) raise an error when eval() is replaced:

Traceback (most recent call last):
...
    raise ValueError("opcode %s not allowed" % dis.opname[code])
ValueError: opcode LOAD_NAME not allowed

And will run as normal with a proper address:

$ pwn shellcraft amd64.crash --address '0x123'
5f5e5d5b5b5a59584831e4ffe4

Testing

I am struggling to find where to put doctests for this, if they are necessary.

Changelog

Making after PR.

P.S.: I made use of this bug for a local CTF I ran with a few others. You can see the challenge here while it's still up.

@Arusekk
Copy link
Member

Arusekk commented Jan 10, 2021

Alright, this came from 11fa0d8 so quite a while ago; but I believe this is not a threat huge enough to be worth backporting.

@Arusekk Arusekk merged commit 153b35b into Gallopsled:dev Jan 10, 2021
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