Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Verify the rayo JvbRoomName header if it exists. #1166

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.jivesoftware.smack.packet.IQ
import org.jivesoftware.smack.packet.StanzaError
import org.jivesoftware.smack.packet.id.StandardStanzaIdSource
import org.jxmpp.jid.Jid
import org.jxmpp.jid.impl.JidCreate
import java.util.concurrent.atomic.AtomicInteger

class JigasiIqHandler(
Expand Down Expand Up @@ -62,18 +63,13 @@ class JigasiIqHandler(
Stats.rejectedRequests.inc()
}

var conference = conferenceStore.getConference(conferenceJid)

if (conference == null) {
// let's search for visitor room with that jid, maybe it's an invite from a visitor
conference = conferenceStore.getAllConferences()
.find { c -> c.visitorRoomsJids.contains(conferenceJid) }
}

conference ?: return RejectedWithError(request, StanzaError.Condition.item_not_found).also {
logger.warn("Rejected request for non-existent conference: $conferenceJid")
Stats.rejectedRequests.inc()
}
val conference = conferenceStore.getConference(conferenceJid)
// search for visitor room with that jid, maybe it's an invite from a visitor
?: conferenceStore.getAllConferences().find { c -> c.visitorRoomsJids.contains(conferenceJid) }
?: return RejectedWithError(request, StanzaError.Condition.item_not_found).also {
logger.warn("Rejected request for non-existent conference: $conferenceJid")
Stats.rejectedRequests.inc()
}

if (!conference.acceptJigasiRequest(request.iq.from)) {
return RejectedWithError(request, StanzaError.Condition.forbidden).also {
Expand All @@ -82,6 +78,17 @@ class JigasiIqHandler(
}
}

val roomNameHeader = request.iq.getHeader("JvbRoomName")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this search the whole structure of the stanza? Cause the dial-iq is like:

<iq to = '[email protected]/focus' type = 'set' xml:lang = 'en'
    id = ''
    from = '[email protected]/36ff70d6'>
    <dial to = 'jitsi_meet_transcribe' xmlns = 'urn:xmpp:rayo:1' from = 'fromnumber'>
        <header value = '[email protected]' name = 'JvbRoomName' />
    </dial>
</iq>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that gets all direct child extensions and the only child of the IQ is a dial extension. The header is the child of the dial extension.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this method gets the DialIq request: IqRequest<DialIq>. Sorry for the noise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (roomNameHeader != null && JidCreate.entityBareFrom(roomNameHeader) != conference.roomName) {
return RejectedWithError(request, StanzaError.Condition.forbidden).also {
logger.warn(
"Rejecting request with non-matching JvbRoomName: from=${request.iq.from} " +
", roomName=${conference.roomName}, JvbRoomName=$roomNameHeader"
)
Stats.rejectedRequests.inc()
}
}

logger.info("Accepted jigasi request from ${request.iq.from}: ${request.iq.toStringOpt()}")
Stats.acceptedRequests.inc()

Expand Down
Loading