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

EOF: Nested container validation without recursion #794

Open
gumb0 opened this issue Jan 15, 2024 · 0 comments
Open

EOF: Nested container validation without recursion #794

gumb0 opened this issue Jan 15, 2024 · 0 comments
Assignees
Labels

Comments

@gumb0
Copy link
Member

gumb0 commented Jan 15, 2024

Currently nested containers are validated by recursive calls to validation function (see eof-create4 branch). Subcontainers are validated before instruction validation of parent container, because CREATE3 validation requires to know whether target child container is truncated or not.

Recursion is potentially attackable by nesting containers many levels deep causing client's stack overflow. It is better to rewrite is as interation, here is a sketch of an algorithm:

worklist = queue(parent_container)

while worklist not empty:
  container = worklist.dequeue()
  header = validate_header(container)
  
  subcontainer_headers = {}
  for all subcontainers in header:
    subcont_header = validate_header(subcontainer)
    subcontainer_header.push_back(subcontainer_header)
    worklist.queue(subcontainer)

  validate_instructions(container, subcontainer_headers)
  validate_stack(container) etc.

Essentially you need to validate child container headers before validating instructions of the parent one.

@gumb0 gumb0 added the EOF label Jan 15, 2024
@gumb0 gumb0 self-assigned this Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant