Microsoft has announced a security flaw in its Azure cloud service. According to the announcement, due to the bug in the service, PostgreSQL databases were accessible by other customers’ accounts. The bug in the PostgreSQL Flexible Server authentication process allows elevating permissions.
Cross-account database access
By elevating permissions, a customer with malicious intentions could leverage an improperly anchored regular expression to bypass authentication; resulting in unauthorized access to other customers’ databases. The vulnerability has only affected the customers who deployed their servers with the public access networking option; the instances with the private access networking option were not affected.
Microsoft states that they fixed the issue within the 48 hours of they were noticed by Wiz, on January 13th. The company has taken the following steps to fix the PostgreSQL database authentication problem on its Azure service:
- Fixes were rolled out worldwide on January 13, 2022.
- Provide complete isolation between different tenants’ underlying virtual machine instances.
- Fixing the pg_ident.conf issue to allow replication permissions only when the exact subject name is matched instead of a prefix match.
- During that patch rollout, Microsoft also addressed all of the new server creations to have blocked both elevated privileged access and remote code access.
- After fixes were deployed, Microsoft security teams and Wiz validated the fixes.
- Microsoft finished updating the entire fleet of existing servers which addressed the remaining issues by February 25, 2022. The fixes included:
- Blocking the copy program in Postgres to mitigate the reported Remote Code Execution in the Flexible Server PostgreSQL service
- Fixing the verbose Postgres error message that displayed the certificate name
Microsoft has also provided the details regarding the exploitation of the vulnerability which is currently fixed:
- An issue with how extensions were handled in Microsoft’s specific implementation of Postgres pg_admin could potentially allow pg_admin to elevate to Superuser
- Due to the insufficient network isolation between Flexible Server instances, an attacker could discover and try to connect to other Flexible Server instances within the region.
- With an overly permissive regular expression used to map certificate common names to users, it was possible to bypass the certificate authentication used for replication connections between Flexible Server Postgres instances.