Unsafe Consumption of Third-Party APIs

The application trusts data and responses from third-party APIs it calls without validating them, so a compromised or impersonated provider can attack the application through them.

SeverityMedium
CVSS 3.14.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N Open in the calculator
CVSS 4.06.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-20: Improper Input Validation
OWASP Top 10A05:2025 Injection
MITRE ATT&CKT1199 Trusted Relationship, T1557 Adversary-in-the-Middle
CategoryInsecure Design

Description

Applications increasingly depend on other APIs: payment and identity providers, address and company lookups, mapping, messaging, data enrichment and partner services. The application treats what these services return as trusted, and applies weaker checks to it than to input from its own users. An attacker who compromises a provider, takes over a provider account, intercepts the connection, or can place data in the provider's records can then use the integration to attack the application or tamper with the data it relies on, and because the data arrives from a trusted partner, the attack may bypass controls applied to user input and go unnoticed. Typical forms are:

  • data from the third party is used in database queries, commands, file paths or web pages without validation, parameterisation or output encoding, so it can carry injection payloads into the application's database or pages;
  • the application follows redirects returned by the third party without restriction, which can turn the integration into a route for server-side request forgery, redirecting its requests to internal systems, or send credentials to another host;
  • calls are made over unencrypted connections, or with certificate validation disabled;
  • there are no timeouts or limits on response size, so a slow or oversized response ties up the application and disrupts it;
  • callbacks and webhooks from the provider are accepted without verifying their signature or origin.

The impact depends on how the data is used, and is high where it reaches queries, commands or other users' browsers. The weakness is identified through code and configuration review of the integrations, by observing outgoing requests, and, where the tester can influence data held by the third party (for example a profile, company record or address entered in the provider's service), by placing test payloads there and observing how the application handles them.

Remediation

Treat every third-party response as untrusted input:

  • Validate data received from other APIs against a strict schema (types, lengths, formats and allowed values) before using it, and apply the same parameterised queries and output encoding as for user input.
  • Use only encrypted connections with full certificate validation to every provider, and never disable validation to work around a certificate problem.
  • Do not follow redirects from third-party APIs automatically; where a redirect is expected, allow only known destinations.
  • Set connection and response timeouts and maximum response sizes on every outbound call, and handle failures safely.
  • Verify the signature, or another proof of origin, on every webhook or callback before acting on it, and reject replayed messages.
  • Assess providers' security before integrating, keep an inventory of integrations and the data they exchange, and give each integration credentials with only the permissions it needs.

Confirm the fix by reviewing each integration against these controls and, where possible, repeating the tests with malformed, oversized, redirecting and unsigned responses from a test provider.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More APIs Findings

Every APIs finding