๐ Recipe ยท SharePoint & OneDrive
Audit SharePoint Files with Public or Anonymous Sharing Links
Scan every SharePoint site and document library to identify files exposed via anonymous (public) sharing links and produce a remediation-ready report.
Complexity
Intermediate
Impact
security + compliance + data-governance + access-review
Context
Why This Matters
Anonymous sharing links in SharePoint (also called "Anyone" links) allow access to files without authentication โ anyone with the URL can view or edit the content. While convenient for external collaboration, these links are one of the most common sources of data leakage in Microsoft 365 tenants.
Run this audit when you need to:
- Respond to a compliance review (SOC 2, ISO 27001, HIPAA, GDPR)
- Investigate a suspected data exposure incident
- Perform a quarterly or post-acquisition data governance review
- Validate external sharing policy changes after tightening tenant-level settings
- Prepare for a tenant-to-tenant migration or M&A due diligence
The recipe walks every SharePoint site collection, enumerates each document library, inspects file-level sharing permissions, and flags items where the sharing scope is anonymous (and, optionally, organization for a broader posture review).
Expected Outcomes
What you'll have when you're done
- A complete inventory of files with anonymous (public internet) sharing links across all SharePoint sites
- A secondary list of files with organization-wide links (optional but recommended)
- A CSV report with site, file path, link type, permission scope, and direct URL โ suitable for import into a GRC tool or ticketing system
- Clear remediation targets: each flagged file can be revoked or re-shared with specific users
- A repeatable script you can schedule monthly to catch new exposures
Risks & Considerations
Warnings and gotchas
- Read-only audit: The audit itself does not change any permissions. Never auto-revoke sharing links without a review โ you may break legitimate external workflows (partners, contractors, customers).
- Throttling: Large tenants (hundreds of sites, millions of files) will hit Graph API throttling (HTTP 429). Honor
Retry-Afterheaders and paginate with@odata.nextLink. - Permission inspection is per-item: The
sharedproperty on adriveItemonly indicates that it is shared, not how. You must callGET /drives/{id}/items/{id}/permissionsto confirm a link is truly anonymous. - Nested folders:
/root/childrenonly returns top-level items. Use/root/search(q=' ')or recurse into folders to catch every file. - OneDrive is separate: This recipe targets SharePoint sites. OneDrive personal libraries require scanning user drives via
/users/{id}/drive. - Data handling: The output report contains file paths and URLs that may themselves be sensitive. Store it in a restricted location and delete after remediation.
- Don't confuse scopes:
anonymous= public internet;organization= anyone in the tenant with the link;users= specific named users. Onlyanonymousis a true public exposure.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| Sites.Read.All | Enumerate all SharePoint sites and read site metadata |
| Files.Read.All | List drive items across all document libraries |
| Sites.FullControl.All | Required to read detailed sharing permissions on every item (Files.Read.All alone is insufficient for /permissions on some items) |
The fastest way to get this done โ just ask Dex. Copy the prompt below and paste it into your Dex conversation.
For IT Admins
Paste into Dex CoAdmin