Skip to content

fix(security): enforce setup, revocation and stream authentication boundaries - #6133

Open
Peaks2000 wants to merge 3 commits into
SunshineStream:masterfrom
Peaks2000:fix/security-session-boundaries
Open

Peaks2000 wants to merge 3 commits into
SunshineStream:masterfrom
Peaks2000:fix/security-session-boundaries

Conversation

@Peaks2000

@Peaks2000 Peaks2000 commented Nov 18, 2026 •

Copy link
Copy Markdown

Description

Close four security boundaries identified during a manual source review.

  • Apply origin_web_ui_allowed to initial credential creation, including installations with no username yet.
  • Recheck each HTTPS request against its own TLS client certificate, including keep-alive requests. Propagate certificate revocation to pending launches and active sessions, and terminate the selected client's streams when unpairing while other clients remain paired.
  • Require authenticated encrypted RTSP for launch and resume, and check revocation again at stream admission. A plaintext RTSP connection could otherwise claim another client's pending launch.
  • Validate encrypted control and legacy-input envelope sizes before decryption, reject malformed GCM inputs, and bound fixed-size control payload reads.

The HTTPS lifetime regression test also exposed a synchronous TLS shutdown that could stall the HTTPS worker when a revoked peer withheld its close notification. Send the notification on a nonblocking socket before teardown.

Compatibility change — Clients must support encrypted RTSP (corever >= 1). Older clients receive an update-client error. Current bundled Moonlight common-c advertises corever=1. The setup and pairing documentation describes the new behavior.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

Added regression tests for restricted first-run setup, certificate revocation and re-enable epochs, authenticated RTSP admission, real TLS keep-alive and concurrent client identity, malformed control envelopes, and real AES-GCM authentication failures and recovery.

Validated on Ubuntu 24.04 with GCC 13.3 and OpenSSL 3.0.13, using Xvfb and PulseAudio for platform tests.

  • uv sync --locked succeeded.
  • uv run --locked lb-update-clang-format succeeded, and git diff --check passed.
  • Built both sunshine and test_sunshine with BUILD_WERROR=ON.
  • The focused security run passed all 82 cases. Two additional RTSP admission tests also passed in the final suite.
  • ./cmake-build-security/tests/test_sunshine --gtest_filter=-X11GrabTest.DisplayNamesRetryTransientScreenResourcesFailure completed with 858 passed and four skipped out of 862 cases.

The excluded, unchanged X11 retry test fails under this Xvfb environment because the display list remains empty. The four skips cover Windows-specific support, the disabled tray, and unavailable NVENC/VAAPI encoders. Windows, macOS, physical capture devices, and hardware encoders were not exercised. Coverage reached 100% of executable lines in the new envelope parser. Changed-source line coverage is approximately 63%, with live stream callbacks and error paths remaining outside runtime coverage.

CMake used BUILD_TESTS=ON, BUILD_DOCS=OFF, BUILD_WERROR=ON, and CMAKE_BUILD_TYPE=Debug. Tray, CUDA, DRM, VAAPI, Vulkan, Wayland, KWin, and portal backends were disabled. The follow-up documentation correction also passed the full strict Dockle build using Doxygen 1.18.0, generating 1,168 HTML pages.

The follow-up quality-gate fix passed the same 862-case run (858 passed, four skipped) and both TLS revocation tests passed 20 consecutive repetitions. It also extends coverage for unknown clients and idempotent enable updates.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

This pull request was generated by Codex using GPT-6.1 Sol, medium thinking level.

@Peaks2000

Copy link
Copy Markdown
Author

This pull request was generated by Codex using GPT-6.1 Sol, medium thinking level.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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