Skip to content

security: bundled-only native loader; fix Sonar vuln + bug#8

Merged
dfa1 merged 1 commit into
mainfrom
security/native-loader-and-sonar-fixes
Jun 26, 2026
Merged

security: bundled-only native loader; fix Sonar vuln + bug#8
dfa1 merged 1 commit into
mainfrom
security/native-loader-and-sonar-fixes

Conversation

@dfa1

@dfa1 dfa1 commented Jun 26, 2026

Copy link
Copy Markdown
Owner

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 @Nested tests) — those clash with the project's checkstyle-enforced conventions and are tracked separately.

Native loader (security)

  • Drop -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.
  • Extract into a private temp dir (createTempDirectory, 0700 on 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-built libzstd now documented as "rebuild into the native resource jar".

Bug

  • ZstdSkippableContent is a record carrying a byte[], so the default equals/hashCode used array identity (Sonar S6218, BUG). Added content-aware equals/hashCode/toString + a value-semantics test.

Test

./mvnw -pl zstd -am verify — 138 green, checkstyle + javadoc clean.

🤖 Generated with Claude Code

- 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>
@dfa1 dfa1 merged commit 8d0ea6a into main Jun 26, 2026
1 check passed
@dfa1 dfa1 deleted the security/native-loader-and-sonar-fixes branch June 26, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant