Skip to content

fix(replication): reject unsafe fullsync file names#3483

Merged
git-hulk merged 5 commits into
apache:unstablefrom
git-hulk:fix/reject-invalid-replication-files
May 11, 2026
Merged

fix(replication): reject unsafe fullsync file names#3483
git-hulk merged 5 commits into
apache:unstablefrom
git-hulk:fix/reject-invalid-replication-files

Conversation

@git-hulk

@git-hulk git-hulk commented May 10, 2026

Copy link
Copy Markdown
Member

Replication fullsync uses the peer's file names to fetch checkpoint files
and materialize them in the local sync checkpoint directory. Previously,
those names were joined directly with local directories,
so traversal components could escape the intended directory during existence checks,
temporary file creation, rename, cleanup, or master-side file open.

Assisted-by: Codex/GPT 5.5 xhigh

git-hulk and others added 5 commits May 10, 2026 19:41
Replication fullsync uses file names received from the peer to fetch checkpoint files and materialize them under the local sync checkpoint directory. Previously those names were joined directly with local directories, so traversal components could escape the intended directory during existence checks, temporary file creation, rename, cleanup, or master-side file open.

Add a shared replication file-name validator and apply it at the metadata parsing and storage helper boundaries. The validator allows expected relative checkpoint paths such as meta/1, but rejects absolute paths, empty path components, dot segments, trailing slashes, embedded NULs, backslashes, and colon characters.

Add cppunit coverage that verifies safe nested names still work and unsafe names are rejected without creating escaped files.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@git-hulk git-hulk marked this pull request as ready for review May 11, 2026 05:14
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@git-hulk git-hulk merged commit 3e564ca into apache:unstable May 11, 2026
72 of 75 checks passed
@git-hulk git-hulk deleted the fix/reject-invalid-replication-files branch May 11, 2026 10:44
@git-hulk git-hulk added the bug type bug label May 12, 2026
nkroker pushed a commit to nkroker/kvrocks that referenced this pull request May 29, 2026
Replication fullsync uses the peer's file names to fetch checkpoint
files
and materialize them in the local sync checkpoint directory. Previously,
those names were joined directly with local directories,
so traversal components could escape the intended directory during
existence checks,
temporary file creation, rename, cleanup, or master-side file open.

Assisted-by: Codex/GPT 5.5 xhigh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug type bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants