Scan and classify cross-account roles and resources in your AWS Account
Project description
AWS External Account Scanner
Xenos, is Greek for stranger.
AWSXenos will assess the trust relationships in all the IAM roles, and resource policies for several AWS services in an AWS account and give you a breakdown of all the accounts that have trust relationships to your account. It will also highlight whether the trusts have an external ID or not.
https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html
This tool reports against the Trusted Relationship Technique and parts of the Valid Accounts: Cloud Accounts of the ATT&CK Framework.
- For the "known" accounts list AWSXenos uses a modified version of known AWS Accounts.
- For the Org accounts list, AWSXenos will query AWS Organizations.
- AWS Services are classified separately.
- Everything else falls under unknown account
- For regional services, e.g. KMS, you'll need to run AWSXenos per region.
- You can configure which services you'd like to assess by providing a config.yaml file.
Example
Why
Access Analyzer falls short because:
-
You need to enable it in every region.
-
Identified external entities might be known entities. E.g. a trusted third party vendor or a vendor you no longer trust. An Account number is seldom useful.
-
Zone of trust is a fixed set of the AWS organisation. You won’t know if a trust between sandbox->prod has been established.
-
Does not identify AWS Service principals. This is mainly important because of Wiz's AWSConfig, et al vulnverabilities
AWS IAM Access Analyzer comparison
Comparison based on AWS Documentation 1 and 2, including services or resources outside of docs, e.g. VPC endpoints.
Service | AWSXenos | Access Analyzer |
---|---|---|
S3 Bucket | :white_check_mark: | :white_check_mark: |
S3 Directory Buckets | :x: | :white_check_mark: |
S3 Access Points | :x: | :white_check_mark: |
S3 Bucket ACLs | :white_check_mark: | :white_check_mark: |
S3 Glacier | :white_check_mark: | :x: |
IAM | :white_check_mark: | :white_check_mark: |
KMS | :white_check_mark: | :white_check_mark: |
Secrets Manager | :white_check_mark: | :white_check_mark: |
Lambda | :white_check_mark: | :white_check_mark: |
SNS | :white_check_mark: | :white_check_mark: |
SQS | :white_check_mark: | :white_check_mark: |
RDS Snapshots | :x: | :white_check_mark: |
RDS Cluster Snapshots | :x: | :white_check_mark: |
ECR | :x: | :white_check_mark: |
EFS | :white_check_mark: | :white_check_mark: |
DynamoDB streams | :white_check_mark: | :white_check_mark: |
DynamoDB tables | :white_check_mark: | :white_check_mark: |
EBS Snapshots | :x: | :white_check_mark: |
EventBridge | :white_check_mark: | :x: |
EventBridge Schema | :x: | :x: |
Mediastore | :x: | :x: |
Glue | :x: | :x: |
Kinesis Data Streams | :white_check_mark: | :x: |
Lex v2 | :x: | :x: |
Migration Hub Orchestrator | :x: | :x: |
OpenSearch | :white_check_mark: | :x: |
AWS PCA | :x: | :x: |
Redshift Serverless | :x: | :x: |
Serverless Application Repository | :x: | :x: |
SES v2 | :x: | :x: |
Incident Manager | :x: | :x: |
Incident Manager Contacts | :x: | :x: |
VPC endpoints | :white_check_mark: | :x: |
How to run
Cli
pip install AWSXenos
awsxenos --reporttype HTML -w report.html
awsxenos --reporttype JSON -w report.json
You will get an HTML and JSON report.
See example report
You can configure the services you care about by using your own config.
Library
from awsxenos.scan import PreScan
from awsxenos.report import Report
from awsxenos.s3 import S3
#from awsxenos.iam import IAM
# To run everything based on your config.
prescan = PreScan()
results = load_and_run(config_path, prescan.accounts)
r = Report(results, prescan.known_accounts)
# Per service
prescan = PreScan()
aws_service = S3()
findings = aws_service.fetch(prescan.accounts)
r = Report(s.findings, s.known_accounts)
json_summary = r.JSON_report()
html_summary = r.HTML_report()
IAM Permissions
Permissions required to scan all services.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"dynamodb:GetResourcePolicy",
"dynamodb:ListStreams",
"dynamodb:ListTables",
"ec2:DescribeVpcEndpoints",
"elasticfilesystem:DescribeFileSystemPolicy",
"elasticfilesystem:DescribeFileSystems",
"es:DescribeDomains",
"es:ListDomainNames",
"events:ListEventBuses",
"glacier:GetVaultAccessPolicy",
"glacier:ListVaults",
"iam:ListRoles",
"kinesis:GetResourcePolicy",
"kinesis:ListStreams",
"kms:GetKeyPolicy",
"kms:ListKeys",
"lambda:GetPolicy",
"lambda:ListFunctions",
"organizations:DescribeOrganization",
"organizations:ListAccounts",
"s3:GetBucketAcl",
"s3:GetBucketPolicy",
"s3:ListAllMyBuckets",
"secretsmanager:GetResourcePolicy",
"secretsmanager:ListSecrets",
"sns:GetTopicAttributes",
"sns:ListTopics",
"sqs:GetQueueAttributes",
"sqs:ListQueues"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
Development
python3 -m env venv
source /env/bin/activate
pip install -r requirements.txt
- Create a file with the name of the service.
- Create a class with the name of the resource that you want from that service
- Your class must inherit from
Service
and returnFindings
Example:
class S3(Service):
def fetch(self, accounts: Accounts ) -> Findings:
self._buckets = self.list_account_buckets()
self.policies = self.get_bucket_policies()
return super().collate(accounts, self.policies)
- Add your filename and class to the config
FAQ
Are there false positives?
Yes. AWSXenos doesn't take into consideration Identity or SCP. It assumes that everything else other than the resource or trust policy has access.
Is this using an SMT Solver or automated reasoning ?
No. AWSXenos only takes into account resource and IAM trust policies. Maybe in the next project or iteration.
Why not use CheckAccessNotGranted ?
We don't know the set of accounts that shouldn't access the resource or role.
How does it work ?
AWSXenos currently assesses access based on https://github.com/Netflix-Skunkworks/policyuniverse.
Features
- Use as library
- HTML and JSON output
- Multi-threaded querying of each service
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file awsxenos-0.4.0.tar.gz
.
File metadata
- Download URL: awsxenos-0.4.0.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7daeabc647ff87fe500b617176d25d95b688ce1db0e9a8408a1d20a263deeea1 |
|
MD5 | cf1e9cdd0f1d9bbc927837a34728fe41 |
|
BLAKE2b-256 | 7f347b6f4c0ee1619b95bd8e8ab562ecf737b71d7efe0f167694ae2a2ab6e72e |
File details
Details for the file AWSXenos-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: AWSXenos-0.4.0-py3-none-any.whl
- Upload date:
- Size: 36.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82cdee28b624fae591c5f81ba476085140f20056404f6fb71e6ef2de3bd6422d |
|
MD5 | 87fa9faf7bf34da7cc53155618bd650a |
|
BLAKE2b-256 | fa984b081ca4b62a69104291a1e99643f9454040f940cb44d695a91bdd1f2609 |