security: bundled-only native loader; fix Sonar vuln + bug#8
Merged
Conversation
- NativeLibrary: drop the -Dzstd.lib.path override. Loading a caller-supplied native library is arbitrary native code execution in the JVM; trust only the artifact bundled on the classpath. (Self-built libzstd: rebuild it into the native resource jar — docs/how-to.md.) - NativeLibrary: extract into a private owner-only temp directory (createTempDirectory, 0700 on POSIX) instead of a file loose in the shared temp root, closing the swap/symlink window (Sonar S5443). - ZstdSkippableContent: the record carries a byte[]; add content-aware equals/hashCode/toString so value equality works as expected instead of array identity (Sonar S6218), with a value-semantics test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
What
Focuses on the real Sonar findings (1 vulnerability, 1 bug) plus a related native-loader hardening. Skips the style/convention rules (S7474
///-markdown javadoc, S6213, S2187@Nestedtests) — those clash with the project's checkstyle-enforced conventions and are tracked separately.Native loader (security)
-Dzstd.lib.path. Loading a caller-supplied native library is arbitrary native code execution in the JVM process; the loader now trusts only the artifact bundled on the classpath.createTempDirectory,0700on POSIX) instead of a file loose in the shared temp root — closes the swap/symlink window (Sonar S5443, CRITICAL vulnerability).docs/how-to.md: self-builtlibzstdnow documented as "rebuild into the native resource jar".Bug
ZstdSkippableContentis a record carrying abyte[], so the defaultequals/hashCodeused array identity (Sonar S6218, BUG). Added content-awareequals/hashCode/toString+ a value-semantics test.Test
./mvnw -pl zstd -am verify— 138 green, checkstyle + javadoc clean.🤖 Generated with Claude Code