π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[server] Validate diff limit to prevent unbounded results
Neeraj Guptae7fefff6aa03
diff --git a/server/pkg/controller/authenticator/controller.go b/server/pkg/controller/authenticator/controller.goindex 10b59210cc..7f120b0d94 100644--- a/server/pkg/controller/authenticator/controller.go+++ b/server/pkg/controller/authenticator/controller.go@@ -82,6 +82,9 @@ func (c *Controller) Delete(ctx *gin.Context, entityID uuid.UUID) (bool, error)// GetDiff...func (c *Controller) GetDiff(ctx *gin.Context, req model.GetEntityDiffRequest) ([]model.Entity, error) {+ if req.Limit <= 0 || req.Limit > 5000 {+ return nil, ente.NewBadRequestWithMessage("limit must be between 1 and 5000")+ }userID := auth.GetUserID(ctx.Request.Header)return c.Repo.GetDiff(ctx, userID, *req.SinceTime, req.Limit)}diff --git a/server/pkg/controller/userentity/controller.go b/server/pkg/controller/userentity/controller.goindex 38b99fba22..bc30911e36 100644--- a/server/pkg/controller/userentity/controller.go+++ b/server/pkg/controller/userentity/controller.go@@ -1,6 +1,7 @@package authenticaorimport (+ "github.com/ente-io/museum/ente"model "github.com/ente-io/museum/ente/userentity""github.com/ente-io/museum/pkg/repo/userentity""github.com/ente-io/museum/pkg/utils/auth"@@ -60,6 +61,9 @@ func (c *Controller) Delete(ctx *gin.Context, entityID string) (bool, error) {// GetDiff returns diff of EntityData for the given typefunc (c *Controller) GetDiff(ctx *gin.Context, req model.GetEntityDiffRequest) ([]model.EntityData, error) {+ if req.Limit <= 0 || req.Limit > 5000 {+ return nil, ente.NewBadRequestWithMessage("limit must be between 1 and 5000")+ }userID := auth.GetUserID(ctx.Request.Header)return c.Repo.GetDiff(ctx, userID, req.Type, *req.SinceTime, req.Limit)}