Skip to content

fix(bbb-web): Add Callback URL Validation - #24828

Merged
antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
paultrudel:callback-url-validation
Apr 28, 2026
Merged

antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
paultrudel:callback-url-validation

Conversation

@paultrudel

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds URL validation to meeting ended callback URLs. Provided URLs must now respect the fetch URL properties: fetchUrlSupportedProtocols, fetchUrlBlockedExternalHosts, and fetchUrlAllowedLocalHosts defined in bigbluebutton.properties.

Motivation

Callback URLs should follow the same pattern of validation used by presentation and client settings override URLs.

@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds server-side validation and result semantics for callback URL fetches. Introduces CallbackRedirectValidatorService (extends BaseUrlRedirectValidator) and wires it into CallbackUrlService via Spring. CallbackUrlService.fetchCallbackUrl now validates URLs, pins DNS resolution to the validated host, performs synchronous HTTP requests with strict timeouts and disabled redirects, and returns a CallbackResult (SUCCESS, TRANSIENT_FAILURE, PERMANENT_FAILURE) instead of a boolean. Control flow and scheduling now use CallbackResult.type() and propagate an optional reason for failures. A new CallbackResult record models outcome and reason.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant CallbackUrlService
    participant CallbackRedirectValidator
    participant DnsResolver
    participant HttpClient
    participant RemoteServer

    Caller->>CallbackUrlService: fetchCallbackUrl(callbackUrl)
    CallbackUrlService->>CallbackRedirectValidator: validateUrl(callbackUrl)
    alt validation fails
        CallbackRedirectValidator-->>CallbackUrlService: invalid / null
        CallbackUrlService-->>Caller: CallbackResult.permanentFailure(reason)
    else validation succeeds
        CallbackRedirectValidator-->>CallbackUrlService: validatedUrl (originalUrl, pinnedHost)
        CallbackUrlService->>DnsResolver: createResolver(pinnedHost)
        CallbackUrlService->>HttpClient: execute GET validatedUrl.originalUrl() with custom DnsResolver
        HttpClient->>DnsResolver: resolve(host)
        DnsResolver->>HttpClient: ip or UnknownHostException
        HttpClient->>RemoteServer: TCP/HTTP request (if resolved)
        RemoteServer-->>HttpClient: HTTP response (status)
        HttpClient-->>CallbackUrlService: response or IOException
        alt HTTP 2xx
            CallbackUrlService-->>Caller: CallbackResult.success()
        else IOException / non-2xx
            CallbackUrlService-->>Caller: CallbackResult.transientFailure(reason) or CallbackResult.permanentFailure(reason)
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding callback URL validation to enforce fetch URL properties, which aligns with the primary purpose of this PR.
Description check ✅ Passed The description is directly related to the changeset, explaining what the PR does (adds URL validation to callback URLs) and why (aligns with existing validation patterns).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@antobinary antobinary added this to the Release 3.0 milestone Mar 31, 2026

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java (1)

34-34: Consider adding null-check for robustness.

The callbackRedirectValidator field is used without null-check in fetchCallbackUrl(). While Spring injection should always provide this dependency, a defensive check would prevent NPE during testing or misconfiguration.

🛡️ Optional: Add defensive null-check
 	private boolean fetchCallbackUrl(final String callbackUrl) {
+		if (callbackRedirectValidator == null) {
+			log.error("Callback redirect validator not configured; blocking request to [{}]", callbackUrl);
+			return false;
+		}
 		ValidatedUrl validatedUrl = callbackRedirectValidator.validateUrl(callbackUrl);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java`
at line 34, The field callbackRedirectValidator in class CallbackUrlService is
used in fetchCallbackUrl() without a null-check; add a defensive null-check at
the start of fetchCallbackUrl() to handle misconfiguration or testing scenarios
(e.g., if callbackRedirectValidator == null) and either throw a clear
IllegalStateException or log an error and return a safe default/empty result so
the method does not NPE; update any unit tests if they rely on the old behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java`:
- Line 34: The field callbackRedirectValidator in class CallbackUrlService is
used in fetchCallbackUrl() without a null-check; add a defensive null-check at
the start of fetchCallbackUrl() to handle misconfiguration or testing scenarios
(e.g., if callbackRedirectValidator == null) and either throw a clear
IllegalStateException or log an error and return a safe default/empty result so
the method does not NPE; update any unit tests if they rely on the old behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 24bf63da-b561-4d81-90ce-f166851e0406

📥 Commits

Reviewing files that changed from the base of the PR and between c2287a8 and 7664c00.

📒 Files selected for processing (3)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/CallbackRedirectValidatorService.java
  • bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java
  • bigbluebutton-web/grails-app/conf/spring/resources.xml

Copilot AI 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.

Pull request overview

Adds security validation for meeting-ended callback URLs so they follow the same URL allow/block/DNS-rebinding protections already used for other “fetch URL” entry points.

Changes:

  • Registers a new Spring bean (callbackRedirectValidator) configured from fetchUrl* properties and injects it into callbackUrlService.
  • Updates CallbackUrlService to validate callback URLs, pin DNS resolution, and apply request timeouts before issuing the HTTP GET.
  • Introduces CallbackRedirectValidatorService as a BaseUrlRedirectValidator specialization for callback URLs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
bigbluebutton-web/grails-app/conf/spring/resources.xml Adds and wires the callback URL validator bean into the callback service.
bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java Enforces URL validation + DNS pinning and sets HTTP timeouts for callback requests.
bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/CallbackRedirectValidatorService.java New validator type for callback URL validation (inherits base security checks).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@antobinary
antobinary requested a review from gustavotrott April 8, 2026 15:41
@gustavotrott

Copy link
Copy Markdown
Contributor

It's working, but I see the callback log saying Callback failed but retrying, what I think will not happen.
It would be better to show the reason of the failure for log callback_failed_retry and don't say it will retry.
In case it requires a bigger refactor we can address in a different PR.
See the logs when failing:

2026-04-08T16:50:13.348-03:00 INFO o.b.a.s.i.BaseUrlRedirectValidator - Validating and resolving URL [https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks=false&meetingID=random-33669]
2026-04-08T16:50:13.348-03:00 ERROR o.b.a.s.i.BaseUrlRedirectValidator - Address [172.17.0.2] is a private/site-local address
2026-04-08T16:50:13.349-03:00 ERROR o.b.w.s.callback.CallbackUrlService - Callback URL [https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks=false&meetingID=random-33669] failed security validation; blocking request.
2026-04-08T16:50:13.349-03:00 INFO o.b.w.s.callback.CallbackUrlService - --analytics-- data={"retryInMs":30000,"logCode":"callback_failed_retry","name":"random-33669","callback":"https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks\u003dfalse\u0026meetingID\u003drandom-33669 ","description":"Callback failed but retrying.","meetingId":"60b3fe5d1e821644b61e423bf33a0353aedc0b57-1775677805844","externalMeetingId":"random-33669","attempts":1}

@gustavotrott

Copy link
Copy Markdown
Contributor

@antobinary please add a note in the release notes clarifying that anyone using a local address as the meta_endCallbackUrl will now need to explicitly allow that hostname in bbb-web.properties, using the fetchUrlAllowedLocalHosts configuration.

@antobinary

Copy link
Copy Markdown
Member

@gustavotrott while I can mention it, perhaps it would warrant a mention in the docs, for example in https://github.com/bigbluebutton/bigbluebutton/blob/v3.0.x-develop/docs/docs/new-features.md?plain=1#L408

What do you think?

@antobinary antobinary mentioned this pull request Apr 8, 2026
22 of 26 tasks
@gustavotrott

gustavotrott commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

@gustavotrott while I can mention it, perhaps it would warrant a mention in the docs, for example in https://github.com/bigbluebutton/bigbluebutton/blob/v3.0.x-develop/docs/docs/new-features.md?plain=1#L408

What do you think?

yes, a mention there would be welcome!

@paultrudel

Copy link
Copy Markdown
Collaborator Author

It's working, but I see the callback log saying Callback failed but retrying, what I think will not happen. It would be better to show the reason of the failure for log callback_failed_retry and don't say it will retry. In case it requires a bigger refactor we can address in a different PR. See the logs when failing:

2026-04-08T16:50:13.348-03:00 INFO o.b.a.s.i.BaseUrlRedirectValidator - Validating and resolving URL [https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks=false&meetingID=random-33669]
2026-04-08T16:50:13.348-03:00 ERROR o.b.a.s.i.BaseUrlRedirectValidator - Address [172.17.0.2] is a private/site-local address
2026-04-08T16:50:13.349-03:00 ERROR o.b.w.s.callback.CallbackUrlService - Callback URL [https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks=false&meetingID=random-33669] failed security validation; blocking request.
2026-04-08T16:50:13.349-03:00 INFO o.b.w.s.callback.CallbackUrlService - --analytics-- data={"retryInMs":30000,"logCode":"callback_failed_retry","name":"random-33669","callback":"https://bbb30.bbb.imdt.dev/bigbluebutton/api/?recordingmarks\u003dfalse\u0026meetingID\u003drandom-33669 ","description":"Callback failed but retrying.","meetingId":"60b3fe5d1e821644b61e423bf33a0353aedc0b57-1775677805844","externalMeetingId":"random-33669","attempts":1}

Up to 4 retries will occur over a period of around 8 minutes. Although it does not make sense for URLs that have failed validation to be retried. I will send an update to prevent retries in those scenarios. Failure reasons are logged separately as can be seen in the log which states "Callback URL failed security validation; blocking request". I'm not sure if it is worth it to move the reason into the main log.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java (1)

219-225: Classify obvious permanent 4xx responses separately.

Returning TRANSIENT_FAILURE for every non-2xx still retries cases like 400/401/403/404/410 that are unlikely to self-heal. That keeps the retry loop noisy and wastes ~8 minutes before give-up for simple misconfigurations.

Possible refinement
 			try (CloseableHttpResponse response = httpClient.execute(request)) {
 				int statusCode = response.getStatusLine().getStatusCode();
 				if (statusCode >= 200 && statusCode < 300) {
 					return CallbackResult.success();
 				}
-				return CallbackResult.transientFailure(
-						"HTTP " + statusCode + " response from callback URL");
+				if (statusCode >= 400 && statusCode < 500
+						&& statusCode != 408
+						&& statusCode != 429) {
+					return CallbackResult.permanentFailure(
+							"HTTP " + statusCode + " response from callback URL");
+				}
+				return CallbackResult.transientFailure(
+						"HTTP " + statusCode + " response from callback URL");
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java`
around lines 219 - 225, The current handling in CallbackUrlService's HTTP
response block treats all non-2xx as transient; change it to classify obvious
permanent 4xx errors as permanent failures: after obtaining statusCode in the
try-with-resources block, if statusCode is between 400 and 499 (except for
rate-limit 429 which should remain transient) return
CallbackResult.permanentFailure("HTTP " + statusCode + " response from callback
URL"); keep 5xx and 429 as CallbackResult.transientFailure as before and leave
2xx returning CallbackResult.success(); this uses the existing statusCode branch
in CallbackUrlService to avoid noisy retries for client-side misconfiguration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java`:
- Around line 210-229: The synchronous httpClient.execute(...) call in
CallbackUrlService blocks the single-thread callback worker; refactor so
outbound HTTP is performed off the single-thread executor by either using an
async HTTP client (HttpAsyncClients) or submitting the blocking work to a
dedicated bounded thread pool (ExecutorService) and awaiting its result with a
strict timeout. Specifically, replace the CloseableHttpClient/execute(...) usage
(and the CloseableHttpResponse handling) with an asynchronous call or wrap the
execute() block for validatedUrl.originalUrl() in a Runnable/Callable submitted
to a separate executor, propagate timeouts and IOException into the same
CallbackResult.transientFailure(...) path, and ensure resources (http client,
response) are closed in the async/worker task; keep existing headers
(Accept-Language, User-Agent), requestConfig, pinnedDnsResolver and the
CallbackResult.success()/transientFailure(...) semantics.

---

Nitpick comments:
In
`@bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java`:
- Around line 219-225: The current handling in CallbackUrlService's HTTP
response block treats all non-2xx as transient; change it to classify obvious
permanent 4xx errors as permanent failures: after obtaining statusCode in the
try-with-resources block, if statusCode is between 400 and 499 (except for
rate-limit 429 which should remain transient) return
CallbackResult.permanentFailure("HTTP " + statusCode + " response from callback
URL"); keep 5xx and 429 as CallbackResult.transientFailure as before and leave
2xx returning CallbackResult.success(); this uses the existing statusCode branch
in CallbackUrlService to avoid noisy retries for client-side misconfiguration.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2f0141e2-7b93-4d96-bc69-a43df83cc9fb

📥 Commits

Reviewing files that changed from the base of the PR and between 7664c00 and b7c4010.

📒 Files selected for processing (3)
  • bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackResult.java
  • bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.java
  • bigbluebutton-web/grails-app/conf/spring/resources.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • bigbluebutton-web/grails-app/conf/spring/resources.xml

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@antobinary antobinary mentioned this pull request Apr 17, 2026
6 of 9 tasks
@antobinary antobinary mentioned this pull request Apr 28, 2026
12 of 17 tasks

@gustavotrott gustavotrott 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!

@antobinary
antobinary merged commit 4c1a341 into bigbluebutton:v3.0.x-develop Apr 28, 2026
33 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.

4 participants