Skip to content

v0.3.4 - URL and TLS fixes

Latest

Choose a tag to compare

@dmitryk-cf dmitryk-cf released this 30 Nov 00:07
6a1629a

Version 0.3.4: a configured TLS never falls back to plaintext, and a caller's id, realm or base URL cannot send a request to another resource. No change to the public API; cargo update brings it to every project on 0.3.

Fixes over 0.3.3, with no change to the public API. Most refuse, with
Error::InvalidRequest and before anything is sent, a value that used to go
somewhere other than where the caller meant. A few make a value work as it
was meant instead: whitespace and a trailing backslash are trimmed from a
base URL, a realm or an authorization server, an identity provider domain
may carry its https://, ws:// becomes wss:// under TLS, and grpcs://
means TLS.

Fixed

Found by testing the published 0.3.3 from an application, and then by
sweeping every HTTP, WebSocket and gRPC client for the same kind of mistake.

  • TLS could be dropped without an error, with the bearer token sent in
    plaintext.

    • JsonClient::with_tls turned only a literal http:// into https://.
      A base URL that URL parsing reads as http://host without being spelt
      that way — http:/host, http:host, http:\\host, a tab inside the
      scheme — went out as plain HTTP. With TLS configured the JSON client now
      refuses any URL that is not https.
    • A ws:// base with TLS opened a plain WebSocket. It now becomes
      wss://, and the WebSocket lane refuses a non-wss URL when TLS is
      configured.
    • On gRPC, Config::with_tls with a grpcs://, grpc://, dns:// or
      other non-HTTP endpoint connected in plaintext HTTP/2, because tonic
      picks TLS by the scheme. grpcs:// now means TLS, as https:// does;
      with TLS configured, any other scheme is Error::InvalidRequest.
  • A path argument could address another resource.

    • URL parsing resolves . and .. against the path, so
      RegistryClient::instrument("..") asked for the list of instruments,
      ScanClient::featured_app_right("..") for the list of every featured-app
      right (and read it as "not featured"), and JsonClient::get_parties and
      package_status for other endpoints.
    • URL parsing also drops tab, CR and LF, so instrument("USD\tC") read
      instrument USDC, and .\t. became ...
    • It reads a backslash as /, so package_status(r"..\..\v2\users")
      asked for /v2/users/status.

    An empty, . or .. segment, a segment with a control character, and a
    package id with a backslash are now Error::InvalidRequest, before anything
    is sent. Scan's API version argument is checked the same way.

  • The OIDC presets put the realm, the authorization server and the domain
    into the token URL as they were.
    OidcConfig::keycloak with a realm of
    AppProvider/../master asked the master realm for a token, an Okta
    auth_server of . reached the org authorization server, and a domain of
    evil.example\.okta.com was host evil.example. A realm or an
    authorization server that would not stay one path segment (empty, .,
    .., %2e%2e, or one with a /, \, ?, # or control character), and
    a domain that is not a bare host[:port], are now refused by the first
    TokenProvider::token, before the secret is sent. Every other value is
    sent as before, with surrounding whitespace trimmed, as a value read from
    a file needs. A domain given with its https://, as identity providers'
    consoles show it, no longer makes the host https.

  • A unix: gRPC endpoint dialled TCP host unix. It is now passed to
    tonic as the Unix socket it names, and refused with TLS, which a socket
    cannot carry.

  • A base URL with a query or a fragment mangled every request.
    …/ledger?tenant=a sent GET /ledger?tenant=a/v2/version, and
    …/ledger#x sent every request, submissions included, to /ledger.
    JsonClient now refuses such a base on the first request, and
    RegistryClient and ScanClient at construction. Whitespace around a
    base URL and a trailing backslash are trimmed like a trailing slash.

Documentation

  • CantonClient::prepare_submission's # Errors said a max record time finer
    than a microsecond is refused. It is rounded down to the microsecond, as
    0.3.3's changelog and Prepare::with_max_record_time say.