Skip to content

rgw/sts: Implementation of validating JWT using modulus and exponent - #61796

Merged
batrick merged 4 commits into
ceph:mainfrom
pritha-srivastava:wip-rgw-n-e
Apr 28, 2025
Merged

batrick merged 4 commits into
ceph:mainfrom
pritha-srivastava:wip-rgw-n-e

Conversation

@pritha-srivastava

@pritha-srivastava pritha-srivastava commented Feb 13, 2025 •

Copy link
Copy Markdown
Contributor

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@pritha-srivastava
pritha-srivastava requested a review from a team as a code owner February 13, 2025 11:22
@github-actions github-actions Bot added the rgw label Feb 13, 2025
@pritha-srivastava

Copy link
Copy Markdown
Contributor Author
  1. Code for validation using n&e has been picked from rgw/sts: enhancements and improvements to JWT validation #41525.
  2. Fix for "error:0407008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding" included.
  3. AWS style thumbprint verification added for n&e for now (can be used for all key types later).

@adamemerson

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox Take a look at this if you could, please.

@awojno-bloomberg

Copy link
Copy Markdown
Contributor

The latest version of jwt-cpp library which we use already has support for n&e validation. We should update the library instead of writing custom code in order to make it easier to rebase in the future if we want to pull in further fixes. I did this in commit 2427bfa so feel free to copy/use as reference.

@awojno-bloomberg

Copy link
Copy Markdown
Contributor

Also, which trackers does this address. I see the checkbox is ticked but no trackers are mentioned in description.

@awojno-bloomberg

Copy link
Copy Markdown
Contributor

Given the overlap between this PR and #60985, maybe we should create a baseline PR that just introduces N&E validation and then addresses further changes in the future. This seems like a way to proceed and have smaller targeted fixes as I believe both PRs perhaps try to address too much. Any thoughts?

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

Also, which trackers does this address. I see the checkbox is ticked but no trackers are mentioned in description.

Please check the individual commits

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

Given the overlap between this PR and #60985, maybe we should create a baseline PR that just introduces N&E validation and then addresses further changes in the future. This seems like a way to proceed and have smaller targeted fixes as I believe both PRs perhaps try to address too much. Any thoughts?

This PR has segregated changes into separate commits, but all of them together address the N&E changes. I will check the new jwt-cpp library and cherry-pick the changes from 2427bfa if needed.

@cbodley

cbodley commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

I will check the new jwt-cpp library and cherry-pick the changes from 2427bfa if needed.

have you had a chance to look at this, @pritha-srivastava?

@awojno-bloomberg

Copy link
Copy Markdown
Contributor

@pritha-srivastava, to move forward, we could have an PR that just has commit 2427bfa to update the library. The update contains support for bare key validation and rebase our PRs on top of the new library. Any thoughts?

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

I will check the new jwt-cpp library and cherry-pick the changes from 2427bfa if needed.

have you had a chance to look at this, @pritha-srivastava?

@cbodley : I will take a look shortly, by next week.

@pritha-srivastava

pritha-srivastava commented Apr 14, 2025 •

Copy link
Copy Markdown
Contributor Author

I will check the new jwt-cpp library and cherry-pick the changes from 2427bfa if needed.

have you had a chance to look at this, @pritha-srivastava?

@cbodley : I will take a look shortly, by next week.

@cbodley @awojno-bloomberg : I am planning to cherry-pick 2427bfa and parts of 277cd24 onto this PR. And then test these changes as this PR in its current form has been tested.

@jmundack

Copy link
Copy Markdown
Contributor

I will check the new jwt-cpp library and cherry-pick the changes from 2427bfa if needed.

have you had a chance to look at this, @pritha-srivastava?

@cbodley : I will take a look shortly, by next week.

@cbodley @awojno-bloomberg : I am planning to cherry-pick 2427bfa and parts of 277cd24 onto this PR. And then test these changes as this PR in its current form has been tested.

Thoughts on doing some incremental PR's with targetted changes so that we are not bundling all these changes?

@pritha-srivastava - appreciate the help on this! - the fix that @awojno-bloomberg is chasing is blocking a several things for us and we are hoping not to patch things downstream. We always try and follow the best practice of getting things in upstream first! 😄

@mattbenjamin

Copy link
Copy Markdown
Contributor

It seems like we should indeed be pulling up the JWT library. @pritha-srivastava could you pull up your PR here and thumprint verification, on to @awojno-bloomberg 's commit(s) pulling up JWT?

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

It seems like we should indeed be pulling up the JWT library. @pritha-srivastava could you pull up your PR here and thumprint verification, on to @awojno-bloomberg 's commit(s) pulling up JWT?

  1. I will pull up the JWT library and cherry-pick @awojno-bloomberg's code that calls into it
  2. I will add the other two commits on top of it - I think the thumbprint verification must go in along with n+e token signature verification code so that the end user does not end up bypassing thumbprint verification.
  3. Figure out if there is a way to run this through teuthology.

@cbodley

cbodley commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

i created a 'rgw cleanup' task in https://tracker.ceph.com/issues/70910 to use a git submodule for src/rgw/jwt-cpp, but that doesn't need to block progress here

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

@mattbenjamin @cbodley : I have updated the PR and performed developer level testing and it works. I will schedule a teuthology run to ensure there are no regressions. Please note: since we are not using an https url for keycloak, we can not test this in teuthology

Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Outdated
Comment on lines 409 to 411

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't there a matching catch somewhere that's going to log this message again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will check

Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm not sure we want any of these errors logged at level 0. this is all happening during AssumeRoleWithWebIdentity, right? we should instead be sending good error messages back to the client via s->err.message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

authenticate() method is the entry point which takes in req_state as a const pointer. Can I remove const from it? Or is there an alternative way by which we can return error messages from the authentication() step

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm, right.. on error from one auth engine, we might fall back to another engine and succeed or fail differently. so auth engines probably shouldn't set error messages directly

i suppose we could extend rgw::auth::Engine::AuthResult to include an optional "message" string? rgw::auth::Strategy::authenticate() returns the "final" AuthResult, so rgw::auth::Strategy::apply() could assign that message to s->err.message

that design could also avoid the special cases we added there for ERR_PRESIGNED_URL_EXPIRED/ERR_PRESIGNED_URL_DISABLED

i don't want to block progress here though. if it gets complicated, maybe we can defer those changes to a followup pr. what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes rgw::auth::Strategy::apply() is the place to assign the error message, and rgw::auth::Engine::AuthResult is the correct place to add a variable to hold the message. and we can track these changes in a separate tracker as you suggested as this might affect other auth engines also. So for now, I will bump up the log levels from 0 atleast. And if you have any other comments on the current PR, let me know.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cbodley : did you get a chance to create a tracker for this? shall I create one if you didnt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@awojno-bloomberg

Copy link
Copy Markdown
Contributor

Are there any new unit or integration tests we can add to test the new features?

Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
Comment thread src/rgw/rgw_rest_sts.cc Resolved
@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

@BBoozmen

Copy link
Copy Markdown
Contributor

Hi @cbodley , @adamemerson , @pritha-srivastava ,
Looks like this is ready to go in AFAIU from the comments and Casey's approval.
If no blockers, can we get this in?

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

@cbodley @adamemerson : I've updated the PR with the log statement that I wanted to add, and it is now ready to be merged.

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

Hi @cbodley , @adamemerson , @pritha-srivastava , Looks like this is ready to go in AFAIU from the comments and Casey's approval. If no blockers, can we get this in?

this should be merged today (provided all jenkins tests pass).

@BBoozmen

Copy link
Copy Markdown
Contributor

jenkins test make check

@BBoozmen

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@pritha-srivastava

pritha-srivastava commented Apr 26, 2025 •

Copy link
Copy Markdown
Contributor Author

make check failures

201 - mgr-dashboard-smoke.sh (Failed)
208 - unittest_bluefs (Timeout)

@pritha-srivastava

pritha-srivastava commented Apr 26, 2025 •

Copy link
Copy Markdown
Contributor Author

make check arm64 failures:

 35 - run-cli-tests (Failed)

the failures do not look related to this PR @cbodley @adamemerson

using modulus and exponent for RSA group of algorithms.

A couple of issues and a fix have been suggested by
Pupu Toivonen ([email protected]) in signature calculation
using modulus and exponent.

Fixes: https://tracker.ceph.com/issues/51018
Signed-off-by: Pritha Srivastava <[email protected]>
if aud is not present in JWT.

Signed-off-by: Pritha Srivastava <[email protected]>
@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

rebasing with latest main, to see if make check failures go away

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

not sure why make check arm64 has failed, the build has succeeded, the tests have passed, still see the following:

Terminated
Build step 'Execute shell' marked build as failure
[Cobertura] Skipping Cobertura coverage report as build was not SUCCESS or better ...

[PostBuildScript] - [INFO] Executing post build scripts.
[PostBuildScript] - [INFO] Build does not have any of the results [ABORTED]. Did not execute build step #0.
INFO: Processing CTest-Version 3.x (default)
INFO: [CTest-Version 3.x (default)] - No test report file(s) were found with the pattern 'build/Testing/**/Test.xml' relative to '/home/jenkins-build/build/workspace/ceph-pull-requests-arm64' for the testing framework 'CTest-Version 3.x (default)'.
Did you enter a pattern relative to (and within) the workspace directory?
Did you generate the result report(s) for 'CTest-Version 3.x (default)'?"
WARNING: All test reports are empty.
INFO: Check 'Failed Tests' threshold.
[Checks API] No suitable checks publisher found.
INFO: Setting the build status to SUCCESS
[Checks API] No suitable checks publisher found.
Setting status of b5bbeb7ea3a65bfed368f834cc6c11fa23ee24e1 to FAILURE with url https://jenkins.ceph.com/job/ceph-pull-requests-arm64/73147/ and message: 'make check failed
 '
Using context: make check (arm64)
Finished: FAILURE

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

@cbodley @adamemerson all required tests have passed, this is ready to be merged. Check for missing .qa links job seems to be running forever

@batrick
batrick merged commit c3b7a34 into ceph:main Apr 28, 2025
@cbodley

cbodley commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

@pritha-srivastava does this need backports all the way to reef? this pr resolved two issues (https://tracker.ceph.com/issues/51018 and https://tracker.ceph.com/issues/54562), so we should choose one to use for backports. the 'tentacle' branch forked on friday, so we'll need to backport there too

@pritha-srivastava

Copy link
Copy Markdown
Contributor Author

https://tracker.ceph.com/issues/54562 can be used for backports till reef. these issues are long outstanding

@cbodley

cbodley commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

https://tracker.ceph.com/issues/54562 can be used for backports till reef. these issues are long outstanding

thanks, moved that one to Pending Backport and the other to Resolved

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.

8 participants