AWS S3 Policy Deny ListObjectVersions - amazon-web-services

I am using Wasabi. I have an s3 bucket with versioning enabled. I want to be able to list all the objects that are not deleted. My bucket contains the following objects:
a.txt
b.txt
c.txt
c.txt has been deleted.
I am accessing my s3 bucket with an IAM that follows the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::MyBucket"
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::MyBucket/*"
}
]
}
If I list the object (aws s3 ls s3://my-bucket) it returns all the objects, included the deleted one (its latest version).
To prevent deleted objects from being listed, I tried to deny s3:ListBucketVersions on the root bucket and all objects but it did not work.
How can I make the policy to prevent the user from listing previous versions / deleted objects?
Edit: I am using Wasabi I just noticed that this behaviour is inconsistent with AWS S3 behaviour. I guess its on their side now.

Related

AWS account A->B->C S3 bucket policy access

In AWS Account B i have S3 bucket with the following bucket policy:
allow to put from Account A (working fine)
allow to list from Account C (working fine)
allow to get object from Account C (not working fine)
The policy is the following:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "ACCOUNT_A"
},
"Action": "s3:PutObject",
"Resource": "MYBUCKET/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "ACCOUNT_A"
},
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "MYBUCKET"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "ACCOUNT_C"
},
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:GetBucketLocation"
],
"Resource": [
"MYBUCKET/*",
"MYBUCKET"
]
}
]
}
Why from AWS Account C i can List but not GetObject ? (i do suspect it's because of the ownership: it's Account A who is the owner, but how to fix it)
Thanks,
If objects are upload to an Amazon S3 bucket from a different AWS Account, then the 'ownership' of the object will remain with the account that uploaded the object. This can be rather frustrating because the owner of the bucket can't even access the object!
There are two ways to avoid this...
Assign ownership
When uploading the object specify an Access Control List (ACL) that assigns ownership to the owner of hte bucket:
ACL='bucket-owner-full-control'
Turn off ACLs
You could Disable ACLs for your bucket - Amazon Simple Storage Service, which avoids the whole problem. In fact, this should probably be the default option for all buckets.

S3 policy to perform move action

Which permission needed to perform move action on objects within the same S3 bucket?
To clarify, we have a bucket named BCK and two folders inside named DIR1 & DIR2. An IAM user needs to move objects within DIR1 to DIR2 and when they perform the action from the management console management they get the an error "access denied".
The only policy attached to the user is:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket",
"s3:ListBucketVersions"
],
"Resource": [
"arn:aws:s3:::BCK/*",
"arn:aws:s3:::BCK"
]
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:HeadBucket"
],
"Resource": "*"
}
]
}
There is no "move" command in Amazon S3. Instead, it requires a combination of CopyObject and DeleteObject. You have already provided these permissions.
The Amazon S3 management console also performs additional steps during the copy operation, such as viewing/setting permissions on each object. Therefore, add these permissions:
s3:GetObjectAcl
s3:PutObjectAcl

Amazon S3 Delete Object Policy Not working

we are using Amazon S3 services and bucket for storing our data, now I have a problem, everything is working, but I want to restrict Delete object permissions only on few tables inside bucket, somehow this is not working:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1448899531000",
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:Put*",
"s3:List*"
],
"Resource": [
"*"
]
},
{
"Sid": "Stmt1461061827000",
"Effect": "Allow",
"Action": [
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::cf-templates-11e3g59cf34bh-eu-west-1/report_file_html/*",
"arn:aws:s3:::cf-templates-11e3g59cf34bh-eu-west-1/market_intelligence_result_sets/*"
]
}
]
}
I checked the ARN for bucket and it is "arn:aws:s3:::cf-templates-11e3g59cf34bh-eu-west-1" as excpected, market_intelligence and report_file_html tables also exist in the bucket, so I want to limit delete object action only to these tables,but from my PHP app, I get 403 error, permission denied to delete an object.
Using Amazon IAM Policy Validator, these rules validates successfully, but then using aws CLI, I get access denied error when calling DeleteObject.

Grant access to only one bucket in S3

I´m trying to write a policy to grant a specific user access to only one bucket
this is what I have so far:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::MYBUCKET",
"arn:aws:s3:::MYBUCKET/*"
]
}
]
}
I don´t want this user to list all other buckets
so I changed
"Resource": "arn:aws:s3:::*" to "Resource": "arn:aws:s3:::MYBUCKET"
but it didn´t work. I don´t need this user to access the console just programmatically is fine. thank you!!
It is not possible to limit the results of the ListAllMyBuckets command. Either they see the list of all the buckets, or they see none at all.
If they know which bucket they wish to use, then you could simply remove permission to list buckets. They will still be able to list the contents of MYBUCKET and upload/download objects. They just won't be able to request a list of buckets. (And the S3 Management Console won't function because it expects to be able to list all buckets in the account)

Renaming object from in aws s3 console, with IAM user

Created an IAM user, with S3 full access (S3:*) on a specific ARN (only one bucket). Upload and delete works, but not able to rename or copy/paste.
Here is my IAM policy.
{
"Sid": "Stmt1490288788",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
}
I don't know if this is the correct solution, but giving ListAllMyBuckets permission worked for me.
I just added another statement along with the previous one.
{
"Sid": "Stmt1490288788",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
}{
"Sid": "Stmt1490289746001",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": [
"arn:aws:s3:::*"
]
}
So this policy lists all the buckets, but only allow put/delete/get access to the specific bucket. Still wondering what's the relation between rename/copy & list all bucket permissions.
While there isn't actually rename functionality in S3 itself, some interfaces may try and implement it by using S3 PUT object copy and DELETE actions behind the scenes. Their implementation may require other bucket-level permissions to complete, which is why it may be failing with your policy. Try this:
{
"Sid": "Stmt1490288788",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::bucket-name",
"arn:aws:s3:::bucket-name/*"
]
}
The difference being this grants permissions to actions performed on the bucket itself (the first resource declared), as well as the objects in the bucket (the second resource declared).