Repository navigation
fix(dedup): audit Spring/Logback allowlist and latch Dropwizard/Jersey async paths on call - #201
Merged
Conversation
…y async paths on call 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.
Problem
keploy/java-sdkv2.3.0 falsely latchesasyncExecutors=falseat startup on synchronous-only Spring Boot 2.7 (samples-java/java-dedup) and Dropwizard 2 (samples-java/dropwizard-dedup) REST apps, causing the>= 2.2.1fail-closed gate to hold all duplicate removals (0removed).Root causes audited from live JAR bytecode (
javap) on both apps:spring-core5.3.x):org/springframework/util/ConcurrentLruCacheuses a privateConcurrentLinkedDeque<K> queueunder aReentrantReadWriteLocksynchronously insideget()/remove()/clear()solely for LRU eviction ordering (zero worker thread, zero executor).logback-core1.2.x):ch/qos/logback/core/AsyncAppenderBaseandch/qos/logback/core/AsyncAppenderBase$Workerform Dropwizard's default async logging wrapper draining aBlockingQueue<E>of logging events intoAppenderAttachableImpl.appendLoopOnAppenders(same logging-only sink category as already-allowlisted Tomcatorg/apache/juli/AsyncFileHandler$LoggerExecutorServiceand Jettyorg/eclipse/jetty/server/AsyncRequestLogWriter$WriterThread).com/codahale/metrics/ScheduledReporter,com/codahale/metrics/health/AsyncHealthCheckDecorator,com/codahale/metrics/health/HealthCheckRegistry,io/dropwizard/servlets/tasks/LogConfigurationTask,org/glassfish/jersey/server/ChunkedOutput,org/glassfish/jersey/server/internal/JerseyRequestTimeoutHandler) are loaded unconditionally during server initialization even when never used for async/scheduled/streaming execution.Solution
Keep the generic
ConcurrentLinkedDeque/BlockingQueue/Thread/ExecutorServiceconstant-pool fail-closed rules intact for all non-allowlisted classes, and apply exact, source-audited rules:ServerEntries.ALLOWLISTED_DISPATCH_CLASSES(3 exact classes):org/springframework/util/ConcurrentLruCache(synchronous private LRU eviction deque only)ch/qos/logback/core/AsyncAppenderBaseandch/qos/logback/core/AsyncAppenderBase$Worker(logging-only event drain)SinkAllowlist.INFRA_THREAD_CALLERS(1 exact caller):ch.qos.logback.core.AsyncAppenderBase(allowsstart()spawning its single internalAsyncAppenderBase$Workerdaemon thread)ServerEntries.LATCH_ON_CALL(6 exact classes, fail-closed on invocation):com/codahale/metrics/ScheduledReporter(start,getScheduledFuture)com/codahale/metrics/health/AsyncHealthCheckDecorator(<init>,run)com/codahale/metrics/health/HealthCheckRegistry(runHealthChecks(Ljava/util/concurrent/ExecutorService;— added descriptor-prefix matching toLatchEntry.matchesso syncrunHealthChecks()stays clean while parallelrunHealthChecks(ExecutorService...)latches)io/dropwizard/servlets/tasks/LogConfigurationTask(getTimer)org/glassfish/jersey/server/ChunkedOutput(write,flushQueue,setContext)org/glassfish/jersey/server/internal/JerseyRequestTimeoutHandler(suspend,setSuspendTimeout)Verification
mvn -B test):Tests run: 461, Failures: 0, Errors: 0, Skipped: 3(BUILD SUCCESS), including:HonestProtocolAndAsyncTest.testSpringAndDropwizardAuditedAllowlistAndLatchOnCall: verifies all 3 allowlisted classes stay clean on load, 4 non-allowlisted classes referencing the exact same primitives (ConcurrentLinkedDeque.offer,BlockingQueue.offer,Threadsubclass,ExecutorService.submit) still latch fail-closed on load, and all 6LATCH_ON_CALLclasses stay clean on load (and syncHealthCheckRegistry.runHealthChecks()stays clean) while latchingasyncExecutors=falseon first async/timer/streaming invocation.JdkSinkBridgeTest.infraAllowlistContainsOnlyExactCitedZeroCallbackClassesAndExcludesUserCallbackPools: updated exact-count and behaviour pins forSinkAllowlist.INFRA_THREAD_CALLERS.samples-java/java-dedup(Spring Boot 2.7, Java 8 / 17 / 21 ×native,native-classpath): 382 duplicates removed / 18 retained (--keep 1), 346 duplicates removed / 54 retained (--keep 3) across all 6 combinations.samples-java/dropwizard-dedup(Dropwizard 2, Java 8 / 17 / 21 ×native,native-classpath): 180 duplicates removed / 20 retained (--keep 1), 142 duplicates removed / 58 retained (--keep 3) across all 6 combinations.java-sdk 2.1.3negative proof (dropwizard-dedup, Java 17native): 0 duplicates removed / 200 retained, fail-closed warning logged.