Repository navigation
feat: added fields IP, User-Agent, Referer and sessionToken to UserJoinedMeetingEvtMsg - #24451
Conversation
…g and UserConnectedToTransferSysMsg
…nectedToTransferSysMsg
This prevents IP spoofing attacks by properly parsing proxy headers that may contain multiple comma-separated IPs.
WalkthroughAdds join-request metadata propagation across the user registration and join flow. ApiController extracts sanitized headers (ipAddress, userAgent, referer, and sessionToken) into a joinRequestMetadata map and passes it to MeetingService.registerUser. The new field is threaded through gateway and messaging layers, added to RegisterUser/RegisterUserReqMsgBody, RegisteredUser, UserState, and UserJoinedMeetingEvtMsgBody. Two helper methods (extractClientIp and sanitizeHeader) were introduced for header extraction and sanitization. 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
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (17)
🚧 Files skipped from review as they are similar to previous changes (9)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2024-10-10T12:15:03.265ZApplied to files:
🧬 Code graph analysis (2)bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (1)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala (1)
⏰ 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). (5)
🔇 Additional comments (11)
✏️ Tip: You can disable this entire section by setting 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.
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 (2)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala (1)
14-52: Database persistence issue: new fields not mapped in UserDAO.insert()The
createmethod correctly includes and passesipAddress,userAgent, andrefererto theRegisteredUsercase class, butUserDAO.insert()does not map these fields when persisting to the database. Lines 73-108 inUserDAO.scalaconstruct theUserDbModelup throughlogoutUrl, but the three new fields are missing. The data will be lost when inserted into the database.Update
UserDAO.insert()to include mappings for these fields in theUserDbModelconstruction.bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala (1)
88-112: Remove privacy-sensitive fields from broadcast message or implement per-recipient filtering.The
UserJoinedMeetingEvtMsgBodyis broadcast to all meeting clients viaBROADCAST_TO_MEETINGrouting, not limited to webhooks. This exposesipAddress,userAgent,referer, andsessionTokento every meeting participant. IP addresses are PII under GDPR/CCPA, and user-agent strings enable fingerprinting.Either exclude these fields from the client broadcast message, or implement a filtering layer that removes sensitive fields before sending to clients while preserving them for server-side webhooks/analytics.
🤖 Fix all issues with AI agents
In
@bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy:
- Around line 459-465: The code trusts X-Forwarded-For/X-Real-IP in
paramsProcessorUtil.extractClientIp and should either document that
trusted-proxy network filtering is required or enforce it: add a configurable
trusted proxy list (e.g., config.trustedProxies) and modify extractClientIp to
only accept X-Forwarded-For/X-Real-IP when request.getRemoteAddr() is in that
whitelist (or expose a new helper isTrustedProxy(remoteAddr)); alternatively add
a clear inline comment next to the extractClientIp/sanitizeHeader calls stating
the trusted-proxy assumption and where to configure the trusted proxy list
(referencing paramsProcessorUtil.extractClientIp,
paramsProcessorUtil.sanitizeHeader, and the new config key such as
trustedProxies or a validator method like paramsProcessorUtil.isTrustedProxy).
🧹 Nitpick comments (2)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala (1)
454-457: Vector("") is a necessary workaround for unsafe.headusage—the real issue deserves attention.
regUser.sessionToken.headis called without validation in UserDAO.scala (line 117). UsingVector.emptywould cause aNoSuchElementExceptionat runtime. TheVector("")default is intentional but indicative of fragile code.Consider:
- Add safety checks before calling
.headonsessionToken- Use
.headOptionand handle theNonecase explicitly- Only then can the default safely become
Vector.emptyThis refactoring would improve both safety and semantic clarity.
bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (1)
27-29: Minor indentation inconsistency.The new fields
userAgentandrefereruse 4-space indentation while other fields use tab indentation. This doesn't affect functionality but creates inconsistent formatting.🔧 Suggested formatting fix
public final String ipAddress; - public final String userAgent; - public final String referer; + public final String userAgent; + public final String referer;
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scalabbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scalabbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.javabbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.javabbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.javabbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.javabbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scalabbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scalabbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scalabbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scalabigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: jaapjansma
Repo: bigbluebutton/bigbluebutton PR: 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
Repo: bigbluebutton/bigbluebutton PR: 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/meeting/ToAkkaAppsSendersTrait.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scalabbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scalabbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scalabbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.javaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scalabbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.javabbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scalabbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scalabigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovyakka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scalabbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
🧬 Code graph analysis (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/ApiParams.java (1)
ApiParams(22-124)
bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala (1)
bigbluebutton-html5/imports/ui/components/layout/push-layout/pushLayoutEngine.jsx (1)
enforceLayout(488-488)
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). (3)
- GitHub Check: build-package (bbb-web)
- GitHub Check: build-package (bbb-fsesl-akka)
- GitHub Check: build-package (bbb-apps-akka)
🔇 Additional comments (20)
bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/ToAkkaAppsSendersTrait.scala (1)
34-35: LGTM!The new fields (
ipAddress,userAgent,referer) are correctly propagated from theRegisterUsermessage to theRegisterUserReqMsgBody. The field ordering is consistent with the established pattern.bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (3)
998-1006: LGTM!The dark logo fallback chain is logically sound: prioritizes explicit
DARK_LOGOparam, falls back toLOGOparam, then default dark logo, and finally default logo if dark logo defaults are disabled.
1836-1864: Implementation follows standard X-Forwarded-For parsing patterns.The method correctly extracts the first (leftmost) IP from
X-Forwarded-For, which represents the original client when proxies append IPs. The fallback chain toX-Real-IPandremoteAddris appropriate.Note: If this IP is used for security-sensitive decisions (rate limiting, access control), ensure that the reverse proxy configuration strips/overwrites client-supplied
X-Forwarded-Forheaders to prevent spoofing.
1866-1878: LGTM!Simple and defensive utility for sanitizing header values. Correctly handles null/empty inputs and enforces length limits.
akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/UserJoinedMeetingEvtMsgBuilder.scala (1)
20-24: LGTM!The new fields (
sessionToken,ipAddress,userAgent,referer) are correctly sourced fromuserStateand included in theUserJoinedMeetingEvtMsgBody. This fulfills the PR objective to enrich the event payload with client-origin metadata for bbb-webhooks consumption.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala (1)
67-71: LGTM!The new fields are correctly propagated from
regUser(RegisteredUser) to the newUserStateduring user join. This bridges the registration metadata to the live meeting user state, enabling downstream event builders to include this data.bbb-common-web/src/main/scala/org/bigbluebutton/api2/MsgBuilder.scala (1)
68-68: LGTM!The new fields (
ipAddress,userAgent,referer) are correctly included in theRegisterUserReqMsgBodyconstruction, sourced from themsgparameter. This maintains consistency with the field propagation pattern across the registration flow.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala (1)
61-64: LGTM - New metadata fields correctly propagated.The new
ipAddress,userAgent, andrefererfields are correctly extracted frommsg.bodyand passed toRegisteredUsers.create. The change aligns with the broader PR objective to enrich user records with request context.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala (1)
48-53: LGTM - Empty metadata fields for dial-in users is appropriate.For dial-in users joining via voice conference, there's no HTTP request context available, so passing empty strings for
ipAddress,userAgent, andrefereris the correct approach. The signature aligns with the updatedRegisteredUsers.createmethod.akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1)
66-69: LGTM - Test data generation correctly updated.The
RegisteredUsers.createcall is properly updated with empty strings for the newipAddress,userAgent, andrefererfields. Using empty strings for test/fake data is appropriate.bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy (1)
568-571: New metadata fields correctly passed to registration service.The
clientIp,userAgent, andreferervalues extracted earlier are properly forwarded tomeetingService.registerUser, completing the data flow from HTTP request to the registration backend.bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/MeetingsManagerActor.scala (1)
18-21: LGTM - Parameter additions are consistent with the registration flow.The new
ipAddress,userAgent, andrefererparameters are correctly positioned afterlogoutUrland beforeuserMetadata, aligning with the corresponding changes inIBbbWebApiGWApp.javaandRegisterUser.java. Based on learnings, these are correctly identified as additions rather than replacements.bbb-common-web/src/main/java/org/bigbluebutton/api2/IBbbWebApiGWApp.java (1)
79-82: LGTM - Interface signature updated consistently.The new parameters
ipAddress,userAgent, andrefererare correctly added to the interface method signature, positioned beforeuserMetadata. This aligns with the implementation inBbbWebApiGWApp.scalaand the data model inRegisterUser.java.bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/RegisterUser.java (1)
32-59: LGTM - Constructor correctly initializes new fields.The constructor signature and field assignments for
ipAddress,userAgent, andrefererare implemented correctly, maintaining consistency with the existing field initialization pattern.bbb-common-web/src/main/scala/org/bigbluebutton/api2/BbbWebApiGWApp.scala (2)
314-318: LGTM - RegisterUser construction correctly includes new fields.The new fields are correctly passed to the
RegisterUserconstructor in the expected order, aligning with the updated case class definition.
304-305: Header values are already sanitized upstream.In
ApiController.groovy(lines 459-465), theuserAgentandrefererparameters are sanitized viaparamsProcessorUtil.sanitizeHeader()with size limits (512 and 1024 characters respectively) before being passed toregisterUser(). TheclientIpis properly extracted viaparamsProcessorUtil.extractClientIp()which handles X-Forwarded-For header parsing. No additional validation is needed inregisterUser().akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala (1)
267-301: LGTM - Case class correctly extended with new fields.The
RegisteredUsercase class properly includesipAddress,userAgent, andrefereras required String fields, positioned consistently with the factory method and related data structures across the PR.bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (2)
135-153: LGTM! Method signature extended with client-origin metadata.The
registerUsermethod correctly propagatesipAddress,userAgent, andrefererto theRegisterUsermessage. Parameter ordering is consistent between the method signature and constructor call.Note: The
RegisteredUserinstantiation at lines 149-150 doesn't include the new fields, which appears intentional since the message-based flow handles propagation to downstream components.
628-634: LGTM! Gateway call correctly extended with new fields.The
processRegisterUsermethod properly forwardsipAddress,userAgent, andrefererfrom the message to the gateway, maintaining consistent parameter ordering with the rest of the registration flow.bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMsgs.scala (1)
8-12: LGTM! Registration request message extended with client metadata.The
RegisterUserReqMsgBodycase class correctly includesipAddress,userAgent, andrefererfields. As a request message, this appropriately captures client-origin metadata for server-side processing during user registration.
| String clientIp = paramsProcessorUtil.extractClientIp( | ||
| request.getHeader("X-Forwarded-For"), | ||
| request.getHeader("X-Real-IP"), | ||
| request.getRemoteAddr() | ||
| ) | ||
| String userAgent = paramsProcessorUtil.sanitizeHeader(request.getHeader('User-Agent'), 512) | ||
| String referer = paramsProcessorUtil.sanitizeHeader(request.getHeader('Referer'), 1024) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "*paramsProcessorUtil*" -o -name "*ParamsProcessorUtil*" | head -20Repository: bigbluebutton/bigbluebutton
Length of output: 231
🏁 Script executed:
rg -l "extractClientIp|sanitizeHeader" --type groovy -i | head -20Repository: bigbluebutton/bigbluebutton
Length of output: 166
🏁 Script executed:
rg "class.*ParamsProcessorUtil" --type groovy -A 30Repository: bigbluebutton/bigbluebutton
Length of output: 53
🏁 Script executed:
wc -l ./bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.javaRepository: bigbluebutton/bigbluebutton
Length of output: 153
🏁 Script executed:
cat -n ./bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.javaRepository: bigbluebutton/bigbluebutton
Length of output: 50383
🏁 Script executed:
wc -l ./bigbluebutton-web/test/groovy/org/bigbluebutton/api/ParamsProcessorUtilTest.javaRepository: bigbluebutton/bigbluebutton
Length of output: 156
🏁 Script executed:
rg "def extractClientIp|public.*extractClientIp" ./bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java -A 25Repository: bigbluebutton/bigbluebutton
Length of output: 970
🏁 Script executed:
rg "def sanitizeHeader|public.*sanitizeHeader" ./bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java -A 10Repository: bigbluebutton/bigbluebutton
Length of output: 402
🏁 Script executed:
cat -n ./bigbluebutton-web/test/groovy/org/bigbluebutton/api/ParamsProcessorUtilTest.javaRepository: bigbluebutton/bigbluebutton
Length of output: 3005
🏁 Script executed:
rg "trusted.*proxy|proxy.*trusted|X-Forwarded-For" ./bbb-common-web/src/main/java/org/bigbluebutton/api/ -i -B 2 -A 2Repository: bigbluebutton/bigbluebutton
Length of output: 1265
🏁 Script executed:
rg "extractClientIp" ./bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy -B 5 -A 5Repository: bigbluebutton/bigbluebutton
Length of output: 597
🏁 Script executed:
rg "X-Forwarded-For" . --type java --type xml -B 3 -A 3 | grep -E "(filter|trusted|proxy|allow)" -i -B 2 -A 2Repository: bigbluebutton/bigbluebutton
Length of output: 53
🏁 Script executed:
find . -name "web.xml" -o -name "*Filter*.java" | head -10Repository: bigbluebutton/bigbluebutton
Length of output: 263
Client metadata extraction is implemented, but document the trusted proxy assumption.
The extraction of client IP, User-Agent, and Referer with sanitization works as designed. Character limits (512 for User-Agent, 1024 for Referer, 128 for IP) are reasonable. The extractClientIp method correctly parses X-Forwarded-For by taking the first non-empty value and falling back to X-Real-IP, then remoteAddr.
However, the implementation does not actively mitigate IP spoofing—it simply trusts all values in the X-Forwarded-For chain without validation against a whitelist of trusted proxies. This approach is safe only if the deployment enforces strict network-level filtering to prevent untrusted sources from injecting X-Forwarded-For headers. Document this security assumption or implement trusted proxy validation if untrusted networks can reach this endpoint.
🤖 Prompt for AI Agents
In
@bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
around lines 459 - 465, The code trusts X-Forwarded-For/X-Real-IP in
paramsProcessorUtil.extractClientIp and should either document that
trusted-proxy network filtering is required or enforce it: add a configurable
trusted proxy list (e.g., config.trustedProxies) and modify extractClientIp to
only accept X-Forwarded-For/X-Real-IP when request.getRemoteAddr() is in that
whitelist (or expose a new helper isTrustedProxy(remoteAddr)); alternatively add
a clear inline comment next to the extractClientIp/sanitizeHeader calls stating
the trusted-proxy assumption and where to configure the trusted proxy list
(referencing paramsProcessorUtil.extractClientIp,
paramsProcessorUtil.sanitizeHeader, and the new config key such as
trustedProxies or a validator method like paramsProcessorUtil.isTrustedProxy).
|
As mentioned earlier (at #23910), these fields (IP, user agent, referer) represent metadata from the initial join request, not the user’s current state. For example, the IP may change during the session and won’t be updated. Given that, adding multiple static fields to akka-apps user data seems unnecessary, especially since their only use is for bbb-webhooks through the I’d suggest introducing a single property Would bbb-webhooks be able to handle it as a single JSON property instead of multiple fields? (cc @prlanzarin) |
…on into task-new-data-30
Replace individual fields (ipAddress, userAgent, referer, sessionToken) with a single joinRequestMetadata Map[String, String] property as suggested by @gustavotrott. This change: - Makes explicit that data is static request metadata, not dynamic user state - Avoids unnecessary additions of user properties in akka-apps - Allows future extensions without touching akka-apps core - Provides bbb-webhooks a single JSON property to consume The joinRequestMetadata contains: - ipAddress: Client IP from X-Forwarded-For/X-Real-IP/remoteAddr - userAgent: Browser/client user agent (max 512 chars) - referer: Origin page URL (max 1024 chars) - sessionToken: User session token
|
Automated tests Summary✅ All the CI tests have passed! |



What does this PR do?
Adds client request metadata to the
UserJoinedMeetingEvtMsgevent through a singlejoinRequestMetadataproperty containing IP address, User-Agent, Referer, and session token.This metadata is extracted from HTTP headers during the join request and propagated through the user registration flow. Using a single JSON property makes it explicit that this is static request metadata (captured at join time) rather than dynamic user state.
Closes Issue(s)
Closes None
More