T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/oss_traffic_forensics.py:1208- Finding
Automatic Account-Wide Bucket Enumeration Exceeds Least Privilege
- Content
View full analysis
Vulnerability Details
File Location:
scripts/oss_traffic_forensics.py:1208-1236
Vulnerability Type: Excessive read permissions and unnecessary account-wide 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-security-incident-forensics"), "bucket": "", "buckets_in_account": _hint, "errors": _herrs, "auto_filled": [], } _na = ("Ask the user which OSS bucket the issue concerns; " "buckets_in_account lists up to 30 buckets visible to the " "current credential.") if not _hint: _na += (" No bucket is listable with the current credential: ask " "for the exact bucket name and its region instead.") return _emit(_rep, "FAIL", _na)The enumeration implementation is located at
scripts/_oss_client.py:600-632:python def list_buckets(prefix: str = "", timeout: int = _DEFAULT_TIMEOUT, endpoint: str = "oss-cn-hangzhou.aliyuncs.com", max_buckets: int = 200) -> list: """Call OSS ListBuckets (read-only) to locate buckets of this account. Used as the fallback path when GetBucketInfo cannot resolve the region (wr ...[truncated 3683 chars]- Remediation
View remediation
Remediation Suggestions
- Remove automatic
ListBucketsinvocation when--bucketis absent. Return a failure that asks for the exact bucket name and, if necessary, its region. - Make account-wide discovery an explicit, separately authorized opt-in operation rather than an implicit fallback.
- Remove
oss:ListBucketsfrom the default minimal policy. Provide it only through a separate discovery policy when the operator has explicitly requested enumeration. - Scope bucket configuration actions to the affected bucket ARN wherever the Alibaba Cloud action supports resource-level restrictions.
- Scope SLS access to the derived OSS log project and logstore rather than using
Resource: "*", wherever supported. - If a region fallback remains necessary, require the user to supply the expected region or obtain it through a narrowly scoped mechanism that does not enumerate the full account.
- Avoid including account inventory in normal report output. If explicitly requested, minimize returned fields and apply output redaction and access controls.
- Add tests asserting that execution without
--bucketperforms no cloud API calls and returns only a request for the missing target.
- Remove automatic
