The vulnerability is a Time-of-Check-to-Time-of-Use (TOCTOU) weakness in the Server-Side Request Forgery (SSRF) protection mechanism, specifically exploitable via DNS rebinding. The application flow is as follows:
-
Check: When a request is received with an X-Atlassian-Jira-Url header, a middleware component calls the validate_url_for_ssrf function. This function resolves the provided hostname to an IP address and verifies that it is a publicly routable address.
-
Flaw: The validation is flawed because the application does not 'pin' this validated IP address. It only confirms that the hostname resolved to a safe IP at that moment.
-
Use: Later in the process, a client fetcher (such as JiraClient or ConfluenceClient) is created via the _get_fetcher function. When this client makes an HTTP request to the user-provided URL, the underlying requests library performs a new DNS resolution for the same hostname.
-
Exploit: An attacker can set up a malicious DNS server with a short Time-To-Live (TTL). When the initial validation check occurs, the server returns a safe, public IP. Immediately after, the DNS record is updated to point to a private, internal IP (e.g., 169.254.169.254 to access cloud provider metadata services). By the time the application makes the actual HTTP request, the hostname resolves to the malicious internal IP, bypassing the SSRF guard.
The patch addresses this by introducing a custom requests transport adapter, SsrfPinningAdapter, which is mounted in the JiraClient and ConfluenceClient constructors. This adapter performs DNS resolution and IP validation in a single, atomic operation, connecting directly to the validated IP address and thus eliminating the window for a DNS rebinding attack.