fix(sts): cap account-root token durations at one hour (#7125)

* fix(sts): cap account-root token durations at one hour

Cap GetSessionToken and GetFederationToken credentials issued to the account-root identity at one hour, preserving IAM user durations and validation ordering.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

* test(sts): bound root token expiry by request time

Check the one-hour default using timestamps captured before the request and after the response, allowing millisecond wire precision. Preserve the root duration cap.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

---------

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-31 17:01:47 -04:00
1 parent dc04c47791
commit 81e1dbc573
5 files changed
+158 -3

No files matched your search

@@ -324,7 +324,7 @@ public class StsQueryHandler {
if (validation != null) {
return validation;
}
int durationSeconds = getIntParam(params, "DurationSeconds", 43200);
int durationSeconds = longTermTokenDuration(params);
String accessKeyId = "ASIA" + randomId(16);
String secretKey = randomSecret(40);
String sessionToken = randomSecret(200);
@@ -610,6 +610,12 @@ public class StsQueryHandler {
return auth == null ? null : accountResolver.extractAccessKeyId(auth);
}
private int longTermTokenDuration(MultivaluedMap<String, String> params) {
int requested = getIntParam(params, "DurationSeconds", 43200);
// Session registration treats an unheld long-term key as Floci's account-root credential.
return iamService.isKnownAccessKey(callerAccessKeyId()) ? requested : Math.min(requested, 3600);
}
private Response handleGetFederationToken(MultivaluedMap<String, String> params) {
if (IamService.isTemporaryAccessKey(callerAccessKeyId())) {
return AwsQueryResponse.error("AccessDenied", IamService.FEDERATION_TOKEN_SESSION_MESSAGE,
@@ -624,7 +630,7 @@ public class StsQueryHandler {
return validation;
}
String name = getParam(params, "Name");
int durationSeconds = getIntParam(params, "DurationSeconds", 43200);
int durationSeconds = longTermTokenDuration(params);
String accessKeyId = "ASIA" + randomId(16);
String secretKey = randomSecret(40);