fix(server): bound the public-IP lookup and accept only an address

getPublicIP read a third-party IP echo service's body whole and cached
whatever came back as the panel's address, so one misbehaving service
could make the panel inflate an endless response at startup, and an
error page became the address shown in every status sample.

The read is capped at 64 bytes and only a parsable IP is accepted;
anything else counts as unavailable. The GitHub release lookups are
capped as well.
This commit is contained in:
MHSanaei
2026-11-01 13:18:01 +01:00
parent f99c6c664d
commit 06cb1742a1
3 changed files with 45 additions and 7 deletions
+2 -1
View File
@@ -43,6 +43,7 @@ type PanelUpdateInfo struct {
const (
panelUpdaterURL = "https://raw.githubusercontent.com/MHSanaei/3x-ui/main/update.sh"
maxPanelUpdaterBytes = 2 << 20
maxPanelReleaseBytes = 2 << 20
// devReleaseTag is the fixed-tag rolling pre-release the CI force-moves to the
// newest main commit; the dev update channel installs from it.
devReleaseTag = "dev-latest"
@@ -450,7 +451,7 @@ func fetchPanelRelease(tag string) (*service.Release, error) {
}
var release service.Release
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
if err := json.NewDecoder(io.LimitReader(resp.Body, maxPanelReleaseBytes)).Decode(&release); err != nil {
return nil, err
}
return &release, nil