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

fix: LSDV-5337: Pre-signed file proxy url clashing with already html encoded values causing errors in signature #4447

Merged
merged 7 commits into from
Jun 29, 2023

Conversation

bmartel
Copy link
Contributor

@bmartel bmartel commented Jun 26, 2023

PR fulfills these requirements

  • Commit message(s) and PR title follows the format [fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made ex. fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
  • Tests for the changes have been added/updated (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance (for bug fixes/features)

Change has impacts in these area(s)

(check all that apply)

  • Product design
  • Backend (Database)
  • Backend (API)
  • Frontend

Describe the reason for change

In some cases the values inside of the pre-signed storage uris could become double encoded for a portion of the string (either sourced this way, or parsed). This would then invalidate the signature when calculating the final presigned url, or possibly the resultant URL entirely.

What does this fix?

Switch from using a url encode/decode on the fileuri query param, and instead use a urlsafe base64 encode/decode. This way we can support all the various values which could be supported in the external storage(s) URI and not limit or break user functionality when using the presigned url options. There is also provisions for a fallback if the base64 fails, it will operate with unquote on the string as was before, which will serve to automatically migrate usage while it is inflight and local user caches invalidate.

What libraries were added/updated?

N/A.

Does this change affect performance?

No.

Does this change affect security?

No.

What feature flags were used to cover this change?

None.

Does this PR introduce a breaking change?

(check only one)

  • Yes, and covered entirely by feature flag(s)
  • Yes, and covered partially by feature flag(s)
  • No
  • Not sure (briefly explain the situation below)

What level of testing was included in the change?

(check all that apply)

  • e2e
  • integration
  • unit

Which logical domain(s) does this change affect?

ImportStorage, PresignedStorageData

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for label-studio-docs-new-theme failed.

Name Link
🔨 Latest commit 2937dc6
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/649b1ff228884800084991b5

@netlify
Copy link

netlify bot commented Jun 26, 2023

Deploy Preview for heartex-docs failed.

Name Link
🔨 Latest commit 2937dc6
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/649b1ff20918fc0008f99b70

@github-actions github-actions bot added the fix label Jun 26, 2023
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (35618d5) 75.57% compared to head (2937dc6) 75.57%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4447      +/-   ##
===========================================
- Coverage    75.57%   75.57%   -0.01%     
===========================================
  Files          156      156              
  Lines        12213    12219       +6     
===========================================
+ Hits          9230     9234       +4     
- Misses        2983     2985       +2     

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bmartel bmartel merged commit e321639 into develop Jun 29, 2023
23 of 34 checks passed
wesleylima pushed a commit that referenced this pull request Aug 11, 2023
…encoded values causing errors in signature (#4447)

* fix: LSDV-5337: Pre-signed file proxy url clashing with already html encoded values causing errors in signature

* Update base_models.py

* updating tests to account for change in assertions of url structure, adding test to cover fallback scenario

* Adding a test to outline resolution and support of the upper limits of file uris in cloud storage

* removing any vendor specifics, just keep the characters

* don't need this in the stubs as it was triggering false positives on security
shayantabatabaee pushed a commit to shayantabatabaee/label-studio that referenced this pull request Sep 19, 2023
…encoded values causing errors in signature (HumanSignal#4447)

* fix: LSDV-5337: Pre-signed file proxy url clashing with already html encoded values causing errors in signature

* Update base_models.py

* updating tests to account for change in assertions of url structure, adding test to cover fallback scenario

* Adding a test to outline resolution and support of the upper limits of file uris in cloud storage

* removing any vendor specifics, just keep the characters

* don't need this in the stubs as it was triggering false positives on security
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants