T09 · Insecure Skill Coding Practices
- Location
upload.py:15- Finding
File uploads are transmitted over an unauthenticated plaintext connection
- Content
View full analysis
Vulnerability Details
File Location:
upload.py, lines 15-31; upload operations at lines 61-66 and 82-86
Vulnerability Type: Plaintext transport and unsigned storage requests
Risk Level: HighVulnerable Code
python BS3_ENDPOINT = os.getenv("BS3_ENDPOINT", "http://bs3-hb1.internal") BS3_BUCKET = os.getenv("BS3_BUCKET", "kim-mario-claw") BS3_REGION = os.getenv("BS3_REGION", "hb1") from botocore.session import Session botocore_session = Session() botocore_session.set_config_variable("region", BS3_REGION) client = botocore_session.create_client( "s3", endpoint_url=BS3_ENDPOINT, config=Config(signature_version=UNSIGNED), use_ssl=False, )The resulting client uploads file contents directly to the configured bucket:
python with open(file_path, "rb") as data: client.put_object( Body=data, Bucket=BS3_BUCKET, Key=obj_key )python client.put_object( Body=data, Bucket=BS3_BUCKET, Key=obj_key )Technical Analysis
The default storage endpoint uses HTTP rather than HTTPS. The S3-compatible client also explicitly disables SSL and selects
UNSIGNEDas the request signature version. Consequently, neither transport encryption nor request-level authentication protects uploaded content.An attacker with access to a relevant network segment could passively inspect uploaded files or actively modify HTTP traffic. Because requests are unsigned, any party that can reach an endpoint configured to allow these operations may also attempt to submit arbitrary
PutObjectrequests without possessing storage credentials.The
BS3_ENDPOINT, bucket, and region values can also be overridden through environment variables. If an attacker controls the process environment, uploaded data could be redirected to an attacker-controlled S3-compatible endpoint. The principal confirmed weakness remains the insecure p ...[truncated 1443 chars]- Remediation
View remediation
Remediation Suggestions
- Replace the default endpoint with an HTTPS endpoint and set
use_ssl=True. - Require valid certificate verification and do not suppress TLS validation.
- Remove
Config(signature_version=UNSIGNED)and use authenticated, short-lived credentials. - Assign a dedicated identity with permission to upload only to a narrowly scoped bucket prefix.
- Configure the bucket policy to reject anonymous requests and requests not transported over TLS.
- Apply server-side upload size limits, content-type controls, quotas, malware scanning, and lifecycle rules.
- Protect environment configuration so untrusted callers cannot redirect
BS3_ENDPOINTor change the destination bucket. - Consider validating the configured endpoint against an approved allowlist before sending data.
- Log upload identities and object destinations while avoiding disclosure of confidential file contents.
- Review existing bucket access policies and remove any unnecessary anonymous read or write access.
- Replace the default endpoint with an HTTPS endpoint and set
