Skip to content

feat: added fields IP, User-Agent, Referer and sessionToken to UserJoinedMeetingEvtMsg - #23910

Closed
AtilaU19 wants to merge 3 commits into
bigbluebutton:v3.0.x-releasefrom
AtilaU19:task-2454
Closed

AtilaU19 wants to merge 3 commits into
bigbluebutton:v3.0.x-releasefrom
AtilaU19:task-2454

Conversation

@AtilaU19

Copy link
Copy Markdown
Contributor

What does this PR do?

Added IP, User Agent and Referer fields to the UserJoinedMeetingEvtMsg event.
Changes are necessary in bbb-webhooks to pass the data.

Closes Issue(s)

Closes None

More

bbbAppsAkka 2025-09-16T14:57:22.286Z INFO o.b.core2.AnalyticsActor - -- analytics -- {"envelope":{"name":"UserJoinedMeetingEvtMsg","routing":{"msgType":"BROADCAST_TO_MEETING","meetingId":"c2a6c19a9c936178284843 389ce797e0fb4d63f0-1758034624975","userId":"w_4tbvct7hw0r8"},"timestamp":1758034642223},"core":{"header":{"name":"UserJoinedMeetingEvtMsg","meetingId":"c2a6c19a9c936178284843389ce797e0fb4d63f0-1758034624975","us erId":"w_4tbvct7hw0r8"},"body":{"intId":"w_4tbvct7hw0r8","extId":"w_4tbvct7hw0r8","name":"User 4599924","role":"MODERATOR","bot":false,"guest":false,"authed":true,"guestStatus":"ALLOW","reactionEmoji":"none","ra iseHand":false,"away":false,"pin":false,"presenter":false,"locked":true,"avatar":"","webcamBackground":"","color":"#7b1fa2","clientType":"HTML5","sessionToken":["luu9hawec7fr6ict"],"ipAddress":"2804:1b2:9443:938 8:8df5:201c:ecbb:a21c","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36","referer":"https://mconf.github.io/","userMetadata":{}}}}

@coderabbitai

coderabbitai Bot commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change threads three new client metadata fields—ipAddress, userAgent, referer—through the user registration and join flows. Public APIs and message payloads are extended across web (Groovy/Java/Scala) and Akka layers: web controller captures headers and passes them to MeetingService, gateway (IBbbWebApiGWApp/BbbWebApiGWApp) forwards them into RegisterUser messages, MeetingsManagerActor and ToAkkaAppsSendersTrait include them in RegisterUserReqMsgBody, and core apps/models update RegisteredUsers.create and RegisteredUser. UserState and UserJoinedMeetingEvtMsgBody now also carry sessionToken and the new metadata. Control flow remains unchanged; only parameters and data structures are extended.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant WC as Web Controller (ApiController.groovy)
  participant MS as MeetingService (Java)
  participant GW as BbbWebApiGWApp / IBbbWebApiGWApp
  participant MMA as MeetingsManagerActor
  participant TAS as ToAkkaAppsSendersTrait
  participant MB as MsgBuilder
  participant AA as Akka Apps (RegisterUserReqMsgHdlr)
  participant RU as RegisteredUsers (model)

  Note over WC: Extract headers: X-Forwarded-For, User-Agent, Referer
  WC->>MS: registerUser(..., enforceLayout, logoutUrl, ipAddress, userAgent, referer, userMetadata)
  MS->>GW: registerUser(..., logoutUrl, ipAddress, userAgent, referer, userMetadata)
  GW->>MMA: RegisterUser(..., logoutUrl, ipAddress, userAgent, referer, userMetadata)
  MMA->>TAS: forward RegisterUser
  TAS->>MB: build RegisterUserReqMsgBody(..., logoutUrl, ipAddress, userAgent, referer, userMetadata)
  MB-->>AA: RegisterUserReqMsg
  AA->>RU: RegisteredUsers.create(..., logoutUrl, ipAddress, userAgent, referer, userMetadata, loggedOut=false)
  RU-->>AA: RegisteredUser created
Loading
sequenceDiagram
  autonumber
  participant Core as Core Apps (HandlerHelpers)
  participant Model as RegisteredUsers / UserState
  participant Evt as UserJoinedMeetingEvtMsgBuilder
  participant Bus as Event Bus

  Core->>Model: Build UserState(..., sessionToken, ipAddress, userAgent, referer, userMetadata)
  Core->>Evt: UserJoinedMeetingEvtMsgBody(..., sessionToken, ipAddress, userAgent, referer, userMetadata)
  Evt-->>Bus: Publish UserJoinedMeetingEvt
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • Tainan404

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title concisely and accurately summarizes the main change: adding IP, User-Agent, Referer, and sessionToken fields to the UserJoinedMeetingEvtMsg, which matches the changes across message definitions, UserState, and registration flows in the diff. It is specific, avoids vague terms, and directly reflects the primary intent of the changeset.
Description Check ✅ Passed The PR description states the goal (adding IP, User Agent, and Referer to UserJoinedMeetingEvtMsg), explains why (bbb-webhooks integration), and includes a concrete example payload showing the new fields (including sessionToken), so it is directly related to the changeset and on-topic. Although brief, the description describes the change and its intended use.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@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: 7

Caution

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

⚠️ Outside diff range comments (1)
bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy (1)

521-546: Gate new PII fields behind config and document retention

ipAddress, userAgent, referer are PII. Add a server property (default: off) to enable collection/forwarding, and document retention/redaction. Consider not persisting them, only emitting to webhooks if enabled.

🧹 Nitpick comments (10)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala (1)

67-71: PII propagation check: sessionToken/ip/UA/referer

Threading these into UserState is fine, but ensure downstream emission does not expose them to clients (see event builder comment). Consider masking before fan‑out.

bbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scala (2)

63-64: Keep logoutUrl validation consistent across builders

Nice: logoutUrl is validated here. The parallel sender (ToAkkaAppsSendersTrait) constructs RegisterUserReqMsgBody directly without the same check; refactor to reuse this builder or factor out a helper to avoid drift.


63-63: Optional: bound header field sizes before sending

Bound ipAddress/userAgent/referer lengths here as well to keep messages small and consistent.

bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala (1)

34-35: De‑duplicate message construction; inherit logoutUrl validation

Reuse MsgBuilder.buildRegisterUserRequestToAkkaApps(msg) to centralize validation and field wiring.

Apply:

   def sendRegisterUserRequestToAkkaApps(msg: RegisterUser): Unit = {
-    val routing = collection.immutable.HashMap("sender" -> "bbb-web")
-    val envelope = BbbCoreEnvelope(RegisterUserReqMsg.NAME, routing)
-    val header = BbbCoreHeaderWithMeetingId(RegisterUserReqMsg.NAME, msg.meetingId)
-    val body = RegisterUserReqMsgBody(meetingId = msg.meetingId, intUserId = msg.intUserId,
-      name = msg.name, firstName = msg.firstName, lastName = msg.lastName,
-      role = msg.role, extUserId = msg.extUserId, authToken = msg.authToken, sessionToken = msg.sessionToken,
-      avatarURL = msg.avatarURL, webcamBackgroundURL = msg.webcamBackgroundURL, bot = msg.bot,
-      guest = msg.guest, authed = msg.authed, guestStatus = msg.guestStatus, excludeFromDashboard = msg.excludeFromDashboard,
-      enforceLayout = msg.enforceLayout, logoutUrl = msg.logoutUrl, ipAddress = msg.ipAddress,
-      userAgent = msg.userAgent, referer = msg.referer, userMetadata = msg.userMetadata)
-    val req = RegisterUserReqMsg(header, body)
-    val message = BbbCommonEnvCoreMsg(envelope, req)
-    sendToBus(message)
+    val message = MsgBuilder.buildRegisterUserRequestToAkkaApps(msg)
+    sendToBus(message)
   }
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala (1)

61-65: LGTM; add light sanitization and consider named args

Before persisting, trim and bound the new strings to avoid oversized messages/DB fields. Using named args here would also reduce future arity bugs.

Example:

-      msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard, msg.body.enforceLayout, msg.body.logoutUrl, msg.body.ipAddress, msg.body.userAgent, msg.body.referer, msg.body.userMetadata, loggedOut = false)
+      msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard,
+      Option(msg.body.enforceLayout).getOrElse("").trim.take(128),
+      Option(msg.body.logoutUrl).getOrElse("").trim.take(2048),
+      Option(msg.body.ipAddress).getOrElse("").trim.take(128),
+      Option(msg.body.userAgent).getOrElse("").trim.take(512),
+      Option(msg.body.referer).getOrElse("").trim.take(1024),
+      msg.body.userMetadata, loggedOut = false)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala (1)

49-53: Validate RegisteredUsers.create argument ordering; prefer named args

Verified — RegisteredUsers.create (akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala) defines the trailing five String params as enforceLayout, logoutUrl, ipAddress, userAgent, referer (in that order). The positional call at akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala:49 maps the five "" strings to those params. Convert the call to use named arguments (at least for the trailing group) to prevent silent mis-wiring.

bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (2)

304-306: Harden inputs and fix minor spacing

  • Minor: remove extra spaces before commas in the signature.
  • Defensive: coerce potential nulls from Java boundary and clamp sizes to avoid oversized messages.

Apply:

-                   enforceLayout: String, logoutUrl: String, ipAddress: String , userAgent: String , referer: String,
+                   enforceLayout: String, logoutUrl: String, ipAddress: String, userAgent: String, referer: String,

Optional hardening:

   def registerUser(...,
-                   enforceLayout: String, logoutUrl: String, ipAddress: String, userAgent: String, referer: String,
+                   enforceLayout: String, logoutUrl: String, ipAddress: String, userAgent: String, referer: String,
                    userMetadata: java.util.Map[String, String]): Unit = {
+    def clamp(s: String, max: Int): String = Option(s).getOrElse("").take(max)
+    val ip  = clamp(ipAddress, 256)
+    val ua  = clamp(userAgent, 512)
+    val ref = clamp(referer, 1024)

318-319: Pass sanitized values to RegisterUser

If you adopt the clamping above, propagate ip, ua, ref here.

-      enforceLayout = enforceLayout, logoutUrl = logoutUrl, ipAddress = ipAddress, userAgent = userAgent, referer = referer, userMetadata = (userMetadata).asScala.toMap)
+      enforceLayout = enforceLayout, logoutUrl = logoutUrl, ipAddress = ip, userAgent = ua, referer = ref, userMetadata = (userMetadata).asScala.toMap)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (2)

135-141: Clamp/sanitize new header-derived fields at ingress

ipAddress, userAgent, referer can be arbitrarily large/tainted. Normalize and cap before constructing messages.

Apply:

   public void registerUser(String meetingID, String internalUserId,
                            String fullname, String firstName, String lastName, String role, String externUserID,
                            String authToken, String sessionToken, String avatarURL, String webcamBackgroundURL, Boolean bot,
                            Boolean guest, Boolean authed, String guestStatus, Boolean excludeFromDashboard, Boolean leftGuestLobby,
-                           String enforceLayout, String logoutUrl, String ipAddress, String userAgent, String referer, Map<String, String> userMetadata) {
+                           String enforceLayout, String logoutUrl, String ipAddress, String userAgent, String referer, Map<String, String> userMetadata) {
+    ipAddress = ipAddress == null ? "" : ipAddress.length() > 256 ? ipAddress.substring(0, 256) : ipAddress;
+    userAgent = userAgent == null ? "" : userAgent.length() > 512 ? userAgent.substring(0, 512) : userAgent;
+    referer   = referer   == null ? "" : referer.length()   > 1024 ? referer.substring(0, 1024) : referer;

632-634: Forwarding to GW updated; consider validating referer URL similar to logoutUrl

We validate logoutUrl in the gateway; do the same for referer if non-empty (defense-in-depth), or explicitly choose to keep it raw. Your call.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d472506 and 1e2d68d.

📒 Files selected for processing (16)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala (3 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1 hunks)
  • bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala (2 hunks)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (2 hunks)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (2 hunks)
  • bbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.java (1 hunks)
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (2 hunks)
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scala (1 hunks)
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala (1 hunks)
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala (1 hunks)
  • bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: jaapjansma
PR: bigbluebutton/bigbluebutton#21204
File: bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala:21-21
Timestamp: 2024-10-10T12:15:03.265Z
Learning: When reviewing code changes in BigBlueButton, particularly in case classes like `RegisterUser` in `MeetingsManagerActor.scala`, ensure to accurately distinguish between added parameters and replaced parameters to avoid incorrect assessments.
📚 Learning: 2024-10-10T12:15:03.265Z
Learnt from: jaapjansma
PR: bigbluebutton/bigbluebutton#21204
File: bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala:21-21
Timestamp: 2024-10-10T12:15:03.265Z
Learning: When reviewing code changes in BigBlueButton, particularly in case classes like `RegisterUser` in `MeetingsManagerActor.scala`, ensure to accurately distinguish between added parameters and replaced parameters to avoid incorrect assessments.

Applied to files:

  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scala
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala
  • bbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.java
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
  • bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala
  • bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala
  • bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java
  • bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
  • bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
🧬 Code graph analysis (3)
bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala (1)
bigbluebutton-html5/imports/ui/components/layout/push-layout/pushLayoutEngine.jsx (1)
  • enforceLayout (457-457)
bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (1)
bigbluebutton-html5/imports/ui/components/layout/push-layout/pushLayoutEngine.jsx (1)
  • enforceLayout (457-457)
bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (1)
bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala (1)
  • RegisterUser (18-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-package (bbb-webrtc)
  • GitHub Check: build-package (bbb-web)
  • GitHub Check: build-package (bbb-fsesl-akka)
  • GitHub Check: build-package (bbb-apps-akka)
🔇 Additional comments (9)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala (1)

20-24: Redact sessionToken from UserJoinedMeetingEvtMsg (do not broadcast session tokens)

sessionToken is included in a meeting-wide event — exposing it enables session/session-level impersonation; remove or redact it.

File: akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala (around lines 20–24)

Apply minimal redaction:

-      sessionToken = userState.sessionToken,
+      sessionToken = Vector.empty[String],

Confirm usages and body definition/order locally with:

  • rg -n --hidden -uu -S '\bUserJoinedMeetingEvtMsg\b'
  • rg -n --hidden -uu -S 'case class\s+UserJoinedMeetingEvtMsgBody(' bbb-common-message
bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala (1)

21-21: Signature alignment looks correct

RegisterUser includes ipAddress, userAgent, referer after logoutUrl and before userMetadata, matching the gateway and message builder.

bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)

141-145: OK: Extended RegisterUser message includes new fields

Construction passes through the new metadata correctly.

bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala (1)

9-13: Approve — RegisterUserReqMsgBody extension verified.

Builders populate ipAddress, userAgent, referer and the case class in UsersMsgs.scala includes them (see bbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scala and bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala).

bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (2)

56-58: LGTM: assignments correctly wire new fields

Field initialization matches constructor parameters.


36-36: Constructor signature expanded — Java callers verified

MeetingService.java (bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java:141) now constructs RegisterUser with the expanded parameters in the correct order (enforceLayout, logoutUrl, ipAddress, userAgent, referer, userMetadata). Scala usages in bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala use named args (separate constructor) and are unaffected.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala (3)

46-48: ```shell
#!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
echo "=== locate RegisteredUsers.scala ==="
fd -HI --hidden -g 'RegisteredUsers.scala' || true

echo
echo "=== search for model, fields and serializers (searching all files, ignoring .gitignore filtering) ==="
rg -n -C2 -P -uu '\bRegisteredUser\b' || true
rg -n -C2 -P -uu '\bipAddress\b|\buserAgent\b|\breferer\b' || true
rg -n -C3 -P -uu 'Format[(RegisteredUser|RegisteredUsers)]|implicit val .*Format.*RegisteredUser|play.api.libs.json' || true

echo
echo "=== search DAOs / repository usage and insert/update sites ==="
rg -n -C2 -P -uu '\b(UserDAO|RegisteredUserDAO|RegisteredUsersDAO|UserRepository|RegisteredUsersRepository)\b' || true
rg -n -C3 -P -uu '\b(insert|update|save|upsert)\b.*\bUser\b' || true

echo
echo "=== search for events / JSON builders / message serialization referencing these fields ==="
rg -n -C3 -P -uu '\bEvent\b.*RegisteredUser|\bRegisteredUser\b.*Event|toJson(|Json.toJson|writes(|reads(' || true

echo
echo "=== search DB migrations and SQL altering users table ==="
rg -n -C1 -P -uu 'db/migration|V[0-9]+__|ALTER TABLE|CREATE TABLE' || true
rg -n -C1 -P -uu '\busers\b|\bregistered_users\b' || true

echo
echo "=== show suspected SQL migration files (if any) ==="
rg -n -S -uu -g '*/db/migration/**' 'CREATE TABLE|ALTER TABLE' || true


---

`294-296`: ```shell
#!/bin/bash
set -euo pipefail

repo_root="."
file="akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala"

echo "FILE_EXISTS: $file -> $( [ -f "$file" ] && echo yes || echo no )"
echo

if [ -f "$file" ]; then
  echo "== SHOW RegisteredUsers.scala (lines 1-400) =="
  sed -n '1,400p' "$file" || true
  echo
fi

echo "== SEARCH (prefer ripgrep) =="
if command -v rg >/dev/null 2>&1; then
  RG="rg -n --hidden --no-ignore -S"
else
  RG="grep -RIn --line-number --binary-files=without-match"
fi

echo "-> occurrences of 'RegisteredUser' (limited to akka-bbb-apps/ and core/)"
$RG '\bRegisteredUser\b' akka-bbb-apps || true
echo

echo "-> occurrences of fields ipAddress|userAgent|referer|sessionToken"
$RG -e '\bipAddress\b' -e '\buserAgent\b' -e '\breferer\b' -e '\bsessionToken\b' || true
echo

echo "-> occurrences of 'UserJoinedMeetingEvtMsg'"
$RG '\bUserJoinedMeetingEvtMsg\b' || true
echo

echo "-> case class RegisteredUser definition (if present)"
$RG 'case class\s+RegisteredUser' || true
echo

echo "-> toString overrides in repo"
$RG 'override\s+def\s+toString' || true
echo

echo "-> explicit toString() calls mentioning RegisteredUser or sessionToken"
$RG 'RegisteredUser.*\.toString\(|sessionToken.*\.toString\(' || true
echo

echo "-> logging lines that reference RegisteredUser or sessionToken or ipAddress/userAgent/referer"
$RG '(logger|LOG|println|System\.out\.println).*(RegisteredUser|sessionToken|ipAddress|userAgent|referer)' || true
echo

echo "-> webhook/analytics/event emit mentions of these fields"
$RG '(emit|emitEvent|publish|webhook|analytics|track|sendEvent|post).*(RegisteredUser|sessionToken|ipAddress|userAgent|referer)' || true
echo

echo "== FALLBACK grep over akka-bbb-apps if above returned nothing =="
if ! command -v rg >/dev/null 2>&1; then
  echo "(rg not found; used grep fallback already)"
fi

echo
echo "== DONE =="

17-17: Create signature adds ipAddress/userAgent/referer — watch parameter bloat and verify callers

Signature in akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala now includes ipAddress, userAgent, referer (snippet below). Ensure all callers are updated to pass the new args in the same order; consider a parameter-object/builder in a future refactor.

Snippet:

             ipAddress: String, userAgent: String, referer: String, userMetadata: Map[String, String], loggedOut: Boolean,

Automated sandbox search did not locate callers (ripgrep skipped files). Run locally: rg -n --hidden -S --no-ignore-vcs 'RegisteredUsers.create\s*(' to confirm caller updates.

Comment on lines +454 to +457
sessionToken: Vector[String] = Vector(""),
ipAddress: String = "",
userAgent: String = "",
referer: String = "",

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.

🛠️ Refactor suggestion

🧩 Analysis chain

Default to Vector.empty and avoid placeholder token; also confirm source populates a vector

  • sessionToken should default to an empty collection, not Vector(""). The current default serializes as [""].
  • Upstream sources pass a single String token; verify it's wrapped as a proper non-empty vector before building events.

Apply:

-    sessionToken:          Vector[String]      = Vector(""),
+    sessionToken:          Vector[String]      = Vector.empty,

To verify call sites populating sessionToken as a collection:


🏁 Script executed:

#!/bin/bash
rg -nP -C2 --type=scala '\bUserState\('
rg -nP --type=scala 'sessionToken\s*[:=]'
rg -nP --type=scala 'UserJoinedMeetingEvtMsgBody\('

Length of output: 14437


Change sessionToken default to Vector.empty

  • Replace Vector("") (which serializes as [""]) with Vector.empty.

Apply:

-    sessionToken:          Vector[String]      = Vector(""),
+    sessionToken:          Vector[String]      = Vector.empty,

Verified callers use a Vector[String]: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala (append/remove tokens at lines ~227,234); akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala (passes userState.sessionToken); bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala (UserJoinedMeetingEvtMsgBody uses Vector[String]).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sessionToken: Vector[String] = Vector(""),
ipAddress: String = "",
userAgent: String = "",
referer: String = "",
sessionToken: Vector[String] = Vector.empty,
ipAddress: String = "",
userAgent: String = "",
referer: String = "",
🤖 Prompt for AI Agents
In akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
around lines 454-457, the sessionToken default is Vector("") which serializes as
a single empty string element; change it to Vector.empty to represent no tokens.
Update the default value to Vector.empty[String] so callers that expect an empty
vector receive an actual empty collection without altering usages in
RegisteredUsers.scala, UserJoinedMeetingEvtMsgBuilder.scala, or UsersMsgs.scala.

🛠️ Refactor suggestion

🧩 Analysis chain

PII fields added to UserState: set clear limits upstream

Storing raw ipAddress, userAgent, and referer in memory/state can balloon unexpectedly. Cap lengths (e.g., 256/512/1024) when extracting headers (controller layer) and strip control chars. Keep this file as-is; sanitize at ingress.

Search that sanitization occurs in the controller:


🏁 Script executed:

#!/bin/bash
rg -nP --type=groovy --type=scala '(clientIp|userAgent|referer)'

Length of output: 4482


Sanitize and cap incoming headers (IP, User‑Agent, Referer) in ApiController

ApiController currently reads headers raw (clientIp/request.getHeader("X-Forwarded-For"), userAgent/request.getHeader("User-Agent"), referer/request.getHeader("Referer") — bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy:437–439) and these values are propagated into user state/messages (Users2x.scala:454–457, MsgBuilder/RegisterUserReqMsgHdlr). Strip control characters and enforce length caps at ingress (suggest: ip ≤64, userAgent ≤512, referer ≤1024) when extracting headers; keep Users2x.scala unchanged and store only the sanitized values.

🤖 Prompt for AI Agents
In grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
around lines 437–439 (and note Users2x.scala lines 454–457 are the downstream
storage), the controller currently reads header values raw; change the header
extraction to sanitize and cap values at ingress: remove control characters and
trim whitespace, enforce maximum lengths ip ≤ 64, userAgent ≤ 512, referer ≤
1024, and handle nulls by defaulting to empty string; keep Users2x.scala
unchanged and pass only the sanitized/capped strings into the existing user
creation/message flow.

Comment on lines 66 to 69
val ru = RegisteredUsers.create(meetingId, userId = id, extId, name, "", "", role,
authToken, Vector(sessionToken), avatarURL, webcamBackgroundURL, color, bot,
guest, authed, guestStatus = GuestStatus.ALLOW, false, "", logoutUrl, Map(), false)
guest, authed, guestStatus = GuestStatus.ALLOW, false, "", "", "", "", logoutUrl, Map(), false)
RegisteredUsers.add(users, ru, meetingId)

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

🧩 Analysis chain

Bug: logoutUrl passed into referer position

Argument order is off. logoutUrl lands in referer, while logoutUrl itself is set to empty. Fix ordering (enforceLayout, logoutUrl, ipAddress, userAgent, referer).

Apply:

-      guest, authed, guestStatus = GuestStatus.ALLOW, false, "", "", "", "", logoutUrl, Map(), false)
+      guest, authed, guestStatus = GuestStatus.ALLOW, false, "", logoutUrl, "", "", "", Map(), false)

Check for other sites with the same mistake:


🏁 Script executed:

#!/bin/bash
rg -nP 'RegisteredUsers\.create\(' -C2 --glob '!**/target/**'

Length of output: 148


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "PWD: $(pwd)"
echo "Listing repo root (first 200 entries):"
ls -la | sed -n '1,200p' || true

echo
echo "Searching for RegisteredUsers.create occurrences (searching hidden and ignored files):"
rg -nP --hidden -uu 'RegisteredUsers\.create\s*\(' -C3 || true

echo
echo "Searching for RegisteredUsers.add occurrences (to find nearby calls):"
rg -nP --hidden -uu 'RegisteredUsers\.add\s*\(' -C3 || true

echo
echo "Searching for RegisteredUsers definition (object/class/trait):"
rg -nP --hidden -uu '^\s*(object|class|trait)\s+RegisteredUsers\b' -C2 || true

echo
echo "Listing files that define RegisteredUsers:"
rg -nP --hidden -uu '^\s*(object|class|trait)\s+RegisteredUsers\b' -l || true

for f in $(rg -nP --hidden -uu '^\s*(object|class|trait)\s+RegisteredUsers\b' -l || true); do
  echo
  echo "---- File: $f ----"
  sed -n '1,220p' "$f" || true
  echo "---- Searching for def create in $f ----"
  rg -nP --hidden -uu 'def\s+create\s*\(' "$f" -n -C3 || true
done

echo
echo "Searching for FakeUserGenerator.scala"
rg -n --hidden -uu 'FakeUserGenerator\.scala' -S || true

if [ -f "akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala" ]; then
  echo
  echo "---- akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (first 240 lines) ----"
  sed -n '1,240p' akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala || true
else
  echo
  echo "File akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala not found."
fi

Length of output: 34223


Bug: Incorrect parameter order in RegisteredUsers.create call

Examining the RegisteredUsers.create method signature and comparing the calls across the codebase reveals the issue. The correct parameter order should be:

def create(meetingId: String, userId: String, extId: String, name: String, firstName: String, lastName: String, roles: String,
           authToken: String, sessionToken: Vector[String], avatar: String, webcamBackground: String, color: String, bot: Boolean,
           guest: Boolean, authenticated: Boolean, guestStatus: String, excludeFromDashboard: Boolean, enforceLayout: String, logoutUrl: String,
           ipAddress: String, userAgent: String, referer: String, userMetadata: Map[String, String], loggedOut: Boolean)

In FakeUserGenerator.scala, the parameters are incorrectly ordered. The correct call should be:

-      guest, authed, guestStatus = GuestStatus.ALLOW, false, "", "", "", "", logoutUrl, Map(), false)
+      guest, authed, guestStatus = GuestStatus.ALLOW, false, "", logoutUrl, "", "", "", Map(), false)

This places logoutUrl in the correct logoutUrl parameter position instead of the referer position. The fix matches the pattern used in RegisterUserReqMsgHdlr.scala line 64 and TestDataGen.scala line 22.

🤖 Prompt for AI Agents
In
akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala
around lines 66-69 the arguments passed to RegisteredUsers.create are
misordered: logoutUrl is currently being passed into the referer position (and
subsequent args shifted), causing incorrect field assignments; reorder the call
to match the create signature so that logoutUrl is passed into the logoutUrl
parameter position and ensure the remaining trailing arguments map to ipAddress,
userAgent, referer, userMetadata, and loggedOut respectively (follow the same
argument order used in RegisterUserReqMsgHdlr.scala line 64 and
TestDataGen.scala line 22).

Comment on lines +107 to 111
sessionToken: Vector[String],
ipAddress: String,
userAgent: String,
referer: String,
userMetadata: Map[String, String]

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: Sensitive data is now broadcast to all clients via UserJoinedMeetingEvtMsg

sessionToken, ipAddress, userAgent, and referer in a client-facing event leak secrets/PII to every subscriber (including other participants and potentially recordings/proxies). The session token is an authentication secret.

Blocker: do not ship these fields in UserJoinedMeetingEvtMsgBody. If needed for webhooks/analytics, emit a separate server-only event (e.g., SysPub/SysCmd) or enrich webhook payloads at the server without rebroadcasting to clients.

Apply one of the following:

  1. Remove sensitive fields from the client event:
 case class UserJoinedMeetingEvtMsgBody(
   ...
-    clientType:       String,
-    sessionToken:     Vector[String],
-    ipAddress:        String,
-    userAgent:        String,
-    referer:          String,
-    userMetadata:     Map[String, String]
+    clientType:       String,
+    userMetadata:     Map[String, String]
 )
  1. Alternatively, gate behind a new internal-only event (recommended) and keep this event unchanged. I can draft the sys event + builder wiring if you want.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sessionToken: Vector[String],
ipAddress: String,
userAgent: String,
referer: String,
userMetadata: Map[String, String]
clientType: String,
userMetadata: Map[String, String]

Comment on lines +27 to +29
public final String ipAddress;
public final String userAgent;
public final String referer;

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

🧩 Analysis chain

New PII fields (ipAddress, userAgent, referer): confirm privacy controls and logging redaction

These are sensitive. Please:

  • Gate emission to external sinks (e.g., webhooks/analytics) behind a config flag and document retention.
  • Verify we don’t log these raw values (including via object dumps).
  • “Referer” spelling is intentional; confirm consistent naming across layers.

Run to spot potential logging and uses:


🏁 Script executed:

#!/bin/bash
# Find logs referencing these fields or dumping RegisterUser/RegisteredUser
rg -n -C2 -P '(logger\.|LOG|Slf4j|println).*(ipAddress|userAgent|referer)|\bRegisteredUser\(|\bRegisterUser\('

Length of output: 7198


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== HEAD: RegisterUser.java ==="
sed -n '1,240p' bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java || true
echo
echo "=== HEAD: RegisteredUser.java ==="
sed -n '1,240p' bbb-common-web/src/main/java/org/bigbluebutton/api/domain/RegisteredUser.java || true
echo
echo "=== HEAD: MeetingService.java ==="
sed -n '1,240p' bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java || true
echo
echo "=== HEAD: akka RegisteredUsers.scala ==="
sed -n '1,400p' akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala || true
echo
echo "=== HEAD: MeetingsManagerActor.scala ==="
sed -n '1,240p' bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala || true
echo
echo "=== occurrences of ipAddress / userAgent / referer (repo-wide) ==="
rg -n --hidden -S "(ipAddress|userAgent|referer)" -g '!**/node_modules/**' -C3 || true
echo
echo "=== logger lines that mention these fields or Register(ed)User ==="
rg -n --hidden -S "(logger\\.|LOG\\.|Slf4j|println).*(ipAddress|userAgent|referer|RegisterUser|RegisteredUser)" -g '!**/node_modules/**' -C2 || true
echo
echo "=== any toString / custom toString implementations (check dumping) ==="
rg -n --hidden -S "toString\\(|override def toString|def toString" -g '!**/node_modules/**' -C3 || true
echo
echo "=== JSON / serialization spots (Json.toJson / ObjectMapper / writeValueAsString / gson) ==="
rg -n --hidden -S "Json\\.toJson|Json\\.stringify|writeValueAsString|gson\\.toJson|ObjectMapper|play\\.api\\.libs\\.json|Json\\.parse" -g '!**/node_modules/**' -C3 || true
echo
echo "=== external sinks / analytics / webhook keywords ==="
rg -n --hidden -S "webhook|analytics|mixpanel|segment|amplitude|sentry|telemetry|applicationinsights|google-analytics|heap" -g '!**/node_modules/**' -C2 || true
echo
echo "=== HTTP header usage (User-Agent / Referer / X-Forwarded-For) ==="
rg -n --hidden -S -i "user-agent|referer|x-forwarded-for|X-Forwarded-For|User-Agent|Referer" -g '!**/node_modules/**' -C2 || true
echo
echo "=== places creating / forwarding RegisteredUser / RegisterUser (to inspect sinks) ==="
rg -n --hidden -S "new RegisterUser|new RegisteredUser|userRegistered\\(|userRegistered\\b|RegisterUser\\(" -g '!**/node_modules/**' -C3 || true

Length of output: 29899


Critical: ipAddress / userAgent / referer are being propagated and likely persisted — block/redact before emitting or logging

  • Verified: fields added to RegisterUser (bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java) and passed in MeetingService.registerUser; same fields appear in MeetingsManagerActor.RegisterUser (bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala) and in akka-bbb-apps RegisteredUser (akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala). RegisteredUsers.add calls UserDAO.insert(..., user) — so these PII values are forwarded into Akka apps and are very likely persisted.
  • Required actions (urgent):
    • Gate emission of these fields to any external sinks (webhooks/analytics) behind an explicit config flag and document retention/retention-periods.
    • Prevent raw logging or object dumps that include these fields (Scala case classes have auto toString). Implement redaction/masking (or remove) before any logging/serialization.
    • Avoid persisting raw IP/User‑Agent/Referer. If storage is necessary, store minimized/pseudonymized/hashes and record retention/erasure policy.
    • Confirm the spelling "referer" is intentional — it is currently used consistently across the files above; keep consistent or map to canonical header name when needed.
  • Fix locations to start with: RegisterUser.java, MeetingService.registerUser, MeetingsManagerActor.RegisterUser, akka-bbb-apps RegisteredUsers.scala (and UserDAO implementations called from there).
🤖 Prompt for AI Agents
In
bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java
lines 27-29, the ipAddress, userAgent and referer fields are being
propagated/persisted; modify flows so these fields are not emitted or logged
raw: add a configuration flag to gate emitting them to external sinks
(webhooks/analytics) and document retention; ensure any logging or
case-class-based serialization redacts or masks these fields (replace with
"[REDACTED]" or hashed/pseudonymized value) before creating messages or calling
toString; update MeetingService.registerUser, MeetingsManagerActor.RegisterUser
and the RegisteredUsers/UserDAO paths to avoid storing raw values (store
minimized/hashes only if necessary and record retention/erasure policy); verify
and keep the "referer" spelling consistent or map to canonical header name where
indicated.

Comment on lines 79 to 83
void registerUser(String meetingID, String internalUserId, String fullname, String firstName, String lastName, String role,
String externUserID, String authToken, String sessionToken, String avatarURL, String webcamBackgroundURL,
Boolean bot, Boolean guest, Boolean authed, String guestStatus, Boolean excludeFromDashboard,
String enforceLayout, String logoutUrl, Map<String, String> userMetadata);
String enforceLayout, String logoutUrl, String ipAddress, String userAgent, String referer, Map<String, String> userMetadata);
void registerUserSessionToken(String meetingID, String internalUserId, String sessionToken, String sessionName,

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

🧩 Analysis chain

Public interface break: confirm all implementers and callers updated

Adding ipAddress, userAgent, referer breaks binary/source compatibility. Ensure every implementer and invocation across modules/tests is updated.

Run:


🏁 Script executed:

#!/bin/bash
rg -nP --type=java --type=scala 'implements\s+IBbbWebApiGWApp'
rg -nP --type=java --type=scala -C2 '\bregisterUser\s*\(' | sed -n '1,200p'

Length of output: 4491


Public interface break — confirm all implementers & callers updated

IBbbWebApiGWApp.registerUser was extended to include ipAddress, userAgent, referer — this is a breaking change. Confirm and update every implementer and call site.

  • Found/verify locations to update:
    • interface: bbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.java (registerUser signature).
    • implementer candidate: bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (def registerUser).
    • mismatched callers/interfaces: bbb-common-web/src/main/java/org/bigbluebutton/api2/IMeetingService.java, bbb-common-web/src/main/java/org/bigbluebutton/api/pub/IPublisherService.java, and bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (registerUser method ~line 135 and gw.registerUser call ~line 629).
  • Action: update those signatures/calls to include the new params and run a repo-wide search for registerUser to catch tests/other modules.
🤖 Prompt for AI Agents
In bbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.java
around lines 79-83 the registerUser signature was extended to add ipAddress,
userAgent, and referer which breaks implementers/callers; update all
implementations and call sites to match the new signature — specifically modify
bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (def
registerUser),
bbb-common-web/src/main/java/org/bigbluebutton/api2/IMeetingService.java,
bbb-common-web/src/main/java/org/bigbluebutton/api/pub/IPublisherService.java,
and bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (the
registerUser method ~line 135 and gw.registerUser call ~line 629) to accept and
forward ipAddress, userAgent, referer; then run a repo-wide search for
registerUser to update all remaining callers and tests, compile and run unit
tests to ensure no signature mismatches remain.

Comment on lines +437 to +440
String clientIp = request.getHeader("X-Forwarded-For") ?: ""
String userAgent = request.getHeader('User-Agent') ?: ""
String referer = request.getHeader('Referer') ?: ""

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

Harden client IP extraction (trust boundary + parsing)

X‑Forwarded‑For is spoofable and may contain multiple IPs. Parse safely, optionally trust only configured proxies, and fall back to request.getRemoteAddr().

Example:

-    String clientIp = request.getHeader("X-Forwarded-For") ?: ""
+    String xff = request.getHeader("X-Forwarded-For") ?: ""
+    String xri = request.getHeader("X-Real-IP") ?: ""
+    String clientIp = ""
+    if (xff) {
+      // take first non-empty token; trim; cap length
+      clientIp = xff.split(",")[0].trim()
+    } else if (xri) {
+      clientIp = xri.trim()
+    } else {
+      clientIp = request.getRemoteAddr()
+    }
+    clientIp = clientIp?.take(128) ?: ""
-    String userAgent = request.getHeader('User-Agent') ?: ""
-    String referer = request.getHeader('Referer') ?: ""
+    String userAgent = (request.getHeader('User-Agent') ?: "").take(512)
+    String referer = (request.getHeader('Referer') ?: "").take(1024)

Add a config flag to only trust proxy headers when behind known proxies.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String clientIp = request.getHeader("X-Forwarded-For") ?: ""
String userAgent = request.getHeader('User-Agent') ?: ""
String referer = request.getHeader('Referer') ?: ""
String xff = request.getHeader("X-Forwarded-For") ?: ""
String xri = request.getHeader("X-Real-IP") ?: ""
String clientIp = ""
if (xff) {
// take first non-empty token; trim; cap length
clientIp = xff.split(",")[0].trim()
} else if (xri) {
clientIp = xri.trim()
} else {
clientIp = request.getRemoteAddr()
}
clientIp = clientIp?.take(128) ?: ""
String userAgent = (request.getHeader('User-Agent') ?: "").take(512)
String referer = (request.getHeader('Referer') ?: "").take(1024)

@github-actions

Copy link
Copy Markdown

Automated tests Summary

✅ All the CI tests have passed!

@gustavotrott

Copy link
Copy Markdown
Contributor

hey @AtilaU19, is this being added only for logging purposes?
If so, wouldn’t a log at bbb-web ApiController be enough instead of adding it in akka-apps?
But I guess you have other application listening UserJoinedMeetingEvtMsg that will use these info, right?


The current log wouldn’t detect cases where the client changes networks (and IP address) or when a user shares a session and the same userId connects from another device with a different User-Agent.
I think the best place to capture this info is at the Graphql connection level. Since a single userId can have multiple IPs and user agents, your approach wouldn’t catch it (UserJoinedMeetingEvtMsg isn’t triggered again on reconnection or session sharing).

We already use GraphQL connections to mark users as Mobile (see https://github.com/gustavotrott/bigbluebutton/blob/ca2c1635f3d3ebb12da12f2b18678ec00ebf403a/bigbluebutton-html5/imports/ui/components/connection-manager/component.tsx#L263), so it makes sense to attach other client-specific info there instead of per user ID.

You can still log everything in akka-apps, since UserGraphqlConnectionEstablishedSysMsg is handled there on every new Graphql connection.
Even if you need this info in other application, it could listen this message and have the needed info.

How does that sound? I can help/work on it if you’d like.

@antobinary antobinary added this to the Release 3.0 milestone Sep 16, 2025
@prlanzarin

prlanzarin commented Sep 16, 2025 •

Copy link
Copy Markdown
Member

The other application that consumes this information is bbb-webhooks.
The join event is handled atomically there - it's a direct mapping of the UserJoinedMeetingEvtMsg event and it's meaning should be preserved.

The fact that a user may join multiple sessions is something new in 3.0 that needs to be handled in an additive manner (i.e.: a new event in bbb-webhooks that is a direct mapping of a BBB event that represents this scenario), IMO. tl;dr I see the need for the fields to be represented in both the UserJoinedMeetingEvtMsg and whatever other events represent reconns/session sharing.

@gustavotrott

Copy link
Copy Markdown
Contributor

The fact that a user may join multiple sessions is something new in 3.0 that needs to be handled in an additive manner

This PR is targeting 3.0, so I’d rather we design it right from the start.
If this were legacy data, I’d agree with duplicating for compatibility, but here it feels like a new data being included.

Having the fields in both messages would just duplicate data.
Since this is a new scenario, why not consistently associate client-specific data with the connection instead? That keeps the model clearer IMO.

Do you have a use case where this info needs to be in UserJoinedMeetingEvtMsg and cannot wait until UserGraphqlConnectionEstablishedSysMsg?

@prlanzarin

prlanzarin commented Sep 16, 2025 •

Copy link
Copy Markdown
Member

I've forwarded that last reply to the consumers of those fields (yes, this contemplates an actual use case). I'll follow-up once I have an answer. Additionally:

  • Downstream components (i.e.: consumers of webhooks) are not prepared to handle any other "connection logic" other than join because that was never implemented in bbb-webhooks. Adding it in bbb-webhooks now is fine - downstream components, not so sure.
  • In case that is not feasible to implement in downstream components in the short-term, user-joined is the only path. The worry is as I've mentioned before: user-joined is handled atomically in webhooks. It has a strict event mapping and changing it's mapping to another source event with different behavior is a semantics change that may have unforeseen implications in downstream components.

If the consumers are fine with handling a new event from bbb-webhooks now, then not adding the fields in UserJoined would be fine. Wait for a reply with their stance.

@gustavotrott

Copy link
Copy Markdown
Contributor

If the consumers are fine with handling a new event from bbb-webhooks now, then not adding the fields in UserJoined would be fine. Wait for a reply with their stance.

Sounds good.

My only concern is that once we add these new fields to UserJoinedMeetingEvtMsg, it becomes very hard to ever remove them without introducing a breaking change. That’s why I’m insisting we validate whether it’s really necessary to include them in the join event instead of the connection.

We’ve been refactoring messages and database tables to consistently associate client-specific data with the connection rather than the user. For example, I recently had to move RTT tracking from the user level to the connection level, because each device can (and should) have a different connection status. This new case seems to follow a similar logic.

@prlanzarin

prlanzarin commented Sep 16, 2025 •

Copy link
Copy Markdown
Member

it becomes very hard to ever remove them without introducing a breaking change.

Out of curiosity: in which case would this be a breaking change? I don't see it altering either BBB's API nor the client's API as that's an internal RPC. The first one pretty much defines what is a breaking change; the second one doesn't, but it should (and it's not rare for we to change it in a breaking way in patch releases).

I see the pain in internal subcomponents, but that's not exactly breaking as it doesn't necessarily surface to system end users (*API users/admins) or client developers.

@gustavotrott

gustavotrott commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

in which case would this be a breaking change?

When I say breaking change, I mean that while we (and Blindside) don’t use webhooks (I doubt any member of our team has ever even cloned bbb-webhooks), apparently someone else does, and they rely on these fields (or not, we don't know).
From an internal standpoint, removing them makes sense since no other application is reading them.
But if some external integration depends on those fields, then removing them would break their setup.

It’s also hard to predict which messages or fields some integration is depending on. I’ve seen several messages that aren’t consumed by any internal application, yet removing them still feels risky.

So it might not be a breaking change for BBB itself, but for a customer who expects those fields in the message, it would be.

@prlanzarin

Copy link
Copy Markdown
Member

When I say breaking change, I mean that while we (and Blindside) don’t use webhooks (I doubt any member of our team has ever even cloned bbb-webhooks), apparently someone else does, and they rely on these fields (or not, we don't know).
From an internal standpoint, removing them makes sense since no other application is reading them.
But if some external integration depends on those fields, then removing them would break their setup.

bbb-webhooks follows its own semantic versioning system
The above fields were added as optional payload fields in bbb-webhooks. They're optional by nature - no client implementation is ever required to set UA or Referer header fields, for example. Adding or removing them to an event doesn't imply a breaking change.
Altering the base structure of an event, its underlying semantics, removing them, or changing the extended webhooks API are breaking changes. This is none of that.

If the consumers are fine with handling a new event from bbb-webhooks now, then not adding the fields in UserJoined would be fine. Wait for a reply with their stance.

Anyways - the consumers of these fields are ok with handling new events instead. Steer this PR any way you wish via a regular review procedure.
We'll maintain the UserJoined fields in a fork and then transition to the new event when we're ready to.

@AtilaU19

Copy link
Copy Markdown
Contributor Author

A new version is available ( #24451 ) where the PR supersedes the previous implementation by addressing the security concerns raised.
The updated approach safely parses the X-Forwarded-For header to extract the first valid IP from multiple comma-separated values, validates against null/empty/whitespace-only inputs, and applies length limits to prevent potential injection attacks.

@gustavotrott

Copy link
Copy Markdown
Contributor

A new version is available ( #24451 )

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