Skip to content

fix(ocm): enforce transport TLS and scheme policy - #5839

Closed
MahdiBaghbani wants to merge 5 commits into
guard-ocm-discovery-inputsfrom
finish-ocm-transport-policy
Closed

MahdiBaghbani wants to merge 5 commits into
guard-ocm-discovery-inputsfrom
finish-ocm-transport-policy

Conversation

@MahdiBaghbani

@MahdiBaghbani MahdiBaghbani commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

This PR is part of the cs3org/OCM-STA#48

Summary

  • Enforce a TLS 1.2 floor on every shared OCM HTTP transport
    (including trusted and insecure modes), make public-only clients
    HTTPS-only with redirect-downgrade rejection (10-redirect limit), and
    tighten the dial guard's address list: deny the IANA special-purpose
    ranges (192.0.0.0/24), keep the PCP/TURN anycast addresses
    (192.0.0.9, 192.0.0.10) reachable inside that range, and deny local-use
    NAT64 (64:ff9b:1::/48) wholesale instead of unwrapping it.

@MahdiBaghbani MahdiBaghbani self-assigned this Sep 21, 2026
@MahdiBaghbani MahdiBaghbani added feature New feature OCM Open Cloud Mesh labels Sep 21, 2026
@MahdiBaghbani
MahdiBaghbani force-pushed the finish-ocm-transport-policy branch from 6d5efef to 947f5f4 Compare September 22, 2026 14:47
@glpatcern
glpatcern force-pushed the finish-ocm-transport-policy branch from 947f5f4 to b66a453 Compare September 22, 2026 16:15
@MahdiBaghbani

MahdiBaghbani commented Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

Dialer.Control only checks IPs, so it misses ftp/gopher and https-to-http downgrades.
This wraps the public-only transport in a RoundTripper that requires https, sets a TLS 1.2 minimum, and refuses downgrade redirects.

flowchart TD
    URL["peer URL"] --> W["publicOnlyTransport.RoundTrip"]
    W -->|http / ftp / gopher| R["ErrPolicyViolation"]
    W -->|redirect to http| R
    W -->|https| B["base transport, then Dialer.Control"]
Loading

I wrapped RoundTrip instead of using Transport.RegisterProtocol, because that can't override http/https and would actually enable gopher if we registered it.

The wrapper is also the only redirect gate for WebDAV, since gowebdav ignores CheckRedirect.
The gowebdav test shows a 302 to plain HTTP failing with no HTTP request sent.

HTTPTransport is exported only so tests can inspect the base transport. Production code shouldn't use it to get around the wrapper.

@MahdiBaghbani
MahdiBaghbani force-pushed the finish-ocm-transport-policy branch from b66a453 to fe7d972 Compare September 24, 2026 18:28
@MahdiBaghbani
MahdiBaghbani force-pushed the finish-ocm-transport-policy branch from fe7d972 to 5781437 Compare September 25, 2026 19:59
@MahdiBaghbani

MahdiBaghbani commented Sep 26, 2026 •

Copy link
Copy Markdown
Member Author

No new key here.

This makes the scheme and redirect checks from this PR use exactly the same CIDR policy as the dial.

newPublicOnlyParts captures one destinationPolicy and hands it to the scheme wrapper, CheckRedirect and dial Control, so a literal-IP redirect is judged by the same rules the dial would use.

flowchart TD
    CFG["TransportConfig"] --> P["newPublicOnlyParts: one destinationPolicy"]
    P --> S["publicOnlyTransport scheme check"]
    P --> R["CheckRedirect"]
    P --> D["dial Control"]
    S -->|"https"| D
    S -->|"http, unless AllowLoopback and literal loopback"| X["refuse"]
    R -->|"non-https"| X
    R -->|"https literal IP"| C["checkResolvedAddr"]
    R -->|"https hostname"| D
    C -->|"out of range"| X
    C -->|"in range"| D
Loading

The part you might ask about is http.

A CIDR entry only admits an address, it doesn't relax the scheme.

checkRequestScheme only reads allowLoopback, so http://10.50.1.1/ is still refused with 10.50.0.0/16 listed, and the TLS 1.2 floor stays on too.

glpatcern
glpatcern previously approved these changes Oct 1, 2026
@glpatcern
glpatcern force-pushed the finish-ocm-transport-policy branch from d1fe987 to da1963b Compare October 1, 2026 08:19
@glpatcern glpatcern closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature OCM Open Cloud Mesh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants