apply security patch: release-11.4.4/366-202504020732.patch
commit 69b820f274911812ffe5cbcca422ee0c16de44d4 Author: Andres Martinez Gotor <andres.martinez@grafana.com> Date: Mon Mar 31 12:15:52 2025 +0200 Sanitize paths before evaluating access to route
This commit is contained in:
@@ -299,7 +299,15 @@ func (proxy *DataSourceProxy) validateRequest() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// route match
|
// route match
|
||||||
if !strings.HasPrefix(proxy.proxyPath, route.Path) {
|
r1, err := util.CleanRelativePath(proxy.proxyPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r2, err := util.CleanRelativePath(route.Path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(r1, r2) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,14 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
|||||||
err = proxy.validateRequest()
|
err = proxy.validateRequest()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("path with slashes and user is editor", func(t *testing.T) {
|
||||||
|
ctx, _ := setUp()
|
||||||
|
proxy, err := setupDSProxyTest(t, ctx, ds, routes, "//api//admin")
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = proxy.validateRequest()
|
||||||
|
require.Error(t, err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("plugin route with RBAC protection user is allowed", func(t *testing.T) {
|
t.Run("plugin route with RBAC protection user is allowed", func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user