Repository navigation
fix: security and bug fixes from the 2026-11-27 code audit #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,556
−187
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d266a86
fix(api): harden readiness, login throttling, audit and resource owne…
claude ddad587
fix(web): block every readiness path, honour the upload limit, flush …
claude a5c980d
fix(operator): rcon Secret adoption, backup Job names, OCI layer caps…
claude b4b92e6
fix(agent,gameproto): archive hard links, gzip integrity, Minecraft t…
claude d6afd9f
fix(telemetry,gp-module): cap k8s versions per report, package only m…
claude b39afec
fix(ci): check design-export paths after applying the patch
claude cdb9c4c
fix(images): make the FiveM, Farming Simulator 25 and ETS2 images run
claude 9f263aa
docs(changelog): add the audit fixes entry
claude 17597d1
fix(api): take the argon2 slot before building the dummy hash
claude 32aad76
fix(api): lint findings in the audit and ownership changes
claude b9569ea
test(agent): cover the gzip trailer and hard link target checks
claude a1c179a
fix(api): keep the login file to the invalid-credentials message
claude 207ddd2
fix: address review on the audit fixes
claude 80942ec
fix(api): close response bodies in the busy tests
claude 8e78fd8
fix: close review gaps in the audit fixes
claude f8e92e1
fix(telemetry-receiver): cap the folded k8s other share at 100%
claude 65152d5
fix(operator): use the user's RCON password config field
claude d8799d6
chore: bump sftp to include GameplanePanel/sftp#7
claude acc1420
chore: merge master into fix/security-bug-audit-2026-11-27
claude c0d9776
test(bundlefetch): cover negative layer sizes, the module bundle tota…
claude 69ca74f
test(bundlefetch): store the template blob in the bundle-total test
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package archive | ||
|
|
||
| import ( | ||
| "archive/tar" | ||
| "bytes" | ||
| "compress/gzip" | ||
| "io/fs" | ||
| "os" | ||
| "path" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| func TestUnpackHardLinkToReplacedSymlinkRefused(t *testing.T) { | ||
| ents := []tarEnt{ | ||
| {name: "d/f", body: "x"}, | ||
| {name: "d/f", typ: tar.TypeSymlink, link: "../x"}, | ||
| {name: "top", typ: tar.TypeLink, link: "d/f"}, | ||
| } | ||
| _, _, err := unpackTar(t, ents, UnpackOptions{}) | ||
| if err == nil { | ||
| t.Fatal("Unpack accepted a hard link to a name replaced by a symlink") | ||
| } | ||
| // symlink() forgets the replaced regular file, so the hard link is | ||
| // refused by the x.files lookup; the Fstatat check is a second guard. | ||
| if msg := err.Error(); !strings.Contains(msg, "not yet extracted") && !strings.Contains(msg, "not a regular file") { | ||
| t.Fatalf("error %q did not come from the hard link check", err) | ||
| } | ||
| } | ||
|
|
||
| func TestUnpackDirOverRegularFileRefused(t *testing.T) { | ||
| ents := []tarEnt{ | ||
| {name: "f", body: "x"}, | ||
| {name: "f", typ: tar.TypeDir}, | ||
| } | ||
| if _, _, err := unpackTar(t, ents, UnpackOptions{}); err == nil { | ||
| t.Fatal("Unpack accepted a directory entry over a regular file") | ||
| } | ||
| } | ||
|
|
||
| func TestUnpackTarGzBadCRCRefused(t *testing.T) { | ||
| data := makeTarGzBytes(t, []tarEnt{{name: "f", body: "hello"}}) | ||
| data[len(data)-8] ^= 0xff | ||
| _, err := Unpack(writeArchive(t, data), t.TempDir(), UnpackOptions{Format: "tar.gz", MaxBytes: 1 << 20}) | ||
| if err == nil { | ||
| t.Fatal("Unpack accepted an archive with a bad gzip CRC") | ||
| } | ||
| } | ||
|
|
||
| func TestUnpackTarGzMissingTrailerRefused(t *testing.T) { | ||
| data := makeTarGzBytes(t, []tarEnt{{name: "f", body: "hello"}}) | ||
| data = data[:len(data)-8] | ||
| _, err := Unpack(writeArchive(t, data), t.TempDir(), UnpackOptions{Format: "tar.gz", MaxBytes: 1 << 20}) | ||
| if err == nil { | ||
| t.Fatal("Unpack accepted an archive with a missing gzip trailer") | ||
| } | ||
| } | ||
|
|
||
| // tarGzWithTrailer builds a tar.gz whose gzip stream carries extra bytes | ||
| // after the tar end marker. | ||
| func tarGzWithTrailer(t *testing.T, trailer []byte) []byte { | ||
| t.Helper() | ||
| var tarBuf bytes.Buffer | ||
| tw := tar.NewWriter(&tarBuf) | ||
| if err := tw.WriteHeader(&tar.Header{Name: "f", Typeflag: tar.TypeReg, Mode: 0o644, Size: 5}); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if _, err := tw.Write([]byte("hello")); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := tw.Close(); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| var out bytes.Buffer | ||
| gz := gzip.NewWriter(&out) | ||
| if _, err := gz.Write(append(tarBuf.Bytes(), trailer...)); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := gz.Close(); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| return out.Bytes() | ||
| } | ||
|
|
||
| func TestUnpackTarGzTrailingDataRefused(t *testing.T) { | ||
| data := tarGzWithTrailer(t, []byte("junk after the end marker")) | ||
| _, err := Unpack(writeArchive(t, data), t.TempDir(), UnpackOptions{Format: "tar.gz", MaxBytes: 1 << 20}) | ||
| if err == nil || !strings.Contains(err.Error(), "unexpected data after tar end marker") { | ||
| t.Fatalf("err = %v, want trailing data refusal", err) | ||
| } | ||
| } | ||
|
|
||
| func TestUnpackTarGzZeroPaddingAccepted(t *testing.T) { | ||
| data := tarGzWithTrailer(t, make([]byte, 4096)) | ||
| if _, err := Unpack(writeArchive(t, data), t.TempDir(), UnpackOptions{Format: "tar.gz", MaxBytes: 1 << 20}); err != nil { | ||
| t.Fatalf("Unpack refused zero padding after the end marker: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // The x.files bookkeeping normally keeps a hard link off anything but a | ||
| // regular file; this checks the on-disk guard behind it on its own. | ||
| func TestHardlinkRefusesNonRegularTarget(t *testing.T) { | ||
| root := t.TempDir() | ||
| vol := filepath.Join(root, "volumes", plainVolume) | ||
| if err := os.MkdirAll(vol, 0o755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.Symlink("/etc/passwd", filepath.Join(vol, "s")); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| fd, err := unix.Open(root, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer func() { _ = unix.Close(fd) }() | ||
| x := &extractor{rootFD: fd, max: 1 << 20, files: map[string]int64{path.Join("volumes", plainVolume, "s"): 0}, dirs: map[string]fs.FileMode{}} | ||
| err = x.hardlink(path.Join("volumes", plainVolume, "top"), "s", layout{plain: true}) | ||
| if err == nil || !strings.Contains(err.Error(), "not a regular file") { | ||
| t.Fatalf("err = %v, want not a regular file", err) | ||
| } | ||
| } | ||
|
|
||
| func TestUnpackTarGzOversizedPaddingRefused(t *testing.T) { | ||
| data := tarGzWithTrailer(t, make([]byte, maxTarTrailerBytes+1024)) | ||
| _, err := Unpack(writeArchive(t, data), t.TempDir(), UnpackOptions{Format: "tar.gz", MaxBytes: 1 << 20}) | ||
| if err == nil || !strings.Contains(err.Error(), "after tar end marker") { | ||
| t.Fatalf("err = %v, want oversized padding refusal", err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/go-chi/chi/v5" | ||
|
|
||
| "github.com/GameplanePanel/gameplane/api/internal/db" | ||
| ) | ||
|
|
||
| func TestReadinessRefusesProxiedRequests(t *testing.T) { | ||
| store, err := db.Open(t.Context(), "sqlite", ":memory:") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| t.Cleanup(func() { _ = store.Close() }) | ||
| r := chi.NewRouter() | ||
| mountHealthRoutes(r, store) | ||
|
|
||
| for _, header := range []string{"X-Forwarded-For", "Forwarded"} { | ||
| req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/readyz", nil) | ||
| req.Header.Set(header, "203.0.113.7") | ||
| rr := httptest.NewRecorder() | ||
| r.ServeHTTP(rr, req) | ||
| if rr.Code != http.StatusNotFound { | ||
| t.Fatalf("%s: status=%d, want 404", header, rr.Code) | ||
| } | ||
| } | ||
| rr := httptest.NewRecorder() | ||
| r.ServeHTTP(rr, httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/readyz", nil)) | ||
| if rr.Code != http.StatusOK { | ||
| t.Fatalf("direct probe: status=%d, want 200", rr.Code) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.