T09 · Insecure Skill Coding Practices
- Location
scripts/gradient_spaces.py:30- Finding
Unvalidated S3 Endpoint Can Redirect Documents and Signed Credential Material
- Content
View full analysis
- Remediation
View remediation
str: parsed = urlparse(endpoint) hostname = (parsed.hostname or "").lower() if parsed.scheme != "https": raise ValueError("The Spaces endpoint must use HTTPS.") if not ( hostname == "digitaloceanspaces.com" or hostname.endswith(".digitaloceanspaces.com") ): raise ValueError("Only DigitalOcean Spaces endpoints are allowed.") if parsed.username or parsed.password or parsed.query or parsed.fragment: raise ValueError("Invalid Spaces endpoint.") return endpoint ``` 2. Apply validation before creating the boto3 client: ```python endpoint = validate_spaces_endpoint(endpoint) ``` 3. If non-DigitalOcean S3 services must be supported, make that an explicitly documented opt-in mode and require separate credentials rather than reusing DigitalOcean Spaces credentials. 4. Reject plaintext HTTP endpoints and retain TLS certificate verification. 5. Use dedicated, minimally scoped Spaces credentials limited to the required bucket and operations. 6. Update the trust statement to accurately document any supported configurable destinations. ]]>
