API security

Ambiguous API parameters and duplicate JSON keys

Service boundary: server, gate, database arranged to illustrate ambiguous api parameters and duplicate json keys.

Different parsers can interpret duplicate or ambiguous values differently. Understanding ambiguous API parameters and duplicate json keys helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Input validation defines the structures, sizes and meanings an application expects to receive. It must happen before information influences a sensitive operation. Validation does not replace safe interpreter APIs, output encoding or permission checks, because those controls address different boundaries.

This section explains how the structure and header fields of an HTTP message should be validated to prevent attacks such as request smuggling, response splitting, header injection, and denial of service via overly long HTTP messages.

Effective input validation controls enforce business or functional expectations around the type of data the application expects to receive. This ensures good data quality and reduces the attack surface. However, it does not remove or replace the need to use correct encoding, parameterization, or sanitization when using the data in another component or for presenting it for output.

Why it matters

Consider a realistic failure: a gateway checks the first role field while the application uses the last.

Untrusted input can change application behaviour, consume excessive resources or reach data and execution paths outside the intended feature. The practical result depends on where the value is used and which privileges are available there.

An API review follows the server-side behaviour behind the interface. Direct requests, alternate methods and background operations can reveal boundaries that the normal frontend journey does not exercise.

How penetration testers check for it

Compare query, header and JSON handling across intermediaries and application components.

  • Confirm that all application components (including load balancers, firewalls, and application servers) determine boundaries of incoming HTTP messages using the appropriate mechanism for the HTTP version to prevent HTTP request smuggling. In HTTP/1.x, if a Transfer-Encoding header field is present, the Content-Length header must be ignored per RFC 2616. When using HTTP/2 or HTTP/3, if a Content-Length header field is present, the receiver must ensure that it is consistent with the length of the DATA frames.
  • Confirm that when generating HTTP messages, the Content-Length header field does not conflict with the length of the content as determined by the framing of the HTTP protocol, in order to prevent request smuggling attacks.
  • Confirm that the application does not send nor accept HTTP/2 or HTTP/3 messages with connection-specific header fields such as Transfer-Encoding to prevent response splitting and header injection attacks.
  • Confirm that the application only accepts HTTP/2 and HTTP/3 requests where the header fields and values do not contain any CR (\r), LF (\n), or CRLF (\r\n) sequences, to prevent header injection attacks.
  • Verify that, if the application (backend or frontend) builds and sends requests, it uses validation, sanitization, or other mechanisms to avoid creating URIs or HTTP request header fields, which are too long to be accepted by the receiving component. This could cause a denial of service, such as when sending an overly long request, which results in the server always responding with an error status.
  • Confirm that input is validated to enforce business or functional expectations for that input. This should either use positive validation against an allow list of values, patterns, and ranges, or be based on comparing the input to an expected structure and logical limits according to predefined rules. For L1, this can focus on input which is used to make specific business or security decisions. For L2 and up, this should apply to all input.
  • Confirm that the application is designed to enforce input validation at a trusted service layer. While client-side validation improves usability and should be encouraged, it must not be relied upon as a security control.
  • Confirm that the application ensures that combinations of related data items are reasonable according to the pre-defined rules.
  • Compare parsing across components and alternate request formats.
  • Use controlled invalid inputs to establish effects rather than assumptions.

How to fix it

Reject ambiguous input and keep parsing and normalisation rules consistent.

  • Use explicit schemas and canonical representations.
  • Prefer safe parsers and parameterised interpreter interfaces.
  • Reject unexpected structures before sensitive processing.
  • Apply resource bounds and predictable failure handling.

Blocking a few known attack strings is not a complete validation strategy. The intended data model and downstream interpretation determine which protections are needed.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your APIs and integrations.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo