Skip to content
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

Dont leak info on UpdateSpace #3449

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/dont-leak-spaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Don't leak space information on update drive

There were some problems with the `UpdateDrive` func in decomposedfs when it is called without permission
- When calling with empty request it would leak the complete drive info
- When calling with non-empty request it would leak the drive name

https://github.com/cs3org/reva/pull/3447
22 changes: 21 additions & 1 deletion pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up
return nil, err
}

// check if user has access to the drive before continuing
if err := fs.checkViewerPermission(ctx, node); err != nil {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{Code: v1beta11.Code_CODE_NOT_FOUND, Message: err.Error()},
}, nil
}

metadata := make(map[string]string, 5)
if space.Name != "" {
metadata[xattrs.NameAttr] = space.Name
Expand Down Expand Up @@ -958,7 +965,20 @@ func (fs *Decomposedfs) checkEditorPermission(ctx context.Context, n *node.Node)
msg := fmt.Sprintf("not enough permissions to change attributes on %s", filepath.Join(n.ParentID, n.Name))
return errtypes.PermissionDenied(msg)
}
return errtypes.NotFound(filepath.Join(n.ParentID, n.Name))
return errtypes.NotFound(n.ID)
}
return nil
}

func (fs *Decomposedfs) checkViewerPermission(ctx context.Context, n *node.Node) error {
// to update the space name or short description we need the manager role
// current workaround: check if RemoveGrant Permission exists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this two comment lines are leftovers

rp, err := fs.p.AssemblePermissions(ctx, n)
switch {
case err != nil:
return errtypes.InternalError(err.Error())
case !rp.Stat:
return errtypes.NotFound(n.ID)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/spaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ var _ = Describe("Spaces", func() {
},
)
Expect(err).ToNot(HaveOccurred())
Expect(updateResp.Status.Code, rpcv1beta1.Code_CODE_PERMISSION_DENIED)
Expect(updateResp.Status.Code).To(Equal(rpcv1beta1.Code_CODE_NOT_FOUND))
})
})
})
Expand Down