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

Prevent RAM exhaustion by limiting maximum value of some fields #146

Closed
wants to merge 1 commit into from

Conversation

aler9
Copy link
Contributor

@aler9 aler9 commented Sep 23, 2023

@sunfish-shogi

Currently it's possible to exhaust available memory by inserting very large numbers into various size fields. This PR adds additional checks on a couple of size fields:

  • hdlr's name size, which is currently unchecked and is passed directly to make([]byte)

  • slice size, which is currently limited to 4.2GB, and is passed directly to make([]byte)

Both are now limited to 100KB. I'm not aware of any MP4 field whose content can exceed 100KB (excluding the content of mdat, which is not unmarshaled).

Currently it's possible to exhaust available memory by inserting very
large numbers into various size fields. This PR adds additional checks
on a couple of size fields:

* hdlr's name size, which is currently unchecked and is passed directly
to make([]byte)

* slice size, which is currently limited to 4.2GB, and is passed
directly to make([]byte)

Both are now limited to 100KB. I'm not aware of any MP4 field whose
content can exceed 100KB (excluding the content of mdat, which is not
unmarshaled).
@aler9
Copy link
Contributor Author

aler9 commented Sep 24, 2023

This needs to be rethinked since mdat data is unmarshaled into a field.

@aler9 aler9 closed this Sep 24, 2023
@sunfish-shogi
Copy link
Contributor

sunfish-shogi commented Sep 24, 2023

I created an issue: #149 .
I'm considering to add default maximum array length and the way to define individual limits for each box types (ex. mdat).

@sunfish-shogi
Copy link
Contributor

@aler9
I created #150
I think this change prevents to allocate large memory which significantly exceeds file size.

@aler9 aler9 deleted the patch/oom branch September 30, 2023 10:04
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