T09 · Insecure Skill Coding Practices
- Location
scripts/oss_quota_diagnosis.py:610- Finding
Credentialed OSS Requests Can Be Redirected to an Arbitrary Host
- Content
View full analysis
"_RetryingHandle": """Build an oss2.Bucket handle carrying UA + per-call timeout. ... """ auth = oss2.ProviderAuth(EnvCredentialsProvider()) session = oss2.Session() # Inject the observability User-Agent into every SDK request of this run. session.session.headers["User-Agent"] = user_agent() try: return _RetryingHandle( oss2.Bucket(auth, endpoint, bucket_name, session=session, connect_timeout=timeout), bucket_name, endpoint) ``` ### Technical Analysis The `--endpoint` argument is accepted as an arbitrary string. Normalization only removes a trailing slash and an optional `http://` or `https://` prefix. It does not verify that the resulting hostname belongs to Alibaba Cloud, matches an OSS endpoint format, uses an approved region, lacks a custom port, or resolves to a trusted address. T ...[truncated 2623 chars]- Remediation
View remediation
.aliyuncs.com` pattern. - Rejection of malformed labels, suffix confusion, and domains such as `aliyuncs.com.attacker.example`. 4. Do not silently strip `http://`; reject non-HTTPS input explicitly. 5. Disable redirects for authenticated requests, or validate every redirect destination before forwarding authentication headers or security tokens. 6. Add tests proving that attacker-controlled hosts, IP addresses, custom ports, internal addresses, and suffix-confusion domains are rejected before credentials are loaded or a request is issued. 7. Prefer short-lived, narrowly scoped STS credentials so that any accidental disclosure has limited duration and impact. ]]>
