4

找出任意 S3 bucket 對應的 AWS Account ID

 6 months ago
source link: https://blog.gslin.org/archives/2024/02/27/11680/%e6%89%be%e5%87%ba%e4%bb%bb%e6%84%8f-s3-bucket-%e5%b0%8d%e6%87%89%e7%9a%84-aws-account-id/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

找出任意 S3 bucket 對應的 AWS Account ID

Hacker News 上看到「How to find the AWS account ID of any S3 bucket (tracebit.com)」這篇,作者利用不同的額外條件,讓 S3 bucket 產生不同的 response,進而取得 AWS 的 Account ID。

首先是先確定 S3 bucket 在哪一區,這個部分比較簡單,即使是 denied response 也會附上 x-amz-bucket-region 這個資訊。

接下來是在對應的區域建立 VPC 以及 VPC Endpoint for S3,接著準備一台 EC2 instance 確認是否透過 VPC Endpoint for S3 存取 Amazon S3 的資料。

接下來的重點就在「Modify the VPC Endpoint policy to determine whether the account ID of the target bucket starts with "0"」這段了,建立一個 policy,限制只能存取 Account ID 是 0* 的 S3 bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": "s3:*",
            "Effect": "Allow",
            "Resource": "*",
            "Principal": "*",
            "Condition": {
                "StringLike": {
                    "s3:ResourceAccount": "0*"
                }
            }
        }
    ]
}

然後發 request 去要檔案,理論上在 command line 這邊都會收到 denied 的訊息,但在 CloudTrail 裡面會有兩種不同的情境,如果 CloudTrail 裡面有這筆記錄,表示 Account ID 是 0*;如果沒有的話,表示 Account ID 不是 0*

If we find our request in CloudTrail, it means that the VPC Endpoint policy permitted the request - i.e. the Account ID of the bucket starts with 0. If we don't find the request, then the VPC Endpoint policy blocked the request - i.e. the Account ID of the bucket does not start with 0.

有了這個破口後,後續的事情就可以自動化了,平行測試以及二分搜尋法拿出來用就可以加速進行。

而 AWS 的 Account ID 雖然不是敏感資訊,但能挖出來還是頗... 有趣的?

Related

Amazon VPC 的 Private Subnet 不需要透過 NAT 去 Amazon S3 抓資料了

在今天之前,Amazon VPC 裡 Private Subnet 的機器需要透過 NAT 才能連到 Amazon S3 的 Endpoint API 上操作:(NAT instance 會放在 Public Subnet 裡) 出自「NAT Instances」的說明。 但在這個架構中,如果 NAT instance 不夠大台,甚至是流量需求超過 10Gbps 時就會有效能瓶頸了。而目前沒有比較簡單的方法可以解決。(一種解法是拆多個 subnet 跑,透過多個不同的 NAT instance 連出去,但這樣架構又變複雜了) 今天則是公佈了讓內部可以直接存取 Amazon S3 的方式:「New – VPC Endpoint for Amazon S3」。第一波是美國 (扣除美國政府用的區域)、歐洲、亞洲、澳洲。所以是巴西與美國政府兩個區域還沒上: Amazon VPC Endpoints for Amazon S3 are…

May 12, 2015

In "AWS"

開 S3 bucket 與 IAM 帳號的工具

看到 Simon Willison 的「s3-credentials: a tool for creating credentials for S3 buckets」這篇,裡面講到了幾件事情。 在 AWS 上比較好的安全設計是,不同專案之間都有自己的 S3 bucket,然後建立對應的 IAM user,每個 IAM user 只能存取自己的 S3 bucket。 但這個建立過程很煩: Creating those credentials is surprisingly difficult! 整個建立的過程包括了四個步驟: 建立 S3 bucket。 建立 IAM user。 將 IAM user 掛上對應的 S3 權限。 建立 IAM user 的 access key。…

November 6, 2021

In "AWS"

Amazon S3 開放 IPv6 存取

開放 IPv6 存取 Amazon S3 了:「Now Available – IPv6 Support for Amazon S3」。 對應的 Endpoint 是 http://BUCKET.s3.dualstack.REGION.amazonaws.com 與 http://s3.dualstack.REGION.amazonaws.com/BUCKET。 值得注意的是所有功能都開放 IPv6 了,包括 BitTorrent (還記得嗎 XDDD 如果忘記的,可以參考「Using BitTorrent with Amazon S3 這篇的說明」): S3 Feature Support – IPv6 support is available for all S3 features with the exception of Website Hosting, S3…

August 12, 2016

In "AWS"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on February 27, 2024Categories API, AWS, Cloud, Computer, Murmuring, Network, Security, ServiceTags account, amazon, api, aws, bucket, cloud, cloudtrail, data, endpoint, id, log, policy, s3, security, service, vpc

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK