1. Home
  2. ...
  3. Security Interceptors
  4. JSON Threat Protection

JSON Threat Protection

Validation of JSON contents by length, depth and number of elements.

JSON Threat Protection is an interceptor that validates the contents of a JSON based on length, depth and number of elements for several components. This can avoid malicious attacks with illegitimate values.

To set up the interceptor, we have to fill in some properties, as shown in the image below. Then, each field is described.

Fields

Container depth

It specifies the depth of an object.

Example of a JSON with depth 3:

Object entry count

It specifies the number of attributes in an object.

Example of a JSON with 4 attributes:

Object Entry name length

It specifies the number of characters of an attribute.

In this example, the quantity is 4 characters:

Array element count

It specifies the number of elements within an array.

Example of an array with 6 elements:

String value length

It specifies the number of characters of the value of any attribute.

In this example, the quantity is 8 characters:

Skip response if fail

It specifies whether to skip the response in case of failure. When this option is checked, if there is any error in the previous validations, the Gateway will not forward the request to the backend, but immediately return it to the client. This option is required when the JSON Threat Protection interceptor is configured both in the request and in the response flow, thus avoiding validation conflicts.

Things to keep in mind

  • If all the properties of the interceptor are filled, the first validation that the Gateway sees will have its exception triggered.

  • If you want a property not to be validated, just leave its field blank.

  • If you select the interceptor, at least one of the properties must be filled.

  • By default, for POST and PUT requests, the HTTP header Content-type: application/json must be informed. Otherwise, an "HTTP 415: Unsupported Media Type" error is returned.

Flow

The interceptor can be inserted in both the request and response flows, as shown in the image below:

Errors

You can see below the errors that can be returned if the interceptor finds any anomaly.

Title
Error
HTTP Code Request
HTTP Code Response
JSONJson format invalid400500
Container depthContainer depth limit exceeds the maximum allowed for this API (10)400500
Object entry countObject entry count limit exceeds the maximum allowed for this API (10)400500
Object Entry name lengthObject entry name length limit exceeds the maximum allowed for this API (10)400500
Array element countArray element count limit exceeds the maximum allowed for this API (30)400500
String value lengthString value length limit exceeds the maximum allowed for this API (30)400500
Invalid Content-TypeJSON threat protection validation failed: Invalid Content-Type in Header -> (Content type)415415
Content-Type not foundJSON threat protection validation failed: Content-Type not found in Header415415

How happy are you with this page?

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more