Source: CQURE Academy
Author: Daniel
URL: https://cqureacademy.com/blog/your-sql-server-is-handing-attackers-a-map-by-default/
ONE SENTENCE SUMMARY:
SQL Server grants public VIEW ANY DATABASE by default, enabling enumeration and exposing misconfigurations like guest access and TRUSTWORTHY escalation.
MAIN POINTS:
- Newly created logins can list all databases without any explicit permissions.
- Default visibility occurs because public is granted server permission VIEW ANY DATABASE.
- Enumerating database names reveals sensitive business context before any data access.
- Attackers can probe for databases with guest CONNECT accidentally enabled.
- Guest CONNECT enabled in one database grants access to every server login.
- Scripted checks can identify databases where guest is effectively active.
- REVOKE CONNECT FROM guest is recommended outside master, tempdb, and msdb.
- Filtering for is_trustworthy_on highlights potential privilege escalation targets.
- TRUSTWORTHY ON plus sa ownership enables db_owner to reach sysadmin via EXECUTE AS OWNER.
- Revoking VIEW ANY DATABASE has manageable operational impacts on tools and SSMS visibility.
TAKEAWAYS:
- Remove public’s database enumeration power, then explicitly grant it to needed accounts only.
- Audit every database for accidental guest CONNECT grants and disable where unnecessary.
- Treat db_owner requests as high risk, granting least privilege instead.
- Identify and remediate TRUSTWORTHY ON databases, especially those owned by sysadmin accounts.
- Accept msdb’s TRUSTWORTHY requirement but harden by restricting code, permissions, and monitoring DDL.