Skip to content

fix(explorer): fetch_batch_data_pointer in explorer reads the entire response body without any limitation#1198

Merged
entropidelic merged 20 commits into
stagingfrom
1016-fixexplorer-fetch_batch_data_pointer-in-explorer-reads-the-entire-response-body-without-any-limitation
Oct 14, 2024
Merged

fix(explorer): fetch_batch_data_pointer in explorer reads the entire response body without any limitation#1198
entropidelic merged 20 commits into
stagingfrom
1016-fixexplorer-fetch_batch_data_pointer-in-explorer-reads-the-entire-response-body-without-any-limitation

Conversation

@avilagaston9
Copy link
Copy Markdown
Contributor

@avilagaston9 avilagaston9 commented Oct 8, 2024

Motivation

The function fetch_batch_data_pointer in the explorer reads the entire response body without any
limitations, which can lead to an OOM attack.

Description

Uses a max_batch_size limit when reading request bodies.

How to Test

See #1202

Closes #1016

@avilagaston9 avilagaston9 marked this pull request as ready for review October 8, 2024 19:36
Copy link
Copy Markdown
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

Comment thread explorer/lib/explorer_web/live/utils.ex Outdated
Copy link
Copy Markdown
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to have another state for the batch.
For this a new ecto migrate is needed, adding an is_valid bool to the batches table.
Also the schemas should be updated, and the value should be set to false if the batch is not valid.

Also in the frontend, invalid proofs should be shown a red invalid status.

Comment thread explorer/lib/explorer_web/live/utils.ex Outdated
{:error, reason} ->
Logger.error("Error fetching batch content: #{inspect(reason)}")
# Returning something ensures we avoid attempting to fetch the invalid data again.
["invalid batch"]
Copy link
Copy Markdown
Contributor

@uri-99 uri-99 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string is converted to hex in frontend, better handle invalids in a cleaner way

Copy link
Copy Markdown
Contributor Author

@avilagaston9 avilagaston9 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to [<<0>>] to show 0x0 in the frontend for now. I'm solving this in a different PR in case we need to merge this one.

Comment thread explorer/lib/explorer_web/live/utils.ex Outdated
Comment thread explorer/lib/explorer_web/live/utils.ex Outdated
Copy link
Copy Markdown
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as Marian

Co-authored-by: Urix <43704209+uri-99@users.noreply.github.com>
Copy link
Copy Markdown
Member

@MarcosNicolau MarcosNicolau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on macos.

@entropidelic entropidelic merged commit e5b3f80 into staging Oct 14, 2024
@entropidelic entropidelic deleted the 1016-fixexplorer-fetch_batch_data_pointer-in-explorer-reads-the-entire-response-body-without-any-limitation branch October 14, 2024 20:33
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.

5 participants