diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index ae1065160ad..67bd8f300a0 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4614,9 +4614,14 @@ rgw::auth::s3::STSEngine::get_session_token(const DoutPrefixProvider* dpp, const ldpp_dout(dpp, 0) << "ERROR: Decryption failed: " << error << dendl; return -EPERM; } else { - dec_output.append('\0'); - auto iter = dec_output.cbegin(); - decode(token, iter); + try { + dec_output.append('\0'); + auto iter = dec_output.cbegin(); + decode(token, iter); + } catch (const buffer::error& e) { + ldout(cct, 0) << "ERROR: decode SessionToken failed: " << error << dendl; + return -EINVAL; + } } return 0; }