Repository navigation
fix(bbb-web): Add Callback URL Validation - #24828
Conversation
WalkthroughAdds 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 DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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
callbackRedirectValidatorfield is used without null-check infetchCallbackUrl(). 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
📒 Files selected for processing (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/CallbackRedirectValidatorService.javabbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.javabigbluebutton-web/grails-app/conf/spring/resources.xml
There was a problem hiding this comment.
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 fromfetchUrl*properties and injects it intocallbackUrlService. - Updates
CallbackUrlServiceto validate callback URLs, pin DNS resolution, and apply request timeouts before issuing the HTTP GET. - Introduces
CallbackRedirectValidatorServiceas aBaseUrlRedirectValidatorspecialization 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.
|
It's working, but I see the callback log saying
|
|
@antobinary please add a note in the release notes clarifying that anyone using a local address as the |
|
@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! |
…on into callback-url-validation
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. |
|
There was a problem hiding this comment.
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_FAILUREfor 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
📒 Files selected for processing (3)
bbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackResult.javabbb-common-web/src/main/java/org/bigbluebutton/web/services/callback/CallbackUrlService.javabigbluebutton-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
✅ Automated tests have passed! |



What does this PR do?
Adds URL validation to meeting ended callback URLs. Provided URLs must now respect the fetch URL properties:
fetchUrlSupportedProtocols,fetchUrlBlockedExternalHosts, andfetchUrlAllowedLocalHostsdefined inbigbluebutton.properties.Motivation
Callback URLs should follow the same pattern of validation used by presentation and client settings override URLs.