Repository navigation
Add cert hostnames and revoked certs to Registrar - #3266
Conversation
CydeWeys
left a comment
There was a problem hiding this comment.
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:
- [P0] Data loss on partial updates in
SecurityAction: OmittingallowedEppClientCertificateHostnamesorrevokedClientCertificateHashesin a POST request (e.g., from the existing console UI or single-field updates) causesregistrarParameter.get...()to returnImmutableSet.of()and silently wipes out existing values in the database. - [P1] Missing
@GetterDelegateand sorted sets onRegistrar: BreakstoDiffableFieldMap()/DiffUtils.prettyPrintDiffedMap()set diffs (null -> [...]instead ofADDED / REMOVED / FINAL CONTENTS) for security notification emails. - [P1] Missing hash format validation & PEM vs. hash contract in
SecurityAction:setRevokedClientCertificateHashesonly checks size<= 20without validating base64 SHA-256 format, andb/573176693specifies that the console sends a PEM certificate which the backend hashes viaX509Utils.getCertificateHash. - [P1] Missing
SecurityActionguards fromb/573176693: Once a registrar has hostnames configured, emptyingallowedEppClientCertificateHostnamesmust be rejected, and clearingclientCertificate/failoverClientCertificateshould be supported while at least one hostname is configured. - [P1] Unhandled
NullPointerException(HTTP 500): JSON arrays containingnullelements throwNullPointerExceptioninstead of returning400 Bad Request. - [P2] Minor hygiene & test notes:
- Please rebase onto
masterto drop the 3Merge branch 'master' into epp-cert-registrar-fieldsmerge commits. - Consider also setting both new fields on the test registrar in
RegistrarDaoTest(SqlIntegrationTestSuite).
- Please rebase onto
d0e2538 to
8ac2373
Compare
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
left a comment
There was a problem hiding this comment.
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:
- [P0/P1]
SecurityAction!isEmpty()guard breaks removing the last revoked cert hash (and silently returns200 OKwhen clearing either list): Conflating omitted JSON keys (null) with explicit empty arrays ([]) makes it impossible to delete the last entry fromrevokedClientCertificateHashesvia the console. - [P1] Unhandled
NullPointerException(HTTP 500) inSecurityActionis still present:registrarParameteris deserialized via Gson reflection (bypassingRegistrar.Builder), soregistrarParameter.get...()callsImmutableSortedSet.copyOf(...)and throwsNullPointerExceptionon[null]beforeRegistrar.Builderis ever reached. - [P2] Pre-canonicalization
.equals(...)inSecurityAction: Submitting["EPP.Example.COM"]when["epp.example.com"]is already saved logs a spuriousEPP_CERT_HOSTNAMES_CHANGEhistory entry. - [P1] Fail-open risk on
setRevokedClientCertificateHashes: Unlike an allowlist, storing an unvalidated string in a revocation denylist fails open at EPP login (see reply onRegistrar.java).
19f57dd to
28da0a3
Compare
CydeWeys
left a comment
There was a problem hiding this comment.
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:
- [P0] Single-read payload injection in
SecurityAction: Remove@Parameter("registrar")fromSecurityAction's constructor, inject only@OptionalJsonPayload Optional<JsonElement> payload(matchingConsoleBulkDomainAction), and deserialize viaconsoleApiParams.gson().fromJson(jsonObject, Registrar.class). - [P1] Return
400 Bad Request(not500) on malformed JSON types: Guardpayload.get().isJsonObject(), checkfield.isJsonArray()and string element types beforegson.fromJson, and catchJsonSyntaxException. - [P2] Stream realism in
SecurityActionTest.createAction& canonical trailing-bits check inRegistrar.setRevokedClientCertificateHashes: WirecreateServletInputStream(jsonBody)inSecurityActionTest+ negative tests for non-array/non-string JSON inputs, and a small canonical re-encode check on 43-char Base64 hashes.
28da0a3 to
c28a2c9
Compare
c28a2c9 to
055626e
Compare
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
055626e to
2826810
Compare
CydeWeys
left a comment
There was a problem hiding this comment.
LGTM! Thanks for addressing all the feedback thoroughly and for the single-payload stream fix and tests.
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:
BUG=http://b/573176068
BUG=http://b/573176693
This change is