Skip to content

fix(gapic-common): reject non-https scheme downgrades on https endpoints - #107

Draft
quartzmo wants to merge 1 commit into
googleapis:mainfrom
quartzmo:fix/b593062793-http-downgrade
Draft

quartzmo wants to merge 1 commit into
googleapis:mainfrom
quartzmo:fix/b593062793-http-downgrade

Conversation

@quartzmo

@quartzmo quartzmo commented Dec 4, 2026

Copy link
Copy Markdown
Member

Prevent Gapic::Rest::ClientStub and Gapic::ResumableUpload from sending requests or accepting resumable upload session URLs with http:// or other non-https schemes when the client stub endpoint uses https://.

  • Add internal Gapic::Rest::UriValidation helper to validate request URIs (allowing relative RPC paths including AIP custom methods while rejecting non-https, protocol-relative, authority-less https, whitespace/control-character, and invalid-encoding URIs) and absolute https:// upload URLs, normalizing uppercase HTTPS:// scheme prefixes to lowercase https://.
  • Update Gapic::Rest::ClientStub#initialize to normalize endpoint schemes case-insensitively and cache @https_endpoint after yielding @connection; enforce scheme validation in base_make_http_request.
  • Update Gapic::ResumableUpload#start and #resume to validate initial_url and ResumeHandle#upload_url before replacing @driver, and pass require_https to StartUploadConfig so Rules rejects non-https X-Goog-Upload-URL headers immediately with a non-resumable BadResponseError ("Upload URL must be a valid https URL").
  • Add unit tests across UriValidation, ClientStub, Rules, and ResumableUpload covering downgrade vectors, resumable? state, permissive retry_predicate non-retry, AIP relative paths, UTF-8 paths, cross-host https://, and http:// emulators.

b/593062793

Prevent Gapic::Rest::ClientStub and Gapic::ResumableUpload from sending
requests or accepting resumable upload session URLs with http:// or
other non-https schemes when the client stub endpoint uses https://.

- Add internal Gapic::Rest::UriValidation helper to validate request
  URIs (allowing relative RPC paths including AIP custom methods while
  rejecting non-https, protocol-relative, authority-less https,
  whitespace/control-character, and invalid-encoding URIs) and absolute
  https:// upload URLs, normalizing uppercase HTTPS:// scheme prefixes
  to lowercase https://.
- Update Gapic::Rest::ClientStub#initialize to normalize endpoint
  schemes case-insensitively and cache @https_endpoint after yielding
  @connection; enforce scheme validation in base_make_http_request.
- Update Gapic::ResumableUpload#start and #resume to validate
  initial_url and ResumeHandle#upload_url before replacing @driver,
  and pass require_https to StartUploadConfig so Rules rejects
  non-https X-Goog-Upload-URL headers immediately with a non-resumable
  BadResponseError ("Upload URL must be a valid https URL").
- Add unit tests across UriValidation, ClientStub, Rules, and
  ResumableUpload covering downgrade vectors, resumable? state,
  permissive retry_predicate non-retry, AIP relative paths, UTF-8
  paths, cross-host https://, and http:// emulators.

Fixes b/593062793
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant