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

Check index bounds in compact protocol reader. #16493

Merged
merged 5 commits into from
Sep 7, 2024

Conversation

bdice
Copy link
Contributor

@bdice bdice commented Aug 5, 2024

Description

This adds bounds checking to the compact protocol reader's read function.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Aug 5, 2024
@bdice bdice marked this pull request as ready for review August 15, 2024 16:54
@bdice bdice requested review from a team as code owners August 15, 2024 16:54
@@ -399,6 +404,7 @@ struct parquet_field_binary_list
auto const l = cpr->get_u32();
CUDF_EXPECTS(l <= static_cast<size_t>(cpr->m_end - cpr->m_cur), "binary length mismatch");

CUDF_EXPECTS(i >= 0 and i < val.size());
Copy link
Contributor

@davidwendt davidwendt Aug 15, 2024

Choose a reason for hiding this comment

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

Looks like the vector is resized in the next line so maybe this check should include l instead of val.size()
Sorry, the resize is on the vector's vector.

Copy link
Member

@mhaseeb123 mhaseeb123 left a comment

Choose a reason for hiding this comment

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

From L103-105, the parquet_field_list base class where these functions are being called from, it does look like we have an assert which checks the requested field's size, and then modifies i and v appropriately to pass to the sub-functions so the checks do seem redundant. I am okay either way though, especially if it was flagged by a security scan.

Copy link
Contributor

@ttnghia ttnghia left a comment

Choose a reason for hiding this comment

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

The index i to check is already unsigned thus we may not need to check if i < 0.

@bdice bdice added bug Something isn't working non-breaking Non-breaking change labels Aug 20, 2024
@bdice bdice self-assigned this Aug 20, 2024
Copy link
Member

@mhaseeb123 mhaseeb123 left a comment

Choose a reason for hiding this comment

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

At L103-105, the parquet_field_list base class assert checks the requested field's type and adjust v.size() and i appropriately before passing them to these sub-functions so the added checks do seem redundant to me.

I am okay with the checks if needed to pass security checks. Otherwise, we can maybe suppress them.

@bdice
Copy link
Contributor Author

bdice commented Sep 6, 2024

@mhaseeb123 I agree it would be good to suppress these checks. I don't know how these checks work but I will inquire. For now, I think we're safer just to enforce the requirement directly.

@bdice
Copy link
Contributor Author

bdice commented Sep 6, 2024

/merge

@rapids-bot rapids-bot bot merged commit 4784067 into rapidsai:branch-24.10 Sep 7, 2024
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants