Skip to content

refactor(bbb-web): Update Plugin URL Handling - #24996

Merged
gustavotrott merged 5 commits into
bigbluebutton:v3.0.x-developfrom
paultrudel:plugin-url-fix
Apr 29, 2026
Merged

gustavotrott merged 5 commits into
bigbluebutton:v3.0.x-developfrom
paultrudel:plugin-url-fix

Conversation

@paultrudel

Copy link
Copy Markdown
Collaborator

What does this PR do?

Updates plugin URL handling to match the pattern that is used for other user submitted URLs.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes implement secure plugin manifest retrieval by introducing a ValidatedUrl abstraction and delegating downloads to a SecureUrlDownloader service. Plugin manifest fetching is refactored across multiple components to validate URLs via PluginRedirectValidatorService, enforce configurable payload size limits, and associate validation metadata with manifests. The PluginRedirectValidatorService is refactored to support URL prefix-based bypass rules for local plugins. Spring configuration is updated to wire the new secure download dependencies and validation rules throughout the plugin manifest pipeline.

Sequence Diagram

sequenceDiagram
    participant PU as PluginUtils
    participant PRV as PluginRedirectValidatorService
    participant SUD as SecureUrlDownloader
    participant MS as MeetingService
    participant PM as PluginManifest

    PU->>PRV: followRedirectSecure(manifestUrl)
    activate PRV
    PRV-->>PU: ValidatedUrl or null
    deactivate PRV
    
    alt ValidatedUrl received
        PU->>SUD: downloadToString(validatedUrl, timeout, maxPayloadKiB)
        activate SUD
        SUD-->>PU: manifest JSON content or null
        deactivate SUD
        
        alt Content downloaded
            PU->>PM: new PluginManifest(url, checksum, validatedUrl)
            activate PM
            PM->>PM: store ValidatedUrl metadata
            PM-->>PU: PluginManifest instance
            deactivate PM
            PU->>MS: register PluginManifest
        else Download failed
            PU->>MS: record error (download returned null)
        end
    else Validation failed
        PU->>MS: record error (security validation failed)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: refactoring plugin URL handling to use a secure, validated approach matching other user-submitted URL patterns.
Description check ✅ Passed The description clearly relates to the changeset, explaining that the PR updates plugin URL handling to match patterns used for other user-submitted URLs.
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.

✏️ 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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/service/SecureUrlDownloader.java (1)

91-105: ⚠️ Potential issue | 🟠 Major

Enforce the payload cap on bytes, not decoded characters.

maxSizeKib is a byte limit, but this loop decrements remaining by characters read from a BufferedReader. A UTF-8 response with multibyte characters can therefore exceed the configured payload cap and still pass. Since this helper now protects plugin manifests and client-settings downloads, the limit needs to be enforced on the raw response bytes before decoding.

Suggested direction
-                StringBuilder sb = new StringBuilder(8192);
-                int remaining = maxSizeKib * 1024;
-
-                try (BufferedReader reader = new BufferedReader(
-                        new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8))) {
-                    char[] buf = new char[4096];
+                int remaining = maxSizeKib * 1024;
+                ByteArrayOutputStream out = new ByteArrayOutputStream(Math.min(remaining, 8192));
+
+                try (InputStream in = response.getEntity().getContent()) {
+                    byte[] buf = new byte[4096];
                     int n;
-                    while ((n = reader.read(buf)) != -1) {
+                    while ((n = in.read(buf)) != -1) {
                         remaining -= n;
                         if (remaining < 0) {
                             log.warn("Response from [{}] exceeded maximum allowed payload size ({} KiB) for context [{}]",
                                     validatedUrl.originalUrl(), maxSizeKib, contextId);
                             return null;
                         }
-                        sb.append(buf, 0, n);
+                        out.write(buf, 0, n);
                     }
                 }
 
-                return sb.toString();
+                return out.toString(StandardCharsets.UTF_8);
🤖 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/api/service/SecureUrlDownloader.java`
around lines 91 - 105, The loop in SecureUrlDownloader currently enforces
maxSizeKib by counting characters from BufferedReader, which miscounts UTF-8
multibyte bytes; instead read the raw InputStream from
response.getEntity().getContent() into a byte buffer (e.g., in secureDownload or
the method containing sb, remaining, reader) and decrement remaining by the
number of bytes read, aborting when remaining < 0 and logging as before; only
after fully reading and verifying the byte cap convert the accumulated bytes to
a UTF-8 string (or StringBuilder) to produce the response body so the byte limit
(maxSizeKib) is correctly enforced.
🧹 Nitpick comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1)

8-13: Keep url and validatedUrl immutable, or update them together.

These two fields now represent one security-sensitive invariant, but callers can still mutate them independently. MeetingService keys and logs by getUrl() while downloading through getValidatedUrl(), so a partial update can leave the manifest pointing at one URL and fetching another. I’d strongly prefer making them final or exposing a single updater that preserves consistency.

Also applies to: 44-49

🤖 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/api/domain/PluginManifest.java`
around lines 8 - 13, PluginManifest currently allows url and validatedUrl to be
mutated independently which breaks the security invariant used by MeetingService
(getUrl vs getValidatedUrl). Fix by making both fields immutable (declare url
and validatedUrl final and only set them in the constructors including the other
constructor overload) OR replace independent setters with a single atomic
updater method (e.g., setUrlAndValidatedUrl(String url, ValidatedUrl
validatedUrl)) that updates both together and is synchronized. Ensure getters
(getUrl/getValidatedUrl) continue to return the same consistent pair and update
all constructors/overloads (the other constructor around lines 44-49) to
initialize both fields.
🤖 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/api/service/impl/PluginRedirectValidatorService.java`:
- Around line 8-12: The isUrlBypassed method currently uses raw startsWith and
must instead parse and normalize both the configured localPluginUrlPrefix and
the incoming redirectUrl (use URI/URL parsing and normalize the path to remove
.. segments), then compare scheme, host and port for equality and ensure the
normalized path is either exactly "/plugins" or has "/plugins/" as its leading
segment (i.e. a descendant) before returning true; update isUrlBypassed to
reject sibling prefixes like "/plugins-extra" and any URLs whose normalized path
escapes the plugins directory while keeping references to localPluginUrlPrefix
and BaseUrlRedirectValidator for locating the logic.

---

Outside diff comments:
In
`@bbb-common-web/src/main/java/org/bigbluebutton/api/service/SecureUrlDownloader.java`:
- Around line 91-105: The loop in SecureUrlDownloader currently enforces
maxSizeKib by counting characters from BufferedReader, which miscounts UTF-8
multibyte bytes; instead read the raw InputStream from
response.getEntity().getContent() into a byte buffer (e.g., in secureDownload or
the method containing sb, remaining, reader) and decrement remaining by the
number of bytes read, aborting when remaining < 0 and logging as before; only
after fully reading and verifying the byte cap convert the accumulated bytes to
a UTF-8 string (or StringBuilder) to produce the response body so the byte limit
(maxSizeKib) is correctly enforced.

---

Nitpick comments:
In
`@bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java`:
- Around line 8-13: PluginManifest currently allows url and validatedUrl to be
mutated independently which breaks the security invariant used by MeetingService
(getUrl vs getValidatedUrl). Fix by making both fields immutable (declare url
and validatedUrl final and only set them in the constructors including the other
constructor overload) OR replace independent setters with a single atomic
updater method (e.g., setUrlAndValidatedUrl(String url, ValidatedUrl
validatedUrl)) that updates both together and is synchronized. Ensure getters
(getUrl/getValidatedUrl) continue to return the same consistent pair and update
all constructors/overloads (the other constructor around lines 44-49) to
initialize both fields.
🪄 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: 07f23852-0b8f-4005-b451-8189c3486e9d

📥 Commits

Reviewing files that changed from the base of the PR and between 69a8230 and 55255a9.

📒 Files selected for processing (7)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/service/SecureUrlDownloader.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/PluginRedirectValidatorService.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java
  • bigbluebutton-web/grails-app/conf/spring/resources.xml

Comment on lines +8 to +12
protected boolean isUrlBypassed(String redirectUrl) {
return localPluginUrlPrefix != null
&& !localPluginUrlPrefix.isEmpty()
&& redirectUrl != null
&& redirectUrl.startsWith(localPluginUrlPrefix);

@coderabbitai coderabbitai Bot Apr 29, 2026 •

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.

⚠️ Potential issue | 🔴 Critical

Normalize and scope the local-plugin bypass before returning true.

BaseUrlRedirectValidator skips the public-routability checks as soon as isUrlBypassed() returns true. A raw startsWith() lets unnormalized paths like /plugins/../api/... and sibling prefixes like /plugins-extra/... inherit that bypass. Parse and normalize the URL first, then require the same scheme/host/port and a path that is exactly /plugins or a descendant of it.

Suggested direction
     `@Override`
     protected boolean isUrlBypassed(String redirectUrl) {
-        return localPluginUrlPrefix != null
-                && !localPluginUrlPrefix.isEmpty()
-                && redirectUrl != null
-                && redirectUrl.startsWith(localPluginUrlPrefix);
+        if (localPluginUrlPrefix == null || localPluginUrlPrefix.isEmpty()
+                || redirectUrl == null || redirectUrl.isEmpty()) {
+            return false;
+        }
+
+        try {
+            URI allowed = URI.create(localPluginUrlPrefix).normalize();
+            URI candidate = URI.create(redirectUrl).normalize();
+
+            String allowedPath = allowed.getPath().endsWith("/")
+                    ? allowed.getPath()
+                    : allowed.getPath() + "/";
+
+            return allowed.getScheme().equalsIgnoreCase(candidate.getScheme())
+                    && allowed.getHost().equalsIgnoreCase(candidate.getHost())
+                    && effectivePort(allowed) == effectivePort(candidate)
+                    && (candidate.getPath().equals(allowed.getPath())
+                        || candidate.getPath().startsWith(allowedPath));
+        } catch (IllegalArgumentException e) {
+            return false;
+        }
     }
🤖 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/api/service/impl/PluginRedirectValidatorService.java`
around lines 8 - 12, The isUrlBypassed method currently uses raw startsWith and
must instead parse and normalize both the configured localPluginUrlPrefix and
the incoming redirectUrl (use URI/URL parsing and normalize the path to remove
.. segments), then compare scheme, host and port for equality and ensure the
normalized path is either exactly "/plugins" or has "/plugins/" as its leading
segment (i.e. a descendant) before returning true; update isUrlBypassed to
reject sibling prefixes like "/plugins-extra" and any URLs whose normalized path
escapes the plugins directory while keeping references to localPluginUrlPrefix
and BaseUrlRedirectValidator for locating the logic.

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.

make sense, I'll address in a subsequent PR.

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.

@gustavotrott, understood! Would you like me to open a follow-up GitHub issue to track the isUrlBypassed() normalization and path-scoping fix so it doesn't get lost?

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.

@gustavotrott, understood! Would you like me to open a follow-up GitHub issue to track the isUrlBypassed() normalization and path-scoping fix so it doesn't get lost?

Yes please! (curious what the issue would look like, maybe there'd be some test sample data even)

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

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.

Yes, open the issue @coderabbitai

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.

🧩 Analysis chain

🏁 Script executed:

gh issue create \
  --repo bigbluebutton/bigbluebutton \
  --title "refactor(bbb-web): Normalize and scope localPluginUrlPrefix bypass in PluginRedirectValidatorService" \
  --assignee gustavotrott \
  --body "## Summary

The \`isUrlBypassed()\` method in [\`PluginRedirectValidatorService\`](https://github.com/bigbluebutton/bigbluebutton/blob/v3.0.x-develop/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/PluginRedirectValidatorService.java) currently uses a raw \`startsWith()\` check to decide whether a redirect URL may bypass public-routability validation. This approach has two security weaknesses:

1. **Path traversal** – an unnormalized URL such as \`/plugins/../api/internalEndpoint\` starts with \`/plugins\` but resolves outside the intended directory after normalization.
2. **Sibling-prefix bypass** – a URL like \`/plugins-extra/malicious\` also starts with the configured prefix \`/plugins\`, unintentionally inheriting the bypass.

## Affected file

\`bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/PluginRedirectValidatorService.java\`

## Suggested fix direction

Parse and normalize both \`localPluginUrlPrefix\` and the incoming \`redirectUrl\` using \`java.net.URI\`, then enforce:
- **Same scheme, host, and port.**
- **Path** is exactly the allowed path *or* starts with \`allowedPath + \"/\"\`.

```java
`@Override`
protected boolean isUrlBypassed(String redirectUrl) {
    if (localPluginUrlPrefix == null || localPluginUrlPrefix.isEmpty()
            || redirectUrl == null || redirectUrl.isEmpty()) {
        return false;
    }

    try {
        URI allowed    = URI.create(localPluginUrlPrefix).normalize();
        URI candidate  = URI.create(redirectUrl).normalize();

        String allowedPath = allowed.getPath().endsWith("/")
                ? allowed.getPath()
                : allowed.getPath() + "/";

        return allowed.getScheme().equalsIgnoreCase(candidate.getScheme())
                && allowed.getHost().equalsIgnoreCase(candidate.getHost())
                && effectivePort(allowed) == effectivePort(candidate)
                && (candidate.getPath().equals(allowed.getPath())
                    || candidate.getPath().startsWith(allowedPath));
    } catch (IllegalArgumentException e) {
        return false;
    }
}
```

## Sample test data

| \`localPluginUrlPrefix\`               | \`redirectUrl\`                                   | Expected \`isUrlBypassed()\` |
|----------------------------------------|---------------------------------------------------|------------------------------|
| \`http://bbb.example.com/plugins\`     | \`http://bbb.example.com/plugins/myplugin.js\`    | \`true\`  ✅ legitimate       |
| \`http://bbb.example.com/plugins\`     | \`http://bbb.example.com/plugins\`                | \`true\`  ✅ exact match      |
| \`http://bbb.example.com/plugins\`     | \`http://bbb.example.com/plugins-extra/evil.js\`  | \`false\` ❌ sibling prefix   |
| \`http://bbb.example.com/plugins\`     | \`http://bbb.example.com/plugins/../api/secret\`  | \`false\` ❌ path traversal   |
| \`http://bbb.example.com/plugins\`     | \`https://bbb.example.com/plugins/myplugin.js\`   | \`false\` ❌ scheme mismatch  |
| \`http://bbb.example.com/plugins\`     | \`http://evil.com/plugins/myplugin.js\`           | \`false\` ❌ host mismatch    |
| \`http://bbb.example.com:8080/plugins\`| \`http://bbb.example.com/plugins/myplugin.js\`    | \`false\` ❌ port mismatch    |
| \`null\` or \`\`                       | \`http://bbb.example.com/plugins/myplugin.js\`    | \`false\` ❌ no prefix set    |

## References

- PR introducing the bypass: https://github.com/bigbluebutton/bigbluebutton/pull/24996
- Review comment: https://github.com/bigbluebutton/bigbluebutton/pull/24996#discussion_r3162998195
- Requested by: `@gustavotrott`"

Length of output: 5284


@gustavotrott, the follow-up issue has been created! 🎉

➡️ #24997

It includes:

  • A description of both weaknesses (path traversal via ../ and sibling-prefix bypass)
  • A suggested fix direction using URI.normalize() with scheme/host/port/path checks
  • A table of sample test data covering the happy path, sibling prefixes, path traversal, scheme mismatch, host mismatch, port mismatch, and null/empty prefix cases
  • Backlinks to this PR and the original review comment

(∩`-´)⊃━☆゚.*・。゚

@antobinary antobinary added this to the Release 3.0 milestone Apr 29, 2026
@antobinary
antobinary requested a review from gustavotrott April 29, 2026 17:39
@gustavotrott

Copy link
Copy Markdown
Contributor

LGTM!

I tested with local plugins and it works.
Validation working fine.

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@gustavotrott
gustavotrott merged commit 7318c35 into bigbluebutton:v3.0.x-develop Apr 29, 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.

3 participants