Skip to content

HDDS-14091. [STS] Deny access if STS token is found in revoked table#9445

Merged
ChenSammi merged 6 commits intoapache:HDDS-13323-stsfrom
fmorg-git:HDDS-14091
Dec 17, 2025
Merged

HDDS-14091. [STS] Deny access if STS token is found in revoked table#9445
ChenSammi merged 6 commits intoapache:HDDS-13323-stsfrom
fmorg-git:HDDS-14091

Conversation

@fmorg-git
Copy link
Copy Markdown
Contributor

@fmorg-git fmorg-git commented Dec 5, 2025

Please describe your PR in detail:

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14091

How was this patch tested?

unit tests (and prototype)

@fmorg-git fmorg-git marked this pull request as draft December 5, 2025 23:26
@fmorg-git fmorg-git marked this pull request as ready for review December 8, 2025 21:03
@Tejaskriya Tejaskriya added the sts Changes for Ozone's S3 Security Token Service label Dec 9, 2025
Copy link
Copy Markdown
Contributor

@Tejaskriya Tejaskriya left a comment

Choose a reason for hiding this comment

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

Thanks @fmorg-git, the changes mostly look good, I just had a suggestion for the tests (below).

@fmorg-git fmorg-git requested a review from Tejaskriya December 9, 2025 19:42

final String tempAccessKeyId = stsTokenIdentifier.getTempAccessKeyId();
if (tempAccessKeyId == null || tempAccessKeyId.isEmpty()) {
return false;
Copy link
Copy Markdown
Contributor

@ChenSammi ChenSammi Dec 11, 2025

Choose a reason for hiding this comment

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

Although the revoke hit chance is very low, but If metadataManager, revokedStsTokenTable or tempAccessKeyId is null, we'd better throw exception to fail the request, instead of silently ignore these failures and assuming that temp access key ID is not revoked, for none of above cases are normal as expected.

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.

updated


return revokedStsTokenTable.getIfExist(tempAccessKeyId) != null;
} catch (Exception e) {
// Any DB or codec problem is treated as best-effort failure.
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.

Whether the revocation check is a best-effort, or strictly enforced, it's an important behavior of revocation, we should highlight it clearly in the design doc. Current doc doesn't have this info.

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.

updated the design with this commit to clarify that revocation is strictly enforced: 398c9f6

return false;
}

return revokedStsTokenTable.getIfExist(tempAccessKeyId) != null;
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 think there will not be many rovoked IDs, so we can consider make s3RevokedStsTokenTable table FULL_CACHE, then all revoked items will be kept in memory.

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.

updated

@fmorg-git fmorg-git requested a review from ChenSammi December 13, 2025 00:08
if (tempAccessKeyId == null || tempAccessKeyId.isEmpty()) {
final String msg = "Could not determine STS revocation: tempAccessKeyId in STSTokenIdentifier is null/empty";
LOG.warn(msg);
throw new OMException(msg, INTERNAL_ERROR);
Copy link
Copy Markdown
Contributor

@ChenSammi ChenSammi Dec 15, 2025

Choose a reason for hiding this comment

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

If tempAccessKeyId is null or empty, it's an invalid tempAccessKeyId, INTERNAL_ERROR is not a proper error code. It's better to move this check to verifyAndDecryptToken().

The rest looks good to me.

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.

updated

public void testEnsureEssentialFieldsArePresentInTokenMissingExpiry() {
final byte[] encryptionBytes = new byte[5];
ThreadLocalRandom.current().nextBytes(encryptionBytes);
final STSTokenIdentifier tokenIdentifier = new STSTokenIdentifier(
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.

Fabian, do you want to replace this line with createTokenWithMissingField too?

Copy link
Copy Markdown
Contributor Author

@fmorg-git fmorg-git Dec 16, 2025

Choose a reason for hiding this comment

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

I couldn't use createTokenWithMissingField for expiration since the expiration is set internally via clock.instant(). However, I see how it can be confusing, so I updated the testEnsureEssentialFieldsArePresentInToken* tests so they are consistent.

Copy link
Copy Markdown
Contributor

@Tejaskriya Tejaskriya left a comment

Choose a reason for hiding this comment

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

Thanks for updating this @fmorg-git , LGTM.

Copy link
Copy Markdown
Contributor

@ChenSammi ChenSammi left a comment

Choose a reason for hiding this comment

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

The last commit LGTM, +1.

@ChenSammi
Copy link
Copy Markdown
Contributor

CI consistently failed for last three runs on the same test hadoop-ozone/dev-support/checks/acceptance.sh compat-new .

@ChenSammi
Copy link
Copy Markdown
Contributor

ChenSammi commented Dec 17, 2025

I downloaded fmorg-git:HDDS-14091 and run the hadoop-ozone/dev-support/checks/acceptance.sh compat-new locally twice, all passed. The CI failure is not relevant to this patch.

@ChenSammi ChenSammi merged commit ae4bdb3 into apache:HDDS-13323-sts Dec 17, 2025
122 of 125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sts Changes for Ozone's S3 Security Token Service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants