Skip to content

Fix ACME SSRF - #5409

Merged
agaragna77 merged 1 commit into
dogtagpki:masterfrom
agaragna77:fix-acme-ssrf
Aug 5, 2026
Merged

Fix ACME SSRF#5409
agaragna77 merged 1 commit into
dogtagpki:masterfrom
agaragna77:fix-acme-ssrf

Conversation

@agaragna77

@agaragna77 agaragna77 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fix 5407

Summary by CodeRabbit

  • Bug Fixes
    • DNS identifiers that are IP literals—including IPv4, IPv6, bracketed IPv6, compressed IPv6, and wildcard-prefixed forms—are now rejected as invalid ACME identifiers.
    • HTTP-01 validation no longer follows redirects, improving challenge handling and predictability.
    • HTTP-01 mismatched key-authorization errors no longer expose the received response content, while operator logging remains available for troubleshooting.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 834eb880-d1fb-4d25-859c-0872bd0c6d0a

📥 Commits

Reviewing files that changed from the base of the PR and between 8405962 and c5274ec.

📒 Files selected for processing (2)
  • base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java
  • base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java
  • base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java

📝 Walkthrough

Walkthrough

DNS validation now rejects IPv4 and IPv6 literals. HTTP-01 validation no longer exposes mismatched response bodies, disables redirects, and uses scoped HTTP resource handling.

Changes

DNS identifier validation

Layer / File(s) Summary
IP literal detection and rejection
base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java
DNS validation strips optional wildcard prefixes and IPv6 brackets, checks IPv4 and IPv6 literal syntax, and returns a malformed ACME error for matches.

HTTP-01 validation hardening

Layer / File(s) Summary
HTTP-01 request and error handling
base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java
Mismatched response bodies are logged but omitted from returned error details. HTTP clients do not follow redirects, and client and response resources use try-with-resources.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: mitigating ACME SSRF through IP-literal validation and redirect handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java`:
- Around line 52-61: Update ACMEIdentifierValidator’s DNS validation to remove a
leading wildcard prefix before calling isIpLiteral, while preserving the
existing malformed error for detected IP literals. Add a regression test
covering a wildcard-prefixed IPv4 identifier and verify it is rejected before
authorization storage or HTTP-01 processing.

In `@base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java`:
- Around line 95-103: Update the invalid-response logging in HTTP01Validator,
including the log site near the later response handling, to stop logging the
remote-controlled response body. Log only bounded, escaped metadata such as
response length and a digest, reusing one sanitized representation consistently
and preserving the existing validation error behavior.
- Around line 117-124: Update HTTP01Validator’s validation request around
HttpClients.custom(), httpClient.execute(), and IOUtils.toString() to enforce
bounded connection, read, and request timeouts and a strict maximum
response-body size before buffering or comparison. Preserve redirect disabling
and ensure oversized or timed-out responses fail validation without exhausting
validation threads or memory.
- Around line 122-124: Update getResponse() to handle a null result from
httpResponse.getEntity() by treating it as an empty response, avoiding both
getContent() and EntityUtils.consume(entity) when no entity exists. Preserve the
existing trimming and response-processing behavior for non-null entities so
validateChallenge reports incorrectResponse rather than a connection error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b8ccb30-1f36-4fa1-bee2-35c727f21ace

📥 Commits

Reviewing files that changed from the base of the PR and between da07c70 and 4dbecd4.

📒 Files selected for processing (2)
  • base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java
  • base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java (1)

95-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the hardening contract.

Cover sanitized mismatch details, non-followed redirects, empty responses, and bounded slow/oversized responses.

Also applies to: 115-128

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java`
around lines 95 - 103, Add regression tests for HTTP01Validator’s validation
flow covering sanitized mismatch error details, redirects that are not followed,
empty response bodies, and bounded handling of slow or oversized responses.
Assert the ACME client receives no response-body disclosure while operator
logging remains appropriate, and exercise the existing validation entry point
rather than adding unrelated test coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java`:
- Around line 117-121: Update HTTP01Validator’s validationURL egress path before
httpClient.execute(httpGet) to resolve the target hostname and reject loopback,
private, link-local, and other disallowed addresses, including every resolved
address before connecting. Reuse existing network-egress isolation or
address-validation utilities if available; otherwise enforce the filtering in
HTTP01Validator while preserving normal public-address validation.

---

Nitpick comments:
In `@base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java`:
- Around line 95-103: Add regression tests for HTTP01Validator’s validation flow
covering sanitized mismatch error details, redirects that are not followed,
empty response bodies, and bounded handling of slow or oversized responses.
Assert the ACME client receives no response-body disclosure while operator
logging remains appropriate, and exercise the existing validation entry point
rather than adding unrelated test coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b9f5576b-f5a7-47f2-9a4f-67a7972d3c17

📥 Commits

Reviewing files that changed from the base of the PR and between 4dbecd4 and 49d2497.

📒 Files selected for processing (2)
  • base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java
  • base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java`:
- Around line 133-141: Update the colon-containing branch in
ACMEIdentifierValidator to validate IPv6 and IPv4-mapped literals lexically
before any resolver call, rejecting malformed values such as “g:internal”. Do
not call InetAddress.getByName for arbitrary host input; only permit the
strictly validated literal forms and preserve rejection of invalid addresses.
- Around line 146-159: Update isIpv4Literal to use a non-resolving IP parser
that recognizes and rejects every IPv4 decimal notation accepted by the HTTP-01
downstream client, including dotted forms with fewer than four components and
single-integer forms such as 127.1, 127.0.1, and 2130706433. Extend the
validateSyntax regression tests to cover these literals and their
wildcard-prefixed variants.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c1c2dd4-4568-4cc2-a8a7-5587b192e55b

📥 Commits

Reviewing files that changed from the base of the PR and between 49d2497 and de4235e.

📒 Files selected for processing (2)
  • base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java
  • base/acme/src/main/java/org/dogtagpki/acme/validator/HTTP01Validator.java

Comment thread base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java Outdated

@edewata edewata left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Sorry for the delay. I just have some minor comments but feel free to update/merge. Thanks!

Comment thread base/acme/src/main/java/org/dogtagpki/acme/server/ACMEIdentifierValidator.java Outdated
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@agaragna77

Copy link
Copy Markdown
Contributor Author

@edewata thanks!

@agaragna77
agaragna77 merged commit 4c9c625 into dogtagpki:master Aug 5, 2026
204 of 207 checks passed
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.

ACME HTTP-01 validation allows SSRF and internal HTTP response disclosure

2 participants