HDDS-15984. [STS] Improve s3:prefix Condition handling and reject unsupported AssumeRole parameters#10875
Open
fmorg-git wants to merge 2 commits into
Open
HDDS-15984. [STS] Improve s3:prefix Condition handling and reject unsupported AssumeRole parameters#10875fmorg-git wants to merge 2 commits into
fmorg-git wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens validation in the S3 STS (AssumeRole) surface by rejecting previously-ignored unsupported parameters, and improves IAM session policy parsing to reject invalid s3:prefix condition shapes instead of silently accepting/ignoring them.
Changes:
- Add explicit validation for AssumeRole parameter names (GET query params and POST form params), distinguishing “AWS-valid but not implemented” vs “unsupported”.
- Update the STS POST endpoint to consume a form payload as a single entity and validate only body parameters (ignoring query string params for POST).
- Reject IAM session policies that specify multiple Condition keys per operator (e.g.,
StringEqualscontaining boths3:prefixand another key).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3sts/TestS3STSEndpoint.java | Adds unit tests covering new AssumeRole parameter validation behavior for GET and POST. |
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3sts/S3STSEndpointBase.java | Adds a safe helper to access query parameters from the request context. |
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3sts/S3STSEndpoint.java | Implements AssumeRole parameter validation (allowed vs unsupported vs not-implemented AWS params) and updates POST handling to consume Form. |
| hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/security/acl/iam/TestIamSessionPolicyResolver.java | Adds test cases ensuring multiple Condition keys (including ordering variations) are rejected. |
| hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/iam/IamSessionPolicyResolver.java | Enforces “exactly one Condition key per operator” in s3:prefix condition parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+368
to
+372
| private static boolean isAllowedAssumeRoleParameter(String paramName) { | ||
| return StringUtils.isBlank(paramName) | ||
| || ASSUME_ROLE_ALLOWED_PARAMS.contains(paramName) | ||
| || Strings.CI.startsWith(paramName, SIGV4_PARAM_PREFIX); | ||
| } |
ChenSammi
reviewed
Jul 27, 2026
| @FormParam("Policy") String awsIamSessionPolicy) throws OS3Exception { | ||
|
|
||
| return handleSTSRequest(action, roleArn, roleSessionName, durationSeconds, version, awsIamSessionPolicy); | ||
| public Response post(Form form) throws OS3Exception { |
Contributor
There was a problem hiding this comment.
If form is null, can we just response with error directly?
ChenSammi
reviewed
Jul 27, 2026
| * @return Response containing STS response XML or error | ||
| */ | ||
| @POST | ||
| @Consumes(MediaType.APPLICATION_FORM_URLENCODED) |
Contributor
There was a problem hiding this comment.
It looks like AWS STS support ”application/x-www-form-urlencoded“ and “application/x-amz-json-1.1”, we only support the first one?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please describe your PR in detail:
Separately, currently unsupported AssumeRole api parameters are being ignored rather than being rejected. This ticket will improve that as well.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15984
How was this patch tested?
unit tests and smoke tests