← Back to Pull requests

RHOAIENG-96983, RHOAIENG-96984: harden TLS profile resolution and add BFF live reload #10325

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 19, 2026 12:18 UTC
Author

Fixes: https://issues.redhat.com/browse/RHOAIENG-96983
Fixes: https://issues.redhat.com/browse/RHOAIENG-96984

Problem

As part of the OCP 5 / RHOAI 3.6 TLS hardening epic (RHOAIENG-96306), the dashboard's TLS profile handling had three gaps assigned to Pewter:

  • Fail-open on denied reads (RHOAIENG-96983). When the cluster TLS profile (apiservers.config.openshift.io/cluster) could not be read due to RBAC (401/403), both the shared BFF resolver (pkg/tls) and the operator resolver (dashboard-operator/internal/tls) silently fell back to Mozilla Intermediate defaults. A misconfigured cluster could therefore serve a weaker TLS policy than the admin intended, with no signal. The operator also substituted Intermediate for unknown profile types, missing Custom blocks, and unknown minTLSVersion, and neither resolver validated that mapped TLS ≤1.2 ciphers are actually negotiable by the running Go runtime.

  • No live reload (RHOAIENG-96983). Every BFF read the profile once at startup and never again, so a cluster TLS policy change required a pod restart to take effect.

  • Hardcoded TLS 1.3 listeners (RHOAIENG-96984). The notebooks backend (workspaces/backend) constructed tls.Config{MinVersion: TLS13} directly instead of honoring the cluster profile, and the notebooks cluster-role lacked config.openshift.io/apiservers access entirely.
  • Solution

  • pkg/tls (shared BFF resolver): fail closed on 401/403 and on unknown profile types; validate mapped TLS ≤1.2 ciphers against tls.CipherSuites() ∪ tls.InsecureCipherSuites() and reject sets with no usable suite; keep NotFound/NoMatchError (non-OpenShift) fail-open to Intermediate; keep nil/empty → Intermediate. Added ServeTLSWithReload / ListenAndServeTLSWithReload, which poll the cluster profile and gracefully restart the HTTPS listener when the resolved config changes.

  • dashboard-operator/internal/tls: mirror the fail-closed behavior so the two resolvers stay in sync — 401/403, unknown type, missing Custom block, and unknown minTLSVersion now return errors; errors are threaded through parseProfile/parseCustomProfile; ciphers are validated against the Go runtime.

  • All 11 BFFs (core-bff + agent-ops, autorag, automl, data-registry, data-connect-hub, eval-hub, gen-ai, maas, mlflow, model-registry/upstream): serve HTTPS via ListenAndServeTLSWithReload behind a single signal-driven shutdown path; fail fast (exit 1) on fatal serve errors. The non-TLS path is unchanged.

  • Notebooks backend: removed the hardcoded TLS 1.3; NewServer now takes a resolved tls.Config derived from the cluster profile via the notebooks controller's existing pkg/tls.Resolve (already a dependency — no upstream divergence), with a graceful restart loop driven by the existing ProfileWatcher.

  • RBAC: granted config.openshift.io/apiservers get;list;watch to the notebooks cluster-role (was missing) and the data-connect-hub cluster-role (list/watch require no resourceNames; apiservers is a cluster singleton, so this stays effectively least-privilege).
  • Behavior change / security note: 401/403 and unknown-profile-type now fail closed in both resolvers. This is intentional per the hardening epic and the 96983 acceptance criteria. The availability tradeoff: a service account missing apiservers get permission, or a cluster advertising a TLS profile type this code doesn't recognize, will now fail to start rather than silently serving Intermediate. RBAC for all affected modules is included here.

    Scope note on 96984: the data-connect-hub BFF listener already consumed the shared resolver (the ticket text was stale for that half); this PR adds its live reload and the RBAC verb bump. The notebooks backend reuses the controller's resolver, whose 401/403 handling is fail-open-with-watcher-self-heal by that component's own design/tests; this PR does not change that upstream contract. With an unset cluster profile the notebooks listener now resolves to Intermediate (TLS 1.2 Mozilla baseline) rather than the previous hardcoded TLS 1.3.

    Evidence

    All changed Go modules build, vet, and test clean locally (Go 1.25.4; the notebooks backend auto-fetched its go 1.26.5 toolchain). gofmt reports no diffs on any edited file.

    <details>
    <summary>Verification commands and results</summary>

    # pkg/tls — hardening + reload (incl. e2e listener-restart test with generated certs)
    pkg/tls$ go vet ./... && go test ./...          # ok
    
    # operator resolver — fail-closed mirror + new error-path tests
    dashboard-operator$ go build ./... && go test ./internal/tls/...   # ok
    
    # all 11 BFFs
    <each>/bff$ go build ./... && go vet ./cmd/...   # OK x11
    
    # notebooks backend — resolved TLS config + reload loop + tests
    workspaces/backend$ go build ./cmd/... ./internal/server/... \
      && go vet ./cmd/... ./internal/server/... \
      && go test ./internal/server/...             # ok
    
    # formatting
    $ gofmt -l <all edited .go files>              # (no output)
    

    </details>

    Automated coverage added:

  • pkg/tls: 401/403 fail-closed, unknown-type fail-closed, runtime cipher validation, tlsConfigEqual, watchForReload (change / unchanged / transient-error / ctx-cancel), and an end-to-end serveTLSWithReload test that serves over TLS and asserts the listener restarts when the resolved profile changes.

  • dashboard-operator/internal/tls: Forbidden/Unauthorized/unknown-type/missing-Custom/bad-minTLSVersion all fail closed.

  • notebooks backend: ReloadTLSConfig swaps the config and signals a non-blocking restart.
  • Not cluster-verified: live reload against a real OpenShift APIServer profile edit is covered by unit/e2e tests here; an on-cluster check with the built images is a reasonable follow-up before release.

    [RHOAIENG-96306]: https://redhat.atlassian.net/browse/RHOAIENG-96306?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    [RHOAIENG-96983]: https://redhat.atlassian.net/browse/RHOAIENG-96983?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    [RHOAIENG-96983]: https://redhat.atlassian.net/browse/RHOAIENG-96983?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    HTTPS listeners use the cluster-wide TLS security profile and periodically apply changes with a graceful restart.
    HTTPS starts only when both a certificate and key are configured.
    Bug Fixes
    Malformed or unsupported TLS profiles and denied profile access now return errors instead of silently using defaults. Transient API errors can still use Intermediate defaults.
    Cipher suites unsupported by the running environment are excluded.
    Documentation
    * Updated HTTPS guidance to cover profile access requirements, reload behavior, and fallback conditions.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: lucferbux Review duration: 5945m
    All Vouch review confidence checks passed
    Residual risk 0.40 = Change Risk (0.75) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #10325"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 40.1% · Moderate risk
    40.1%