[PR #5396] [MERGED] fix(xray): verify the release archive checksum before installing #5870

Closed
opened 2026-11-02 04:04:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5396
Author: @n0ctal
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @MHSanaei

Base: main ← Head: pr-0004-xray-checksum


📝 Commits (2)

  • fe44c60 fix(xray): verify the release archive checksum before installing
  • cab964e address review: clearer warning + re-download guidance on checksum mismatch

📊 Changes

2 files changed (+134 additions, -0 deletions)

View changed files

📝 internal/web/service/server.go (+62 -0)
➕ internal/web/service/server_xray_checksum_test.go (+72 -0)

📄 Description

Summary

Verify the downloaded Xray-core release archive against its published SHA2-256 before installing, instead of installing it after only a TLS fetch + HTTP-200 + a size cap.

Why

UpdateXray → downloadXRay fetched the release zip and installed the binary from it with no integrity check on the artifact itself. TLS protects the transport, not the bytes: a corrupted or tampered release asset (a bad mirror/CDN, or a proxy that terminates TLS) would be extracted and run as the panel's long-lived xray process.

Scope

  • after download, fetch the .dgst sidecar XTLS publishes next to each asset, parse its SHA2-256 (the label is SHA2-256=, not SHA256=), compute the archive's SHA-256, and abort on mismatch
  • abort the update when the .dgst is unreachable or has no/short SHA2-256 entry — fail closed, never install an unverified archive. (Maintainer note: this hard-fails updating to any release without a published .dgst; happy to switch to warn-and-proceed if you'd prefer to keep installing those.)
  • the .dgst read is capped at 64 KiB

Validation

  • unit tests for the digest parser (the real v26.3.27 .dgst line format, plus missing/malformed entries) and the fetch (httptest 200 + 404)
  • internal/web/service package tests pass

Risk

Low. Adds a verification step inside the existing download path; no API or behaviour change beyond rejecting an unverifiable archive.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5396 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/19/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `pr-0004-xray-checksum` --- ### 📝 Commits (2) - [`fe44c60`](https://github.com/MHSanaei/3x-ui/commit/fe44c60bea3e925f157bfa5434609f3c177d45d6) fix(xray): verify the release archive checksum before installing - [`cab964e`](https://github.com/MHSanaei/3x-ui/commit/cab964e357f6af522e9faaffec913721a3610d1d) address review: clearer warning + re-download guidance on checksum mismatch ### 📊 Changes **2 files changed** (+134 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/server.go` (+62 -0) ➕ `internal/web/service/server_xray_checksum_test.go` (+72 -0) </details> ### 📄 Description ## Summary Verify the downloaded Xray-core release archive against its published `SHA2-256` before installing, instead of installing it after only a TLS fetch + HTTP-200 + a size cap. ## Why `UpdateXray` → `downloadXRay` fetched the release zip and installed the binary from it with no integrity check on the artifact itself. TLS protects the transport, not the bytes: a corrupted or tampered release asset (a bad mirror/CDN, or a proxy that terminates TLS) would be extracted and run as the panel's long-lived xray process. ## Scope - after download, fetch the `.dgst` sidecar XTLS publishes next to each asset, parse its `SHA2-256` (the label is `SHA2-256=`, not `SHA256=`), compute the archive's SHA-256, and abort on mismatch - abort the update when the `.dgst` is unreachable or has no/short `SHA2-256` entry — fail closed, never install an unverified archive. *(Maintainer note: this hard-fails updating to any release without a published `.dgst`; happy to switch to warn-and-proceed if you'd prefer to keep installing those.)* - the `.dgst` read is capped at 64 KiB ## Validation - unit tests for the digest parser (the real v26.3.27 `.dgst` line format, plus missing/malformed entries) and the fetch (httptest 200 + 404) - `internal/web/service` package tests pass ## Risk Low. Adds a verification step inside the existing download path; no API or behaviour change beyond rejecting an unverifiable archive. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5870
No description provided.