The vulnerability is a classic race condition in the application's API endpoints for creating subdomains and registering tunnels. The root cause is the lack of a locking mechanism when the application checks for resource limits (number of subdomains or tunnels) before creating a new resource. The application first reads the current count of resources, then compares it with the limit allowed by the user's plan, and only then proceeds to create the new resource. An attacker can exploit this by sending multiple requests in parallel. Due to the race condition, all requests might read the resource count before any of them has a chance to update it, thus all of them will pass the limit check and create a new resource, effectively bypassing the restrictions of the user's plan. The provided patches fix this by wrapping the check-and-create logic in a database transaction and using FOR UPDATE to acquire a row-level lock. This ensures that concurrent requests are serialized, preventing the race condition.