Skip to content

Add explicit EPP/TLS/quota FSMs and P0 hotfixes - #3304

Open
CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:epp-tls-quota-fsm
Open

CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:epp-tls-quota-fsm

Conversation

@CydeWeys

@CydeWeys CydeWeys commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Implicit connection flags, split certificate caches, and misclassified HTTP status codes across EPP transport, proxy quota enforcement, and scheduled background tasks create security bypasses, rotation outages, and silent operational failures. Replacing those ad-hoc booleans and split caches with explicit state machines and atomic credentials keeps connection lifecycles unambiguous, ensures TLS rotations never pair mismatched keys and certificates, enforces RFC 5734 session closure and PROXY v1 framing caps, and prevents Cloud Tasks from silently dropping domain purges or RDE escrow uploads and staging failures.

Changes

  • Atomic TLS credentials and SslContext caching (CertificateSupplierModule, SslServerInitializer, core/proxy EppProtocolModule): bundle private key and ordered certificate chain in one TlsCredentials record cached under a single memoizeWithExpiration TTL, fail fast on unsupported Mode.P12_FILE, cache/rebuild SslContext atomically only on credential rotation instead of per TCP connection, and re-read credentials inside the build lock so stale reads cannot overwrite rotated contexts.
  • Disable server-side TLS session resumption on cached mTLS SslContexts (SslServerInitializer, jetty/kubernetes/*, proxy/kubernetes/*, jetty/start.sh, proxy/Dockerfile, networking/build.gradle): BoringSSL omits intermediate certificates on resumed server sessions, which would break post-handshake client certificate chain validation on 3+ tier chains, and both JDK and Netty OpenSSL emit stateless TLS 1.2/1.3 session tickets unless -Djdk.tls.server.enableSessionTicketExtension=false is set. Because EPP uses persistent TCP connections and previously built a fresh SslContext per connection, TLS session resumption was never used in production. Explicitly disable the OpenSSL session cache (setSessionCacheEnabled(false) / SSL_SESS_CACHE_OFF), unconditionally invalidate server-side sessions on handshake completion (sslSession.invalidate()), log a startup warning if the ticket flag is absent on an mTLS server, and pass -Djdk.tls.server.enableSessionTicketExtension=false in JDK_JAVA_OPTIONS across all 15 Jetty and proxy Kubernetes containers (plus jetty/start.sh, proxy/Dockerfile, and networking/build.gradle tests) so every mTLS connection performs a full handshake and preserves full client certificate chains on both TLS 1.2 and TLS 1.3.
  • Explicit integrated EPP connection FSM (core EppServiceHandler): replace ad-hoc boolean flags with a flat ConnectionState enum (AWAITING_TLS, READY_UNAUTHENTICATED, AUTHENTICATED, CLOSING) and a single idempotent releaseConnectionLimits() helper, execute already-completed cert promises inline in channelActive (and re-check after addListener() to close the cross-executor TOCTOU window), reject pre-TLS frames and non-200 servlet responses fail-closed, guard buildServletRequest() inside try/catch so OIDC token errors fail closed and release limits, defer CLOSING until close-on-flush succeeds so write failures still release limits and close, remove the sticky <clID> regex latch on failed logins, preserve client certificate chain validation and hostname header forwarding, and drop pipelined frames in CLOSING.
  • Proxy quota lease FSM and PROXY v1 header cap (QuotaHandler, ProxyProtocolHandler): add LeaseState (UNCHECKED, LEASED, REJECTED, RELEASED) so pipelined frames after quota rejection are dropped and released instead of bypassing checks, and enforce the 107-byte HAProxy PROXY protocol v1 header cap to prevent unbounded buffer growth.
  • RFC 5734 §2 close on 2501 (EppRequestHandler): set Epp-Session: close on AUTHENTICATION_ERROR_CLOSING_CONNECTION (2501) as well as SUCCESS_AND_CLOSE (1500).
  • Rolled-in P0 operational hotfixes (b/591075298, b/591075515):
    • ResaveEntityAction: pass tm().getTxTime() (filtering remaining times) instead of original requestedTime so Day-35 final purges (30d RGP + 5d pending delete > 30d MAX_ASYNC_ETA) are not silently dropped, and enqueue the follow-up Cloud Task outside the SERIALIZABLE transaction.
    • RdeUploadAction: throw ServiceUnavailableException (503) instead of NoContentException (204) on SFTP cooldown so Cloud Tasks retries.
    • RdeStagingAction: preserve HTTP 500 when any Dataflow launch throws IOException instead of overwriting the status with 200.

Operational Justification & Blast Radius

Eliminates TLS rotation key/cert mismatch outages, per-connection native OpenSSL context churn, resumed-session client chain truncation, pre-TLS and post-rejection quota bypasses, unbounded PROXY header memory allocation, and silent RDE/domain-purge drops across the frontend EPP/proxy tier and backend Cloud Tasks actions, keeping JDK_JAVA_OPTIONS in parity across all 15 Jetty and proxy containers with zero database schema, Flyway, or Valkey Protostuff changes.

BUG= http://b/591076386


This change is Reviewable

@CydeWeys
CydeWeys force-pushed the epp-tls-quota-fsm branch 2 times, most recently from 8599806 to 3acc6fc Compare December 4, 2026 21:35
Implicit connection flags, split certificate caches, and misclassified
HTTP status codes across EPP transport, proxy quota enforcement, and
scheduled background tasks create security bypasses, rotation outages,
and silent operational failures. Replacing those ad-hoc booleans and
split caches with explicit state machines and atomic credentials keeps
connection lifecycles unambiguous, ensures TLS rotations never pair
mismatched keys and certificates, enforces RFC 5734 session closure and
PROXY v1 framing caps, and prevents Cloud Tasks from silently dropping
domain purges or RDE escrow uploads and staging failures.

Changes:
- Atomic TLS credentials and SslContext caching (CertificateSupplierModule,
  SslServerInitializer, core/proxy EppProtocolModule): bundle private key
  and ordered certificate chain in one TlsCredentials record cached under a
  single memoizeWithExpiration TTL, fail fast on unsupported Mode.P12_FILE,
  cache/rebuild SslContext atomically only on credential rotation instead
  of per TCP connection, and re-read credentials inside the build lock so
  stale reads cannot overwrite rotated contexts.
- Disable server-side TLS session resumption on cached mTLS SslContexts
  (SslServerInitializer, jetty/kubernetes/*, proxy/kubernetes/*,
  jetty/start.sh, proxy/Dockerfile, networking/build.gradle): BoringSSL
  omits intermediate certificates on resumed server sessions, which would
  break post-handshake client certificate chain validation on 3+ tier
  chains, and both JDK and Netty OpenSSL emit stateless TLS 1.2/1.3
  session tickets unless jdk.tls.server.enableSessionTicketExtension=false
  is set. Because EPP uses persistent TCP connections and previously built
  a fresh SslContext per connection, TLS session resumption was never used
  in production. Explicitly disable the OpenSSL session cache
  (setSessionCacheEnabled(false) / SSL_SESS_CACHE_OFF), unconditionally
  invalidate server-side sessions on handshake completion
  (sslSession.invalidate()), log a startup warning if the ticket flag is
  absent on an mTLS server, and set
  -Djdk.tls.server.enableSessionTicketExtension=false across all Jetty and
  proxy Kubernetes containers, Dockerfiles/start.sh, and networking tests
  so every mTLS connection performs a full handshake and preserves full
  client certificate chains on both TLS 1.2 and TLS 1.3.
- Explicit integrated EPP connection FSM (core EppServiceHandler): replace
  ad-hoc boolean flags with a flat ConnectionState enum (AWAITING_TLS,
  READY_UNAUTHENTICATED, AUTHENTICATED, CLOSING) and a single idempotent
  releaseConnectionLimits() helper, execute already-completed cert promises
  inline in channelActive (and re-check after addListener() to close the
  cross-executor TOCTOU window), reject pre-TLS frames and non-200 servlet
  responses fail-closed, guard buildServletRequest() inside try/catch so
  OIDC token errors fail closed and release limits, defer CLOSING until
  close-on-flush succeeds so write failures still release limits and close,
  remove the sticky <clID> regex latch on failed logins, preserve client
  certificate chain validation and hostname header forwarding, and drop
  pipelined frames in CLOSING.
- Proxy quota lease FSM and PROXY v1 header cap (QuotaHandler,
  ProxyProtocolHandler): add LeaseState (UNCHECKED, LEASED, REJECTED,
  RELEASED) so pipelined frames after quota rejection are dropped and
  released instead of bypassing checks, and enforce the 107-byte HAProxy
  PROXY protocol v1 header cap to prevent unbounded buffer growth.
- RFC 5734 section 2 close on 2501 (EppRequestHandler): set Epp-Session:
  close on AUTHENTICATION_ERROR_CLOSING_CONNECTION (2501) as well as
  SUCCESS_AND_CLOSE (1500).
- Rolled-in P0 operational hotfixes (b/591075298, b/591075515):
  - ResaveEntityAction: pass tm().getTxTime() (filtering remaining times)
    instead of original requestedTime so Day-35 final purges (30d RGP +
    5d pending delete > 30d MAX_ASYNC_ETA) are not silently dropped, and
    enqueue the follow-up Cloud Task outside the SERIALIZABLE transaction.
  - RdeUploadAction: throw ServiceUnavailableException (503) instead of
    NoContentException (204) on SFTP cooldown so Cloud Tasks retries.
  - RdeStagingAction: preserve HTTP 500 when any Dataflow launch throws
    IOException instead of overwriting the status with 200.

Operational justification and blast radius:
Eliminates TLS rotation key/cert mismatch outages, per-connection native
OpenSSL context churn, resumed-session client chain truncation, pre-TLS
and post-rejection quota bypasses, unbounded PROXY header memory
allocation, and silent RDE/domain-purge drops across the frontend
EPP/proxy tier and backend Cloud Tasks actions, keeping JDK_JAVA_OPTIONS
in parity across all 15 Jetty and proxy containers with zero database
schema, Flyway, or Valkey Protostuff changes.

BUG= http://b/591076386

This branch has not been deployed

No deployments
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.

2 participants