If you are checking your sites permissions regularly you will probably notice a lot of unique permissions being applied.
❌ Figure: Some items may have unique permissions
The default "Copy Link" setting in SharePoint is usually set to "People from your organization can view this document". This creates a unique sharing link each time it is used, giving people access to the file even if they didn't already. The consequence in SharePoint is that unique permissions are applied to the individual items breaking permission inheritance. It also has performance implications. Links should instead be created with the "People with existing access" setting.
To fix the issue you need to change the default sharing method. There are 2 ways to do this - manually via the GUI or programmatically via PNP.PowerShell.
Figure: Select Sharing
Figure: Select people with existing access
#Variables$AdminCenterURL = "https://sswcom-northwind.sharepoint.com"$HubSiteURL = "https://sswcom.northwind.com"#Connect to PnP OnlineConnect-PnPOnline -Url $AdminCenterURL -Interactive#Get the children of the main HubSite$Hub = Get-PnPHubSiteChild -Identity $HubSiteURLforeach ($Url in $Hub){#Remove the "Same as organization-level" setting. Can be set to anything Internal, None or Direct.Set-PnPTenantSite -Url $Url -DefaultSharingLinkType Internal#Set the Default Link type to be Existing AccessSet-PnPTenantSite -Url $Url -DefaultLinkToExistingAccess $true}
Figure: PowerShell to change default link sharing behaviour that affects security