added info to aws and did some linting
This commit is contained in:
parent
611827f4b1
commit
f2de7845c0
|
@ -1,21 +1,34 @@
|
||||||
# AWS S3 Enumeration
|
# AWS S3 Enumeration
|
||||||
|
|
||||||
## Usage
|
## Regions
|
||||||
|
|
||||||
* [Regions](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-segions)
|
[A list of services by region](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/) is maintained by AWS
|
||||||
* `--region`
|
There are global and regional services.
|
||||||
|
|
||||||
### Simple Storage Service (S3)
|
Watch out for the global and regional __Security Token Service__ (STS) which
|
||||||
* [S3](https://aws.amazon.com/s3/)
|
provides temporary access to third party identities, since regional STS are
|
||||||
* Methods of access control are as follows
|
also valid in other regions. Global STS are only valid in default regions.
|
||||||
* [Bucket policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)
|
|
||||||
* [S3 ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/managing-acls.html)
|
In aws cli, [Regions](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-segions) go the cli argument `--region`
|
||||||
|
|
||||||
|
## Simple Storage Service (S3)
|
||||||
|
|
||||||
|
[S3](https://aws.amazon.com/s3/) is an object storage without volume limits.
|
||||||
|
The names of buckets are unique and the namespace of buckets is global but they
|
||||||
|
are stored regionally.
|
||||||
|
|
||||||
|
Methods of access control are as follows
|
||||||
|
1. [Bucket policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)
|
||||||
|
2. [S3 ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/managing-acls.html)
|
||||||
|
|
||||||
|
The aws cli scheme is
|
||||||
|
|
||||||
* Scheme is
|
|
||||||
```sh
|
```sh
|
||||||
http://<bucketname>.s3.amazonaws.com/file.name
|
http://<bucketname>.s3.amazonaws.com/file.name
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
http://s3.amazonaws.com/BUCKETNAME/FILENAME.ext
|
http://s3.amazonaws.com/BUCKETNAME/FILENAME.ext
|
||||||
```
|
```
|
||||||
|
@ -24,55 +37,107 @@ http://s3.amazonaws.com/BUCKETNAME/FILENAME.ext
|
||||||
```sh
|
```sh
|
||||||
aws s3 ls s3://<bucketname>/ --no-sign-request
|
aws s3 ls s3://<bucketname>/ --no-sign-request
|
||||||
```
|
```
|
||||||
* Download via `curl`, `wget` or `s3` cli via
|
|
||||||
|
Download via `curl`, `wget` or `s3` cli via
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
aws s3 cp s3://<bucketname>/foo_public.xml . --no-sign-request
|
aws s3 cp s3://<bucketname>/foo_public.xml . --no-sign-request
|
||||||
```
|
```
|
||||||
|
|
||||||
#### ACL
|
### ACL
|
||||||
|
|
||||||
|
If the ACL is set to
|
||||||
|
|
||||||
* `Anyone`, just `curl`
|
* `Anyone`, just `curl`
|
||||||
* `AuthenticatedUsers`, `s3` cli with aws key
|
* `AuthenticatedUsers`, `s3` cli with aws key
|
||||||
|
|
||||||
## IAM
|
## IAM
|
||||||
|
|
||||||
* Not necessarily used by s3
|
Permissions are granted directly through user accounts or indirectly through
|
||||||
* Access key ID, starts with `AKIA` + 20 chars
|
roles the user has joined.
|
||||||
* Secret access key
|
![users and groups](./include/iam-intro-users-and-groups.diagram.png)
|
||||||
* Session token, `ASIA` + sessionToken
|
|
||||||
|
Gaining access to important roles like maintenance opens the door to higher permissions.
|
||||||
|
An always unique AWS Account ID has a length of 12 digits.
|
||||||
|
|
||||||
|
The IAM is not necessarily used by S3. AK/SK is sufficient for authentication
|
||||||
|
and authorization.
|
||||||
|
|
||||||
|
* Access key ID, starts with `AKIA` + 20 chars
|
||||||
|
* Secret access key (SK)
|
||||||
|
* Session token, `ASIA` + sessionToken
|
||||||
|
* AWS Organizations control accounts who joined
|
||||||
|
* Third party identity providers are supported
|
||||||
|
* IAM identity center of an organization allows provision of accounts from third parties through the AWS SSO
|
||||||
|
|
||||||
|
### Root Accounts
|
||||||
|
|
||||||
|
Every AWS account has a single root account bound to an email address. This
|
||||||
|
account has got the all privileges over the account. A root account has MFA
|
||||||
|
disabled by default.
|
||||||
|
|
||||||
|
The account is susceptible to an attack if the mail address is accessible but
|
||||||
|
MFA is not activated.
|
||||||
|
|
||||||
|
If the MFA is not set, it is an opportunity for a password reset attack when
|
||||||
|
the account the vulnerable root belongs to is part of an AWS Organization.
|
||||||
|
|
||||||
|
### User Policies
|
||||||
|
|
||||||
|
After authentication of a user (or principal) policies of the account are
|
||||||
|
checked if the request is allowed.
|
||||||
|
Policy evaluation can be found in the [AWS docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html).
|
||||||
|
The following graph is taken from the documentation, it shows the evaluation
|
||||||
|
logic inside an account
|
||||||
|
![policy evaluation](./include/PolicyEvaluationHorizontal111621.pnhttps://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-login.htmlg)
|
||||||
|
|
||||||
|
Policies like `assume-role` and `switch-role` can lead to the gain of roles
|
||||||
|
with higher permissions
|
||||||
|
|
||||||
|
### User Provisioning
|
||||||
|
|
||||||
|
When using the cli command, the aws configuration and credentials are stored at `~/.aws`
|
||||||
|
|
||||||
|
Add credentials to profile via
|
||||||
|
|
||||||
* Add credentials to profile via
|
|
||||||
```sh
|
```sh
|
||||||
aws configure --profile PROFILENAME
|
aws configure --profile PROFILENAME
|
||||||
```
|
```
|
||||||
* Config and credentials is stored at `~/.aws`
|
|
||||||
* Sanity test profile via
|
Sanity test a profile through checking its existance via
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
aws s3 ls --profile PROFILENAME
|
aws s3 ls --profile PROFILENAME
|
||||||
```
|
```
|
||||||
* Find account ID to an access key
|
|
||||||
|
Find account ID to an access key
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
aws sts get-access-key-info --access-key-id AKIAEXAMPLE
|
aws sts get-access-key-info --access-key-id AKIAEXAMPLE
|
||||||
```
|
```
|
||||||
* Find username to an access key
|
|
||||||
|
Find username to an access key
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
aws sts get-caller-identity --profile PROFILENAME
|
aws sts get-caller-identity --profile PROFILENAME
|
||||||
```
|
```
|
||||||
* Listing EC2 instances of an account
|
|
||||||
|
Listing EC2 instances of an account
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
aws ec2 describe-instances --output text --profile PROFILENAME
|
aws ec2 describe-instances --output text --profile PROFILENAME
|
||||||
```
|
```
|
||||||
* aws ec2 describe-instances --output text --profile PROFILENAME
|
|
||||||
```sh
|
In another region
|
||||||
aws ec2 describe-instances --output text --profile PROFILENAME
|
|
||||||
```
|
|
||||||
* In another region
|
|
||||||
```sh
|
```sh
|
||||||
aws ec2 describe-instances --output text --region us-east-1 --profile PROFILENAME
|
aws ec2 describe-instances --output text --region us-east-1 --profile PROFILENAME
|
||||||
```
|
```
|
||||||
|
|
||||||
### AWS ARN
|
### AWS ARN
|
||||||
* Unique ID is create via the following scheme
|
|
||||||
|
Unique ID is create through the following scheme
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
arn:aws:<service>:<region>:<account_id>:<resource_type>/<resource_name>
|
arn:aws:<service>:<region>:<account_id>:<resource_type>/<resource_name>
|
||||||
```
|
```
|
||||||
|
@ -87,8 +152,8 @@ ws secretsmanager get-secret-value --secret-id <Name> --region <region>
|
||||||
|
|
||||||
## Check Permissions on S3 Bucket
|
## Check Permissions on S3 Bucket
|
||||||
|
|
||||||
* Do a `PUT` method to see if the bucket may be writeable to upload a file via
|
Do a `PUT` method to see if the bucket may be writeable to upload a file via
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -vvv -X PUT $BUCKET_URL --data "Test of write permissions"
|
curl -vvv -X PUT $BUCKET_URL --data "Test of write permissions"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 151 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue