Skip to content

Add cert hostnames and revoked certs to Registrar - #3266

Merged
anomaly2104 merged 1 commit into
google:masterfrom
anomaly2104:epp-cert-registrar-fields
Nov 19, 2026
Merged

anomaly2104 merged 1 commit into
google:masterfrom
anomaly2104:epp-cert-registrar-fields

Conversation

@anomaly2104

@anomaly2104 anomaly2104 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Map the allowed_epp_client_certificate_hostnames and revoked_client_certificate_hashes columns onto Registrar and let SecurityAction read and update them from the console security settings endpoint:

  • Canonicalize and validate hostnames (A-label punycode, lowercase, at least two labels, no wildcards/IPs/ports, max 20) and enforce max 20 on revoked certificate hashes.
  • Update SecurityAction to persist changes to both fields and record EPP_CERT_HOSTNAMES_CHANGE and REVOKED_CERTS_CHANGE in ConsoleUpdateHistory.

BUG=http://b/573176068
BUG=http://b/573176693


This change is Reviewable

@anomaly2104
anomaly2104 requested a review from CydeWeys November 9, 2026 16:05

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting the Flyway migration (#3249) and ORM changes (#3266) cleanly per db/README.md!

I left inline comments on several functional/spec issues and test gaps to address before merging:

  1. [P0] Data loss on partial updates in SecurityAction: Omitting allowedEppClientCertificateHostnames or revokedClientCertificateHashes in a POST request (e.g., from the existing console UI or single-field updates) causes registrarParameter.get...() to return ImmutableSet.of() and silently wipes out existing values in the database.
  2. [P1] Missing @GetterDelegate and sorted sets on Registrar: Breaks toDiffableFieldMap() / DiffUtils.prettyPrintDiffedMap() set diffs (null -> [...] instead of ADDED / REMOVED / FINAL CONTENTS) for security notification emails.
  3. [P1] Missing hash format validation & PEM vs. hash contract in SecurityAction: setRevokedClientCertificateHashes only checks size <= 20 without validating base64 SHA-256 format, and b/573176693 specifies that the console sends a PEM certificate which the backend hashes via X509Utils.getCertificateHash.
  4. [P1] Missing SecurityAction guards from b/573176693: Once a registrar has hostnames configured, emptying allowedEppClientCertificateHostnames must be rejected, and clearing clientCertificate / failoverClientCertificate should be supported while at least one hostname is configured.
  5. [P1] Unhandled NullPointerException (HTTP 500): JSON arrays containing null elements throw NullPointerException instead of returning 400 Bad Request.
  6. [P2] Minor hygiene & test notes:
    • Please rebase onto master to drop the 3 Merge branch 'master' into epp-cert-registrar-fields merge commits.
    • Consider also setting both new fields on the test registrar in RegistrarDaoTest (SqlIntegrationTestSuite).

@anomaly2104
anomaly2104 force-pushed the epp-cert-registrar-fields branch 2 times, most recently from d0e2538 to 8ac2373 Compare November 16, 2026 12:34
@anomaly2104

Copy link
Copy Markdown
Member Author

Thanks for splitting the Flyway migration (#3249) and ORM changes (#3266) cleanly per db/README.md!

I left inline comments on several functional/spec issues and test gaps to address before merging:

  1. [P0] Data loss on partial updates in SecurityAction: Omitting allowedEppClientCertificateHostnames or revokedClientCertificateHashes in a POST request (e.g., from the existing console UI or single-field updates) causes registrarParameter.get...() to return ImmutableSet.of() and silently wipes out existing values in the database.

  2. [P1] Missing @GetterDelegate and sorted sets on Registrar: Breaks toDiffableFieldMap() / DiffUtils.prettyPrintDiffedMap() set diffs (null -> [...] instead of ADDED / REMOVED / FINAL CONTENTS) for security notification emails.

  3. [P1] Missing hash format validation & PEM vs. hash contract in SecurityAction: setRevokedClientCertificateHashes only checks size <= 20 without validating base64 SHA-256 format, and b/573176693 specifies that the console sends a PEM certificate which the backend hashes via X509Utils.getCertificateHash.

  4. [P1] Missing SecurityAction guards from b/573176693: Once a registrar has hostnames configured, emptying allowedEppClientCertificateHostnames must be rejected, and clearing clientCertificate / failoverClientCertificate should be supported while at least one hostname is configured.

  5. [P1] Unhandled NullPointerException (HTTP 500): JSON arrays containing null elements throw NullPointerException instead of returning 400 Bad Request.

  6. [P2] Minor hygiene & test notes:

    • Please rebase onto master to drop the 3 Merge branch 'master' into epp-cert-registrar-fields merge commits.
    • Consider also setting both new fields on the test registrar in RegistrarDaoTest (SqlIntegrationTestSuite).

Thanks for the review! One quick note on the differences with b/573176068 and b/573176693: when I generated those task bugs in bulk using AI, the AI added several extra requirements in the bug descriptions that I found to be unnecessarily complex during implementation, so I kept the implementation simple and aligned with what we actually need (and I've updated the bug descriptions to match).

Rebased onto master to drop the merge commits, added the fields to RegistrarDaoTest, and addressed the inline comments below.

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean rebase onto master, moving ALLOWED_CHARS to DomainNameUtils, adding @GetterDelegate / ImmutableSortedSet, and updating RegistrarDaoTest! I've resolved the threads that are all set.

A few remaining bugs in the new SecurityAction !isEmpty() block and a fail-open validation concern on setRevokedClientCertificateHashes are noted inline:

  1. [P0/P1] SecurityAction !isEmpty() guard breaks removing the last revoked cert hash (and silently returns 200 OK when clearing either list): Conflating omitted JSON keys (null) with explicit empty arrays ([]) makes it impossible to delete the last entry from revokedClientCertificateHashes via the console.
  2. [P1] Unhandled NullPointerException (HTTP 500) in SecurityAction is still present: registrarParameter is deserialized via Gson reflection (bypassing Registrar.Builder), so registrarParameter.get...() calls ImmutableSortedSet.copyOf(...) and throws NullPointerException on [null] before Registrar.Builder is ever reached.
  3. [P2] Pre-canonicalization .equals(...) in SecurityAction: Submitting ["EPP.Example.COM"] when ["epp.example.com"] is already saved logs a spurious EPP_CERT_HOSTNAMES_CHANGE history entry.
  4. [P1] Fail-open risk on setRevokedClientCertificateHashes: Unlike an allowlist, storing an unvalidated string in a revocation denylist fails open at EPP login (see reply on Registrar.java).

@anomaly2104
anomaly2104 force-pushed the epp-cert-registrar-fields branch 4 times, most recently from 19f57dd to 28da0a3 Compare November 18, 2026 14:44

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for extracting DomainNameUtils.canonicalizeAndValidateHostname, adding the 32-byte Base64 SHA-256 format check on setRevokedClientCertificateHashes, and covering all the SecurityAction business-logic and unit-test scenarios!

One critical catch on the new SecurityAction wiring—and apologies for not flagging this subtlety when suggesting @OptionalJsonPayload in the previous round: RequestModule.providePayloadAsBytes(HttpServletRequest) is unscoped, so injecting @OptionalJsonPayload alongside @Parameter("registrar") causes Dagger to read HttpServletRequest.getInputStream() twice per request. On real Jetty requests, the second read hits EOF (Optional.empty()), causing payload.get() to throw NoSuchElementException (500 Internal Server Error) on every POST /console-api/settings/security call.

Summary of inline notes below:

  1. [P0] Single-read payload injection in SecurityAction: Remove @Parameter("registrar") from SecurityAction's constructor, inject only @OptionalJsonPayload Optional<JsonElement> payload (matching ConsoleBulkDomainAction), and deserialize via consoleApiParams.gson().fromJson(jsonObject, Registrar.class).
  2. [P1] Return 400 Bad Request (not 500) on malformed JSON types: Guard payload.get().isJsonObject(), check field.isJsonArray() and string element types before gson.fromJson, and catch JsonSyntaxException.
  3. [P2] Stream realism in SecurityActionTest.createAction & canonical trailing-bits check in Registrar.setRevokedClientCertificateHashes: Wire createServletInputStream(jsonBody) in SecurityActionTest + negative tests for non-array/non-string JSON inputs, and a small canonical re-encode check on 43-char Base64 hashes.

@anomaly2104
anomaly2104 force-pushed the epp-cert-registrar-fields branch from 28da0a3 to c28a2c9 Compare November 19, 2026 15:01
@anomaly2104
anomaly2104 requested a review from CydeWeys November 19, 2026 15:23
@anomaly2104
anomaly2104 force-pushed the epp-cert-registrar-fields branch from c28a2c9 to 055626e Compare November 19, 2026 15:27
Map the allowed_epp_client_certificate_hostnames and
revoked_client_certificate_hashes columns onto Registrar and let
SecurityAction read and update them from the console security settings
endpoint:
- Canonicalize and validate hostnames (A-label punycode, lowercase, at
  least two labels, no wildcards/IPs/ports, max 20) and enforce max 20
  on revoked certificate hashes.
- Update SecurityAction to persist changes to both fields and record
  EPP_CERT_HOSTNAMES_CHANGE and REVOKED_CERTS_CHANGE in
  ConsoleUpdateHistory.

BUG=http://b/573176068
BUG=http://b/573176693
@anomaly2104
anomaly2104 force-pushed the epp-cert-registrar-fields branch from 055626e to 2826810 Compare November 19, 2026 15:37

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for addressing all the feedback thoroughly and for the single-payload stream fix and tests.

@anomaly2104
anomaly2104 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into google:master with commit db7c5e6 Nov 19, 2026
15 checks passed
@anomaly2104
anomaly2104 deleted the epp-cert-registrar-fields branch November 19, 2026 20:38
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