The vulnerability lies in the improper authorization of the /log endpoint in the Juju API server. Any authenticated user could access this endpoint and read debug logs, which could contain sensitive information. The root cause of this issue was the weak authorization configuration within the apiserver.Server.endpoints function.
The analysis of the provided patches (commits 402ff008dcc2cb57f4441968628637efb5c2a662 and c91a1f4046956874ba77c8b398aecee3d61a2dc3) reveals that the endpoints function was modified to enforce stricter access control. Specifically, the original implementation used a tagKindAuthorizer that only verified that the user was authenticated, but did not perform any permission checks for accessing logs.
The fix, as seen in the patches, was to introduce a CompositeAuthorizer for the debugLogHandler. This new authorizer combines the existing tagKindAuthorizer (now restricted to machine and controller agents) with a modelPermissionAuthorizer. This new authorizer ensures that any user attempting to access the /log endpoint must have permission.ReadAccess on the model, effectively preventing unauthorized users from reading the logs.
Therefore, the apiserver.(*Server).endpoints function is identified as the vulnerable function because it was responsible for the insecure configuration of the /log endpoint's authorization.