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

Add an array filter to our serialize/deserialize methods and narrow down previous filter #849

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

b4sjoo
Copy link
Collaborator

@b4sjoo b4sjoo commented Apr 7, 2023

Description

Previous we did not add filter to the depth and byte array length to our deserialization method, which can cause a denial of service attack via very long arrays or nested objects. Meanwhile we have an allowlist that is too general so malicious files could potentially bypass. Now we narrow down the allowlist, add a reject list, and also add a depth and length filter. In long term we will try to change this byte stream deserialization method into json or protocol buffer.

Issues Resolved

This is a short-term fix in regards to a security ticket.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

b4sjoo added 3 commits April 7, 2023 20:03
…own previous filter

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 14, 2023

Codecov Report

Merging #849 (dcf4fd6) into 2.x (036bda0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##                2.x     #849   +/-   ##
=========================================
  Coverage     84.81%   84.82%           
  Complexity     1628     1628           
=========================================
  Files           135      135           
  Lines          6079     6083    +4     
  Branches        596      596           
=========================================
+ Hits           5156     5160    +4     
  Misses          666      666           
  Partials        257      257           
Flag Coverage Δ
ml-commons 84.82% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../org/opensearch/ml/engine/utils/ModelSerDeSer.java 83.33% <100.00%> (+3.33%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
Copy link
Collaborator

@ylwu-amzn ylwu-amzn left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

@b4sjoo b4sjoo merged commit 0997d6c into opensearch-project:2.x Apr 17, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-849-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0997d6cbc247b705c340e31480e381513d3a8691
# Push it to GitHub
git push --set-upstream origin backport/backport-849-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-849-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 17, 2023
…own previous filter (#849)

* Add an array filter to our serialize/deserialize methods and narrow down previous filter

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Further narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Keep narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Add test for deserialization methods in all built-in models

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

---------

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
(cherry picked from commit 0997d6c)
b4sjoo added a commit that referenced this pull request Apr 17, 2023
…own previous filter (#849) (#857)

* Add an array filter to our serialize/deserialize methods and narrow down previous filter

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Further narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Keep narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Add test for deserialization methods in all built-in models

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

---------

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
(cherry picked from commit 0997d6c)

Co-authored-by: Sicheng Song <sicheng.song@outlook.com>
@b4sjoo b4sjoo deleted the 2.x_ser_deser branch April 18, 2023 19:46
rbhavna pushed a commit to rbhavna/ml-commons that referenced this pull request Jun 16, 2023
…own previous filter (opensearch-project#849)

* Add an array filter to our serialize/deserialize methods and narrow down previous filter

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Further narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Keep narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Add test for deserialization methods in all built-in models

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

---------

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
rbhavna pushed a commit to rbhavna/ml-commons that referenced this pull request Jun 16, 2023
…own previous filter (opensearch-project#849)

* Add an array filter to our serialize/deserialize methods and narrow down previous filter

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Further narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Keep narrowing down accept list

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

* Add test for deserialization methods in all built-in models

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>

---------

Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
rbhavna added a commit that referenced this pull request Jun 16, 2023
…own previous filter (#849) (#993)


Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
Co-authored-by: Sicheng Song <sicheng.song@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants