The vulnerability lies in the get_task function in weblate/api/views.py, which is responsible for retrieving task information for the API. The function failed to properly enforce access controls for tasks that were still in a 'PENDING' state. This is because the logic for retrieving the associated component or translation (which is needed for the permission check) relied on the task's result being available, which is not the case for pending tasks. The patch addresses this by introducing a new mechanism to store and retrieve task metadata (specifically component_id and translation_id) in the cache when a task is created. The get_task function was modified to use this metadata to fetch the associated object and perform the permission check, even for pending tasks. The TaskViewSet.retrieve method is the API endpoint that calls the vulnerable get_task function, making it the entry point for a potential exploit.