Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

fix(plugins): require admin.pages paths to be rooted

Gabe Kangasc6aeb7aa2ca2
diff --git a/services/plugins/manifest.go b/services/plugins/manifest.go
index c863af73a1..a9d2617b38 100644
--- a/services/plugins/manifest.go
+++ b/services/plugins/manifest.go
@@ -404,6 +404,13 @@ func (m *Manifest) validateAdminPages() error {
if page.Path == "" {
return fmt.Errorf("manifest.admin.pages[%d].path is required", i)
}
+ // Must be rooted. The auth gate matches request paths (which always
+ // start with "/") against this glob and its "<path>/" descendant prefix;
+ // an unrooted value like "admin" matches neither "/admin" nor
+ // "/admin/...", silently leaving the intended subtree unauthenticated.
+ if !strings.HasPrefix(page.Path, "/") {
+ return fmt.Errorf("manifest.admin.pages[%d].path %q must start with \"/\"", i, page.Path)
+ }
}
return nil
}
diff --git a/services/plugins/manifest_test.go b/services/plugins/manifest_test.go
index ab708604a4..4381027c3e 100644
--- a/services/plugins/manifest_test.go
+++ b/services/plugins/manifest_test.go
@@ -231,6 +231,30 @@ func TestParseManifest_Action_ExternalURLPreserved(t *testing.T) {
}
}
+func TestParseManifest_AdminPage_MustBeRooted(t *testing.T) {
+ // An unrooted admin-page path matches neither "/admin" nor "/admin/..." in
+ // the auth gate, silently leaving the subtree unauthenticated, so it's
+ // rejected at load.
+ _, err := ParseManifest([]byte(`{
+ "api": "1", "name": "stats", "version": "1.0",
+ "admin": {"pages": [{"title": "Dash", "path": "admin"}]}
+ }`))
+ if err == nil {
+ t.Fatal("expected error: unrooted admin page path")
+ }
+ if !strings.Contains(err.Error(), "must start with") {
+ t.Errorf("error should explain the rooting requirement, got: %v", err)
+ }
+
+ // A rooted path is accepted.
+ if _, err := ParseManifest([]byte(`{
+ "api": "1", "name": "stats", "version": "1.0",
+ "admin": {"pages": [{"title": "Dash", "path": "/admin/*"}]}
+ }`)); err != nil {
+ t.Errorf("rooted admin page path should be valid, got: %v", err)
+ }
+}
+
func TestParseManifest_Action_MissingHttpServePerm(t *testing.T) {
_, err := ParseManifest([]byte(`{
"api": "1", "name": "stats", "version": "1.0",