Welcome to PathShield! This guide will help you get started with scanning your AWS environment for privilege escalation paths in just a few minutes.
PathShield is an AWS security scanner that discovers potential privilege escalation paths in your cloud infrastructure. It analyzes IAM relationships, cross-service interactions, and identifies attack vectors that could lead to unauthorized privilege escalation.
Before you begin, ensure you have:
- Python 3.9 or higher installed
- AWS CLI configured with credentials
- AWS Account with appropriate IAM permissions
- pip package manager
Check your Python version:
python3 --versionpip install pathshieldgit clone https://github.com/pathshield/pathshield.git
cd pathshield
pip install -e .docker pull pathshield/pathshield:latestEnsure your AWS credentials are configured. PathShield uses the standard AWS credential chain:
# Configure AWS CLI if not already done
aws configure
# Verify credentials
aws sts get-caller-identitypathshield scan --region us-east-1This will:
- Scan IAM users, roles, and groups
- Analyze EC2, Lambda, S3, and KMS resources
- Display results in your terminal with color-coded severity levels
pathshield scan --region us-east-1 --output json --output-file results.jsonpathshield scan --region us-east-1 --output html --output-file dashboard.htmlOpen dashboard.html in your browser to view an interactive report.
pathshield scan --region us-east-1 --verbosePathShield assigns severity levels to each detected escalation path:
- CRITICAL 🔴 - Direct path to admin privileges, immediate action required
- HIGH 🟡 - Significant escalation potential, should be addressed soon
- MEDIUM 🔵 - Moderate risk, review and remediate
- LOW 🟢 - Minor concern, consider fixing during maintenance
================================================================
PathShield - AWS Privilege Escalation Scanner
================================================================
IAM Graph Summary:
Total Principals: 45
Users: 12
Roles: 30
Groups: 3
Trust Relationships: 18
[!] Found 3 potential escalation paths:
[1] [CRITICAL]
Source: developer-user (user)
Target: admin-role (role)
Technique: PassRole + CreateFunction
Description: developer-user can create a Lambda function with privileged
role admin-role and then invoke it to execute code with
elevated privileges.
Path Length: 2 hops
Perform a comprehensive security audit of your AWS account:
pathshield scan \
--region us-east-1 \
--output html \
--output-file security-audit-$(date +%Y%m%d).html \
--verboseGenerate SARIF output for GitHub Advanced Security:
# In your CI/CD pipeline
pathshield scan \
--region us-east-1 \
--output sarif \
--output-file results.sarif
# Upload to GitHub (if using GitHub Actions)
# This will appear in the Security tabScan multiple AWS regions:
for region in us-east-1 us-west-2 eu-west-1; do
echo "Scanning $region..."
pathshield scan \
--region $region \
--output json \
--output-file results-$region.json
doneScan another AWS account by assuming a role:
# Create a config file
cat > config.yaml << EOF
aws:
profile: "default"
region: "us-east-1"
role_arn: "arn:aws:iam::123456789012:role/SecurityAuditRole"
session_duration: 3600
EOF
# Run scan with config
pathshield --config config.yaml scanCreate a config.yaml file:
aws:
profile: "default"
region: "us-east-1"
logging:
level: "INFO"
verbose: false
output:
format: "cli"
analysis:
services:
- ec2
- lambda
- s3
- kms
- iam
depth: 3Run with configuration:
pathshield --config config.yaml scanexport PATHSHIELD_AWS_PROFILE=production
export PATHSHIELD_AWS_REGION=us-east-1
export PATHSHIELD_LOGGING_LEVEL=DEBUG
pathshield scanPathShield requires read-only IAM permissions. Here's a minimal policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:GetUser",
"iam:GetRole",
"iam:GetGroup",
"iam:ListUsers",
"iam:ListRoles",
"iam:ListGroups",
"iam:ListAttachedUserPolicies",
"iam:ListAttachedRolePolicies",
"iam:GetPolicy",
"iam:GetPolicyVersion",
"ec2:DescribeInstances",
"lambda:ListFunctions",
"lambda:GetFunction",
"s3:ListAllMyBuckets",
"s3:GetBucketPolicy",
"kms:ListKeys",
"kms:DescribeKey"
],
"Resource": "*"
}
]
}docker run --rm -it \
-v ~/.aws:/root/.aws:ro \
pathshield/pathshield:latest \
scan --region us-east-1docker run --rm -it \
-v ~/.aws:/root/.aws:ro \
-v $(pwd)/results:/results \
pathshield/pathshield:latest \
scan --region us-east-1 --output json --output-file /results/scan.jsonCreate docker-compose.yml:
version: '3.8'
services:
pathshield:
image: pathshield/pathshield:latest
volumes:
- ~/.aws:/root/.aws:ro
- ./results:/results
command: scan --region us-east-1 --output json --output-file /results/scan.jsonRun:
docker-compose upSolution: Configure AWS credentials:
aws configure
# or
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secretSolution: Ensure your IAM user/role has the required read permissions. Check the IAM policy section above.
Solution: Explicitly specify the region:
pathshield scan --region us-east-1Or set default region:
export AWS_DEFAULT_REGION=us-east-1Solution:
- Reduce analysis depth:
pathshield scan --region us-east-1 --max-depth 2- Scan specific services only (create config.yaml):
analysis:
services:
- iam
- ec2Solution: Filter by severity in your analysis workflow, or use JSON output and process programmatically:
pathshield scan --region us-east-1 --output json --output-file results.json
# Then use jq to filter
jq '.escalation_paths[] | select(.severity == "critical")' results.jsonRun your first scans on a non-production AWS account to familiarize yourself with the tool.
Schedule regular scans (weekly/monthly) to track your security posture over time:
# Add to cron
0 2 * * 1 /usr/local/bin/pathshield scan --region us-east-1 --output json --output-file /var/log/pathshield/scan-$(date +\%Y\%m\%d).jsonAdd PathShield to your CI/CD pipeline to catch privilege escalation paths before they reach production.
- Focus on CRITICAL and HIGH severity issues first
- Document false positives
- Track remediation progress
When investigating a specific path, use verbose mode to see detailed information:
pathshield scan --region us-east-1 --verboseNow that you've completed your first scan, here's what to do next:
-
Review the Results
- Understand each detected escalation path
- Assess the risk in your specific context
-
Remediate Issues
- Start with CRITICAL severity paths
- Apply least-privilege principles
- Update IAM policies
-
Learn More
- Read the full README
- Check CONTRIBUTING.md to contribute
- Review SECURITY.md for security best practices
-
Automate
- Set up scheduled scans
- Integrate with your security monitoring
- Create dashboards for tracking
-
Get Help
- Open an issue on GitHub
- Check existing issues for solutions
- Join our community discussions
# Basic scan
pathshield scan --region us-east-1
# Show version
pathshield version
# Show current config
pathshield config
# Verbose scan with JSON output
pathshield scan --region us-east-1 --verbose --output json --output-file results.json
# Scan with custom config
pathshield --config myconfig.yaml scan
# HTML report
pathshield scan --region us-east-1 --output html --output-file report.html
# SARIF for CI/CD
pathshield scan --region us-east-1 --output sarif --output-file results.sarif| Format | Use Case | File Extension |
|---|---|---|
| cli | Terminal viewing | N/A |
| json | Programmatic processing | .json |
| sarif | CI/CD integration | .sarif |
| html | Dashboard/Reports | .html |
Here's a complete workflow from installation to remediation:
# 1. Install
pip install pathshield
# 2. Verify installation
pathshield version
# 3. Run initial scan
pathshield scan --region us-east-1 --output html --output-file initial-scan.html
# 4. Review results in browser
open initial-scan.html
# 5. Export for analysis
pathshield scan --region us-east-1 --output json --output-file analysis.json
# 6. After remediation, run another scan
pathshield scan --region us-east-1 --output html --output-file post-remediation.html
# 7. Compare results
# (Use your preferred diff tool or custom script)- Documentation: README.md
- Issues: GitHub Issues
- Security: SECURITY.md
- Contributing: CONTRIBUTING.md
Happy Scanning! 🛡️
Remember: PathShield is a tool to help identify potential privilege escalation paths. Always validate findings and apply fixes according to your organization's security policies.