Repository navigation
feat(dedup): enable safe dedup on Jetty 11/12 and Undertow 2.2/2.3 - #197
Open
slayerjain wants to merge 5 commits into
Open
slayerjain wants to merge 5 commits into
slayerjain wants to merge 5 commits into
Conversation
Keep asyncExecutors=true and clean per-window dedup on Jetty 11/12/12.1 and Undertow 2.2/2.3 (including Spring Boot Jetty and Undertow starters) without allowlisting any user-callback-capable pool or executor: - Hook org.xnio.XnioWorker.execute(Runnable) via RequestGate.handXnioWorker and enterXnioWorkerDispatch/exitXnioWorkerDispatch (paired with UNARMED_REQUEST_DEPTH for pre-connect server requests) so XNIO worker dispatch tracks tasks and lazily spawned XNIO-1 worker threads safely while failing closed on outside-window XnioWorker.execute, unreadable classloaders, or user-created EnhancedQueueExecutor/JBossThread pools. - Exempt only hooked, non-overriding XnioWorker instances (verifying both execute(Runnable) on XnioWorker and all submit overloads on AbstractExecutorService) from RequestGate's untracked-executor check. - Classify Jetty 11/12 internal I/O/strategy/shutdown classes (relocated HttpConnection, SslEndPoint, AdaptiveExecutionStrategy, ShutdownService, SerializedInvoker$Link) in the load-time scan allowlist, and hook user-callable or rarely-used helpers (Graceful.shutdown, VirtualThreads.executeOnVirtualThread, ThreadPool.executeImmediately, Invocable$InvocationType$1.runWithoutBlocking, Undertow's ServerWebSocketContainer, and Spring's DefaultPartHttpMessageReader) with fail-closed latch-on-call instrumentation. - Add only Spring Boot 3.x/4.x zero-callback infra thread callers (BackgroundPreinitializer and Jetty GracefulShutdown) to SinkAllowlist. - Remove Undertow 2.2 waivers in ForkedAsyncAndHonestyTest and add isolated JDK 17+ forked integration rows for Jetty 11.0.24, Jetty 12.0.16 (ee10), and Undertow 2.3.18 across prefix and index modes plus escape tests. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Rewrite app calls to XnioIoThread.executeAfter and executeAtInterval to emit untracked-async flags so delayed I/O selector tasks never escape a dedup window silently. Hook server-owned executor and scheduler sinks (Jetty QueuedThreadPool, MonitoredQueuedThreadPool, ExecutorThreadPool, ReservedThreadExecutor, TryExecutor$NoTryExecutor, ScheduledExecutorScheduler, TimerScheduler; Undertow PipeliningExecutor and XNIO WorkerThread) with an exact-class caller check that allows only the server's own internal packages and fails closed (contaminating the active window and latching asyncExecutors=false) on app, third-party library, or reflective hand-offs across Jetty 9.4/11/12/12.1 and Undertow 2.2/2.3. Add unit and forked tests covering XnioWorker override verification, tag-7 latch-on-call fallback, per-entry allowlist citations and behaviour rows, retransform idempotency, and reflective/library escapes. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… server executor and timer sinks Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…AsyncContext.dispatch - Verify Jetty IdleTimeout receivers via SinkAllowlist.isServerConnectorOwnedEndPoint so app-built SocketChannelEndPoint and SslConnection wrappers fail closed unless owned by a ServerConnector ManagedSelector and its channel SelectionKey. - Preserve Servlet AsyncContext.dispatch() (Spring MVC Callable / DeferredResult) across Jetty 9.4, 11, 12.0 (ee10), and 12.1 (ee11) via exact HttpChannelState#scheduleDispatch (HttpChannel/HttpChannelOverHttp task check) and ServletChannelState#scheduleDispatch (ScopedContext -> ServletChannel lambda check), while keeping public forwarders fail-closed for direct, library, and reflective callers. - Keep TimerScheduler#run visible and restricted to self-rearm (task == receiver, exact TimerScheduler), remove dead/non-direct caller entries, and add unit + forked regressions across Jetty 9.4/11/12.0/12.1 and Undertow 2.2/2.3. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… and TimerScheduler rows Pre-merge test coverage and allowlist cleanup: - Add copy-jetty121 artifact set (Jetty 12.1.15 ee11-servlet/server/http/io/util/session/security + jakarta.servlet-api 6.1.0) in the JDK 17+ profile and run the JakartaJetty12App forked suite on ee11 (AsyncContext.dispatch Callable/DeferredResult + all escape probes). - Add JdkSinkBridgeTest rows proving app-built SocketChannelEndPoint handed a started ServerConnector's real ManagedSelector with null or foreign SelectionKey fails closed, and proving a live transformed TimerScheduler self-re-arm keeps asyncExecutors=true. - Remove unused QueuedThreadPool$2#run allowlist entry from SinkAllowlist. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables safe per-test dedup (
asyncExecutors=true,windowCut=true, failing closed on untracked async hand-offs) for Jetty 11 / 12 / 12.1 and Undertow 2.2 / 2.3 (including minimal Spring Boot Jetty and Undertow apps), without allowlisting any user-callback-capable pool or executor (EnhancedQueueExecutor,JBossThread,ManagedThreadPoolExecutor,XnioWorker$DefaultThreadPoolExecutor), and closes server-owned executor, scheduler, and abstract timer escape paths across Jetty 9.4/11/12/12.1 and Undertow 2.2/2.3 using exact, cited(callerClass#callerMethod)allowlists with zero package-prefix wildcards.Root Causes Fixed
AdaptiveExecutionStrategy,server.internal.HttpConnection+$HttpStreamOverHTTP1,SslConnection$SslEndPoint+$IncompleteWriteCallback,ShutdownService,SerializedInvoker$Link) and rarely-used helpers (Graceful.shutdown,VirtualThreads.executeOnVirtualThread,ThreadPool.executeImmediately,Invocable$InvocationType$1.runWithoutBlocking).XnioWorker/EnhancedQueueExecutorlazily spawnsXNIO-1 task-*threads on the first HTTP request (TaskPool/EnhancedQueueExecutor->JBossThread.start()), which previously trippedJdkSinkBridge.onThreadStart()unless recognized via the exactio.undertow.server.Connectors#executeRootHandlerstack-frame check.QueuedThreadPool,ReservedThreadExecutor,Scheduler,TimerScheduler,ContextHandler$ScopedContext,Server$ServerContext,VirtualThreads.execute,CyclicTimeout,CyclicTimeouts,IdleTimeout,SocketChannelEndPoint(even when handed a realServerConnectorManagedSelectorwith a null or foreignSelectionKey),ByteArrayEndPoint, or UndertowXnioWorker/XnioIoThread/WorkerUtilscould bypass call-site rewriting via reflection or unrewritten third-party libraries.AsyncContext.dispatch()(Spring MVCCallable/DeferredResult) on Jetty 9.4/11/12.0/12.1: PreservesasyncExecutors=trueand zero contamination for legitimate servlet async dispatches via exactHttpChannelState#scheduleDispatch(9.4/11) andee10/ee11ServletChannelState#scheduleDispatch(12.0/12.1) caller + task checks, while keeping all public Jetty forwarders fail-closed for app, library, and reflective callers.Changes
SinkAllowlist.java:(callerClass#callerMethod)allowlists for every server sink (QueuedThreadPool,ReservedThreadExecutor,ScheduledExecutorScheduler,TimerScheduler,IdleTimeout,CyclicTimeout,CyclicTimeouts,XnioWorker,WorkerThread).EatWhatYouKill,AdaptiveExecutionStrategy, and exact"execute"methods onSelectorManager,HttpChannel,ee10/ee11ServletChannel,ContextHandler$ScopedContext,Server$ServerContext,VirtualThreadsfor Jetty pools;WorkerUtils,ParseTimeoutUpdater,ConnectionUtilsforWorkerThread) while keepingTimerScheduler#runandWorkerThread#runvisible so self-re-arms resolve cleanly.isServerConnectorOwnedEndPoint: verifiesSocketChannelEndPoint(andSslConnection's underlying network endpoint) belongs to an exactServerConnector$ServerConnectorManagerManagedSelectorAND that_keyis aSelectionKeywhosechannel() == _channelandselector() == ManagedSelector._selector.HttpChannelState#scheduleDispatch(Jetty 9.4/11) permits only exactHttpChannel/HttpChannelOverHttptasks;ee10/ee11ServletChannelState#scheduleDispatch(Jetty 12.0/12.1) verifiesContextHandler$ScopedContext$$Lambda+ innerServletChannelcapture as an additional guard alongside the exact caller frame.TimerScheduler#runpermits onlytask == receiverof exactTimerScheduler.WorkerThread#runpermits onlyParseTimeoutUpdater.ServerEntries.java&JdkSinkBridge.java:ThreadPool.executeImmediatelyandScheduledExecutorScheduler.schedule(Runnable, Duration).keploy-sdk/pom.xml,ForkedAsyncAndHonestyTest.java,JdkSinkBridgeTest.java):ee10), Jetty 12.1.15 (ee11,copy-jetty121+jakarta.servlet-api6.1.0), and Undertow 2.3.18 in the JDK 17+ profile and runs full forked-JVM clean-dedup,AsyncContext.start,AsyncContext.dispatch(Callable/DeferredResult), and adversarial escape rows on all four servers in both prefix and index modes.JdkSinkBridgeTestrows proving app-builtSocketChannelEndPointhanded a startedServerConnector's realManagedSelectorwith null or foreignSelectionKeyfails closed, and proving a live transformedTimerSchedulerself-re-arm keepsasyncExecutors=true.Safe Fail-Closed Scope Notes
ReadListener/WriteListenerwakeups andDelayedHandler/EagerContentHandler/QoSHandlerre-dispatches reach a skipped forwarder from an unlisted frame and fail closed (asyncExecutors=false); on Jetty 9.4/11,HttpChannelOverHTTP2async dispatches also fail closed safely.HttpSessionListener.sessionDestroyed, etc.) are not part of this PR and are tracked in a dedicated follow-up PR.Verification
scripts/smoke-javaagent.sh: 453/453 PASS on JDK 21 (and full JDK 8/11/17/21 matrix in CI).mvn test-compile/package -DskipTestscheck before test execution): 8/8 KILLED (N2,N3,N4,N7,N10,MF1,M15,M16,compile_errors=[],survived=[]).