Summary

OmniFaces: SSE push channels are not bound to their owning HTTP session

Advisory details

Summary

GHSA-fp43-vj7g-pg92 (fixed 5.4.2) bound session- and view-scoped WebSocket (o:socket) push channels to the HTTP session that registered them, so a leaked channel ID can no longer be connected to from a foreign or absent HTTP session. The fix (d5cae243c4) touched only the Socket* classes.

The parallel SSE (o:sse, added in 5.2) push transport was left unchanged. SseEndpoint.doGet accepts a connection whenever the presented channel ID is in the application-wide registry, without ever checking that the caller's HTTP session owns it. A leaked session/view-scoped SSE channel ID can therefore be replayed from any (or no) HTTP session to receive the messages pushed to it — exactly the behaviour the advisory removed for WebSocket, still present on SSE at the latest release.

Root Cause

Both push transports share the same base classes. A session- or view-scoped channel ID is minted as channel + "?" + UUID.randomUUID() and registered only in an application-scoped, session-agnostic registry: PushChannelManager#L123 mints it and #L136 calls getPushSessions().register(channelId); the registry's membership test is PushSessionManager#L137-L139:

protected boolean isRegistered(String channelId) {
    return sessions.containsKey(channelId); // keyed by channelId only — no HTTP-session dimension
}

WebSocket (fixed). SocketChannelManager.register additionally records session/view channel IDs on the HTTP session, and the handshake refuses anything not owned by the caller's session, at SocketEndpoint.java#L133-L142:

if (
    !SocketChannelManager.isApplicationScopedChannelId(channelId)
        && !SocketChannelManager.isChannelIdRegisteredInSession((HttpSession) request.getHttpSession(), channelId)
) {
    throw new IllegalStateException(ERROR_UNAUTHORIZED_CHANNEL);
}

SSE (unfixed). SseChannelManager extends the base register() unchanged (no HTTP-session registration), and the endpoint's sole accept gate is the global isRegistered check, at SseEndpoint.java#L59-L66:

var channel = getChannel(request);
var channelId = channel + "?" + request.getQueryString();
var sseSessions = Beans.getReference(SseSessionManager.class);

if (channel == null || !sseSessions.isRegistered(channelId)) {
    response.getOutputStream().write(SSE_NOT_FOUND_EVENT);
    return;
}
// ...accepts: startAsync() and streams events for this channel

doGet never calls request.getSession(...); no Sse* class consults the HTTP session for the accept decision. So for a session/view-scoped channel ID the fix intends to bind, WebSocket refuses a foreign/absent session while SSE accepts it. (Application-scoped channels are unbound by design on both transports — not at issue here.)

Related, same root cause: the idle-timeout and max-sessions-per-channel bounds the fix added to SocketEndpoint / SocketSessionManager were also not ported to SSE — SseEndpoint.doGet sets asyncContext.setTimeout(0) and SseSessionManager inherits the unbounded getMaxSessionsPerChannel().

Steps to Reproduce

The PoC drives the real SseEndpoint.doGet from omnifaces 5.4.2 and shows it accepts a leaked session-scoped channel ID from a request carrying no owning HTTP session (and never consults the session), while the WebSocket fix refuses the same class of ID.

Prerequisites

  • JDK 21 or newer (tested on Temurin/Zulu 21 and OpenJDK 25)
  • Apache Maven 3.9+

Step 1: Create the project

mkdir -p /tmp/omnifaces-sse-poc/src/test/java/org/omnifaces/cdi/push
cd /tmp/omnifaces-sse-poc
cat > pom.xml <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>poc</groupId>
    <artifactId>omnifaces-sse-poc</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>5.4.2</version>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.1.0</version>
        </dependency>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <version>4.1.0</version>
        </dependency>
        <dependency>
            <groupId>jakarta.websocket</groupId>
            <artifactId>jakarta.websocket-api</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>4.1.0</version>
        </dependency>
        <dependency>
            <groupId>jakarta.el</groupId>
            <artifactId>jakarta.el-api</artifactId>
            <version>6.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.11.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.14.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.1</version>
            </plugin>
        </plugins>
    </build>
</project>
EOF

Step 2: Add the test

cd /tmp/omnifaces-sse-poc
cat > src/test/java/org/omnifaces/cdi/push/SseChannelBindingPoCTest.java <<'EOF'
package org.omnifaces.cdi.push;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.lang.reflect.Field;
import java.util.UUID;

import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.omnifaces.util.Beans;

import jakarta.servlet.AsyncContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

// Placed in package org.omnifaces.cdi.pu

References