Skip to content

fix: harden SFTP (API transfer re-check, chart transport and metrics) - #1093

Merged
ValgulNecron merged 3 commits into
masterfrom
fix/sftp-security-hardening
Nov 24, 2026
Merged

ValgulNecron merged 3 commits into
masterfrom
fix/sftp-security-hardening

Conversation

@ValgulNecron

@ValgulNecron ValgulNecron commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Gameplane side of the SFTP security review fixes (spec 040). The SFTP server changes are in GameplanePanel/sftp#4. This PR bumps the sftp submodule once that PR merges.

API

  • Running SFTP transfers ignored revocation on SQLite. RevalidateStreams was mounted only when store.Driver == "postgres" (api/cmd/main.go), so on the default SQLite install an SFTP upload or download kept going after its session was revoked or expired. SFTP session streams are now re-checked every 5 s on every driver. New helper auth.SFTPSessionStream; browser streams on SQLite are unchanged.
  • Long transfers would be cut at 15 minutes. A single streamed download is one API request, so the session never slid while it ran. Each successful stream re-check now slides the SFTP session (throttled to once a minute), in streamRecheck.

Chart (templates/sftp.yaml)

  • Local mode sets GAMEPLANE_SFTP_ALLOW_INSECURE_API=true. The hop is http://gameplane-api.<ns>.svc over the pod network, and the API has no in-cluster TLS listener. Remote mode now fails to render unless sftp.apiURL starts with https://.
  • /metrics (no auth) is off unless serviceMonitors.enabled is set. With it on, the pod binds :9102 behind a separate ClusterIP gameplane-sftp-metrics Service, a ServiceMonitor, and a NetworkPolicy ingress rule for serviceMonitors.scrapeNamespaceSelector. The public gameplane-sftp Service still carries only ssh.
  • New value sftp.maxPreAuthPerIP (default 8).

Docs

docs/security.md (threat model), docs/sftp.md, api/specs.md, changelog/unreleased/1093-sftp-security-hardening.md. Not breaking: SFTP has not been released yet (it landed after v0.4.3).

Tests

New api/internal/auth/sftp_stream_hardening_test.go, plus new assertions in charts/gameplane/tests/sftp.sh (case 7 and an http remote-mode render that must fail). No existing assertion was changed. A fresh reviewer that saw only the test diff found no weakened or deleted changes.

🤖 Generated with Claude Code

RevalidateStreams ran only on PostgreSQL panels, so on SQLite an SFTP
upload or download kept running after its session was revoked or
expired. Wrap SFTP session streams on every driver (browser streams on
SQLite are unchanged), and slide the SFTP session on each successful
re-check so a long transfer is not cut at the 15-minute lifetime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
- Local mode sets GAMEPLANE_SFTP_ALLOW_INSECURE_API (pod network only);
  remote mode refuses an sftp.apiURL that is not https://.
- /metrics is off by default; with serviceMonitors.enabled it binds
  :9102 behind a separate in-cluster gameplane-sftp-metrics Service, a
  ServiceMonitor and a NetworkPolicy rule for the scrape namespace.
- New sftp.maxPreAuthPerIP (default 8).
- Docs, threat model and changelog.

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

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a0407a6 and e671f35.

Files selected for processing: 11

  • api/cmd/main.go
  • api/internal/auth/sessions.go
  • api/internal/auth/sftp_guard.go
  • api/internal/auth/sftp_stream_hardening_test.go
  • api/specs.md
  • changelog/unreleased/1093-sftp-security-hardening.md
  • charts/gameplane/templates/sftp.yaml
  • charts/gameplane/tests/sftp.sh
  • charts/gameplane/values.yaml
  • docs/security.md
  • docs/sftp.md
  • 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 added type: fix Bug fix type: security Security hardening or vulnerability fix area: api REST/WebSocket gateway area: chart Helm chart and deployment labels Nov 24, 2026 — with Claude
@ValgulNecron ValgulNecron self-assigned this Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

CI Report - e671f35

run 45297307292 - attempt 2

0 failed - 25 passed - 8 skipped - unknown elapsed

Test selection: partial - per-suite table

Coverage

no coverage/* commit statuses found on e671f35

Changed

Area Files +/-
api/ 5 +101/-1
charts/ 3 +98/-0
docs/ 2 +40/-5
changelog/ 1 +3/-0

Slowest jobs

no job duration data available

e2e buckets run

bot-fast

@ValgulNecron
ValgulNecron marked this pull request as ready for review November 24, 2026 01:27
@ValgulNecron
ValgulNecron merged commit 8046bda into master Nov 24, 2026
142 of 144 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api REST/WebSocket gateway area: chart Helm chart and deployment type: fix Bug fix type: security Security hardening or vulnerability fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants