When you want to hide some menu for anonymous users, Custom HTML is useful.
Solution
- Navigate to Confluence Administration page >> Custom HTML.
- Click Edit.
- Add the following to At the end of the HEAD section and click Save:
<script>
  AJS.toInit(function(){
    if (AJS.params.remoteUser == ''){
      AJS.$("#space-tools-menu-trigger").hide();
    }
  });
</script>