Description: Connection pooling within libcurl can lead to the reuse of HTTP connections across different API requests, potentially using incorrect OAuth bearer tokens. When a user authenticates with one token and then another user makes a request without forcing a new connection, the second request might be served on the first connection, inadvertently using the first user's token. This can result in unauthorized access to resources or data belonging to the first user.
How to Test:
- Authenticate with API using an OAuth bearer token:
curl -H "Authorization: Bearer <TOKEN1>" <TARGETURL> - Establish a persistent TCP connection to the API endpoint.
- Authenticate with API using a different OAuth bearer token on the same easy handle without setting
CURLOPTFRESHCONNECT=1:curl -H "Authorization: Bearer <TOKEN2>" <TARGETURL> - Observe that the second request is served on the first connection and uses the
Authorization: Bearer <TOKEN_1>header. - Verify that the API server processes the second request as if it were made by the user associated with
<TOKEN_1>.
Impact: Unauthorized access to resources and data belonging to other users, potentially leading to data breaches, account takeover, or other security compromises.
Remediation: Ensure that connections are refreshed when switching between OAuth bearer tokens on the same host. Developers should set CURLOPTFRESHCONNECT=1 when switching tokens or explicitly reset the easy handle (curleasyreset()) to force a new connection for each request. Structurally, ensure that OAuth bearer token changes always trigger a connection pool expiry for HTTP connections, irrespective of credential-per-request flags.