[ 
https://issues.apache.org/jira/browse/HDDS-17876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148026#comment-18148026
 ] 

Gargi Jaiswal commented on HDDS-17876:
--------------------------------------

I don’t see any problem in this.
The AWS S3 API reference for 
[ListBuckets|https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html]
 and 
[ListDirectoryBuckets|https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListDirectoryBuckets.html]
 describes {{ContinuationToken}} only as an opaque (obfuscated) value. The 
client gets it from one response and sends it back in the next request to the 
same API. *Neither page says that a token from one listing API must be rejected 
by another, and neither defines an error for that case.* 
_*The documented contract is about client behavior:*_ pass back only the token 
that the same API returned. AWS SDK and CLI paginators always do this.

*Why Ozone accepts the token*

In Ozone, both APIs list the same set of buckets (the buckets in the {{s3v}} 
volume) in the same name order. *ListDirectoryBuckets* only filters that list 
down to FSO buckets. Both continuation tokens store just one thing: the name of 
the last bucket returned. In practice the token means "continue after bucket 
name X", and it means the same for both APIs. A ListBuckets token is 
byte-for-byte identical to a ListDirectoryBuckets token that ended on the same 
bucket.

Why this is acceptable
 * Results stays correct. A ListDirectoryBuckets call with a ListBuckets token 
returns the FSO buckets whose names sort after X. Nothing after X is skipped or 
repeated, and the pages that follow are consistent. This matches what is 
described in the report: 5 directory buckets, a new token, then the next 5.

 * The token is only a start position. It does not bypass authorization or 
reveal data, because a user can already list all buckets they are allowed to 
see without any token. Tampered or malformed tokens are still rejected with 
{{{}400 InvalidArgument{}}}. I don’t see any security impact. 

 * Normal clients are not affected. SDKs and the CLI never send a token from 
one API to another, so they paginate the same way they do against AWS.

This works as designed and does not break the documented S3 API contract

> ListDirectoryBuckets Accepts Continuation Token Generated by ListBuckets
> ------------------------------------------------------------------------
>
>                 Key: HDDS-17876
>                 URL: https://issues.apache.org/jira/browse/HDDS-17876
>             Project: Apache Ozone
>          Issue Type: Bug
>          Components: S3
>            Reporter: Bablu Raul
>            Assignee: Gargi Jaiswal
>            Priority: Major
>
> During S3 API validation, I observed that the {{ListDirectoryBuckets}} API 
> accepts a continuation token generated by the {{ListBuckets}} API.
> Both APIs support pagination and generate continuation tokens to retrieve 
> subsequent pages. However, when a token generated by {{ListBuckets}} is 
> passed to {{{}ListDirectoryBuckets{}}}, Ozone accepts the token and 
> successfully returns directory bucket entries instead of rejecting it.
> This behavior needs to be verified against the expected S3 API contract to 
> determine whether continuation tokens should be specific to their respective 
> listing APIs.
> Steps to Reproduce
> *Step 1: Generate a continuation token using ListBuckets*
>  
>  {{LB_TOKEN=$(aws --endpoint-url "$ENDPOINT_URL" --no-verify-ssl s3api 
> list-buckets \  --max-buckets 5 \  --query ContinuationToken \  --output 
> text)echo "$LB_TOKEN"}}
> *Step 2: Pass the ListBuckets continuation token to ListDirectoryBuckets*
>  
>  {{aws --endpoint-url "$ENDPOINT_URL" --no-verify-ssl s3api 
> list-directory-buckets \  --continuation-token "$LB_TOKEN" \  
> --max-directory-buckets 5 \  --output json}}
> *Step 3: Verify the response*
> Observe whether the API accepts the token and returns directory bucket 
> entries along with another continuation token.
> *Step 4: Continue pagination*
> Use the newly generated continuation token in another 
> {{ListDirectoryBuckets}} request.
> h2. Actual Result
>  * {{ListDirectoryBuckets}} accepts the continuation token generated by 
> {{{}ListBuckets{}}}.
>  * The request completes successfully and returns 5 directory bucket entries.
>  * The response contains another continuation token.
>  * The subsequent request using the newly generated token also succeeds and 
> returns the next 5 directory bucket entries.
> h2. Expected Result
> If continuation tokens are required to be API-specific, 
> {{ListDirectoryBuckets}} should reject a token generated by {{ListBuckets}} 
> rather than interpreting it as a valid continuation token.
> h2. Impact
> Accepting continuation tokens generated by a different listing API may result 
> in unexpected pagination behavior if the APIs are expected to maintain 
> independent continuation-token handling.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to