From 79560d5a08b212aaada9ccf3a2e0cb84c8dd2dfe Mon Sep 17 00:00:00 2001 From: "Matthew N. Heler" Date: Tue, 17 Mar 2026 15:33:32 -0500 Subject: [PATCH] rgw: stop crashing when an admin tries to assume a nonexistent role An admin user sending an AssumeRole request for a role that doesn't exist would crash rgw. The permission check failed but got overridden because the caller was an admin, and the code that ran next blindly assumed the role had already been loaded. Fixed by loading the role directly instead of hoping it was done earlier. Signed-off-by: Matthew N. Heler (cherry picked from commit a1f1811f50509f6986198b95d51802c328afa9af) --- src/rgw/rgw_sts.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_sts.cc b/src/rgw/rgw_sts.cc index 951af012b48..d57d784464b 100644 --- a/src/rgw/rgw_sts.cc +++ b/src/rgw/rgw_sts.cc @@ -399,16 +399,16 @@ AssumeRoleResponse STSService::assumeRole(const DoutPrefixProvider *dpp, AssumeRoleResponse response; response.packedPolicySize = 0; - //Get the role info which is being assumed - boost::optional r_arn = rgw::ARN::parse(req.getRoleARN()); - if (r_arn == boost::none) { - ldpp_dout(dpp, 0) << "Error in parsing role arn: " << req.getRoleARN() << dendl; - response.retCode = -EINVAL; + auto [ret, r] = getRoleInfo(dpp, req.getRoleARN(), y); + if (ret < 0) { + response.retCode = ret; return response; } - string roleId = role->get_id(); - uint64_t roleMaxSessionDuration = role->get_max_session_duration(); + boost::optional r_arn = rgw::ARN::parse(req.getRoleARN()); + + string roleId = r->get_id(); + uint64_t roleMaxSessionDuration = r->get_max_session_duration(); req.setMaxDuration(roleMaxSessionDuration); //Validate input -- 2.47.3