T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/oss_cross_account_auth_diagnosis.py:1343- Finding
Account-wide bucket enumeration occurs when the required bucket name is absent
- Content
View full analysis
Vulnerability Details
File Location:
scripts/oss_cross_account_auth_diagnosis.py:1343-1364
Vulnerability Type: Excessive cloud-resource enumeration
Risk Level: MediumVulnerable Code
python # Missing-bucket guard: most real tickets never name a bucket, so a bare # argparse exit 2 leaves the customer with no next step. Ask for the name # and surface the buckets this credential can actually see. if not (args.bucket or "").strip(): _hint = [] _herrs = [] try: try: _all = _oss_client.list_buckets() except TypeError: _all = _oss_client.list_buckets(prefix="") _hint = [b["name"] for b in _all][:30] except Exception as e: _herrs.append({"category": "degraded", "code": "ListBucketsFailed", "message": str(e)[:200]}) print(f"[WARN] ListBuckets bucket-name hint degraded: {e}", file=sys.stderr) _rep = { "skill": globals().get("_SKILL_NAME", "alibabacloud-oss-cross-account-auth-diagnosis"), "bucket": "", "buckets_in_account": _hint, "errors": _herrs, "auto_filled": [], }The corresponding policy in
references/ram-policies.mdgrantsoss:ListBucketson"Resource": "*", allowing account-wide enumeration.Technical Analysis
A missing required input does not require access to cloud inventory. The least-privilege response would be to request the exact bucket name and optionally its region. Instead, the script calls
ListBuckets, retrieves account-wide bucket metadata, and includes up to 30 bucket names in the generated report.Bucket names can disclose customer identifiers, project names, deployment environments, internal naming conventions, and other operational information. This also makes
oss:ListBucketspart of the recommended core permission set even though a targeted diagnosis can ordinarily operate ...[truncated 977 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the
ListBucketscall from the missing---bucketbranch. - Return
STATUS: FAILand ask the user for the exact bucket name and region. - Make
oss:ListBucketsan optional permission rather than one of the four core permissions. - Require an explicit option such as
--discover-bucketbefore performing account-wide enumeration. - Clearly warn that discovery returns account inventory before making the request.
- Do not include unrelated bucket names in Agent-visible reports.
- Where possible, scope normal operation to
oss:GetBucketInfoandoss:GetBucketPolicyfor the explicitly named bucket.
- Remove the
