Skip to content

fix: leave an existing file unchanged on a write-less open without truncation - #7

Merged
ValgulNecron merged 1 commit into
masterfrom
fix/security-bug-audit-2026-11-27
Nov 27, 2026
Merged

ValgulNecron merged 1 commit into
masterfrom
fix/security-bug-audit-2026-11-27

Conversation

@ValgulNecron

@ValgulNecron ValgulNecron commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Found in the 2026-11-27 code audit of all GameplanePanel repos.

Bug (low): opening an existing file with SSH_FXF_CREAT but without SSH_FXF_TRUNC, then closing it without writing, emptied the file. Filewrite passed flags.Creat || flags.Trunc as create, so a write-less Close committed an empty file over the existing one. Some clients open files this way to touch them or to probe write access.

Fix: internal/vfs/write.go: create := (!exists && flags.Creat) || flags.Trunc. baseKnown is unchanged. The field and Close comments now say the same thing.

Tests

  • New: internal/vfs/write_existing_test.go seeds an existing file, opens it with CREAT and no TRUNC, closes it without writing, and checks the content is unchanged.
  • No existing test changed. Local check was compile-only (go build ./..., go test -c). CI runs the tests.

After merge, the sftp pointer gets bumped in Gameplane, in the same PR as the other audit fixes.

🤖 Generated with Claude Code

…uncation

Opening an existing file with SSH_FXF_CREAT but without SSH_FXF_TRUNC and
closing it without writing emptied the file, because the writer treated
any Creat as a create. Only a new file opened with Creat, or any Trunc,
now makes an empty file on a write-less close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89a755e6-6c26-4781-9a18-33801e4c1367
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ValgulNecron ValgulNecron self-assigned this Nov 27, 2026
@ValgulNecron
ValgulNecron merged commit cb196b3 into master Nov 27, 2026
6 checks passed
ValgulNecron pushed a commit to GameplanePanel/Gameplane that referenced this pull request Nov 27, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@ValgulNecron
ValgulNecron deleted the fix/security-bug-audit-2026-11-27 branch November 27, 2026 22:32
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.

2 participants