Estás viendo la documentación de Apigee Edge.
Ve a la
Documentación de Apigee X. información

Qué
Minimiza el riesgo que presentan los ataques a nivel de contenido, ya que te permite especificar límites en varias estructuras JSON, como arreglos y strings.
.Video: Mira un video breve para obtener más información sobre cómo la política JSONThreatProtection te permite proteger las API contra ataques a nivel de contenido.
Video: Mira este video breve sobre la plataforma de API entre nubes de Apigee.
Referencia de elementos
En la referencia del elemento, se describen los elementos y atributos de la política JSONThreatProtection.
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSONThreatProtection 1</DisplayName> <ArrayElementCount>20</ArrayElementCount> <ContainerDepth>10</ContainerDepth> <ObjectEntryCount>15</ObjectEntryCount> <ObjectEntryNameLength>50</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>500</StringValueLength> </JSONThreatProtection>
Atributos <JSONThreatProtection>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
En la siguiente tabla, se describen los atributos que son comunes a todos los elementos principales de las políticas:
Atributo | Descripción | Predeterminado | Presencia |
---|---|---|---|
name |
El nombre interno de la política. El valor del atributo De forma opcional, usa el elemento |
N/A | Obligatorio |
continueOnError |
Configúralo como Configúralo como |
falso | Opcional |
enabled |
Configúralo como Configúralo como |
true | Opcional |
async |
Este atributo dejó de estar disponible. |
falso | Obsoleta |
Elemento <DisplayName>
Se usan además del atributo name
para etiquetar la política en el editor de proxy de la IU de administración con un nombre de lenguaje natural diferente.
<DisplayName>Policy Display Name</DisplayName>
Predeterminada |
N/A Si omites este elemento, se usa el valor del atributo |
---|---|
Presencia | Opcional |
Tipo | String |
Elemento <ArrayElementCount>
Especifica la cantidad máxima de elementos permitidos en un arreglo.
<ArrayElementCount>20</ArrayElementCount>
Predeterminado: | Si no especificas este elemento o si especificas un número entero negativo, el sistema no aplica un límite. |
Presencia: | Opcional |
Tipo: | Entero |
Elemento <ContainerDepth>
Especifica la profundidad de contención máxima permitida, en la que los contenedores son objetos o arreglos. Por ejemplo, un arreglo que contiene un objeto que tiene un objeto daría como resultado una profundidad de contención de 3.
<ContainerDepth>10</ContainerDepth>
Predeterminado: | Si no especificas este elemento o si especificas un número entero negativo, el sistema no aplica ningún límite. |
Presencia: | Opcional |
Tipo: | Entero |
Elemento <ObjectEntryCount>
Especifica la cantidad máxima de entradas permitidas en un objeto.
<ObjectEntryCount>15</ObjectEntryCount>
Predeterminado: | Si no especificas este elemento o si especificas un número entero negativo, el sistema no aplica ningún límite. |
Presencia: | Opcional |
Tipo: | Entero |
Elemento <ObjectEntryNameLength>
Especifica la longitud máxima de string permitida para un nombre de propiedad dentro de un objeto.
<ObjectEntryNameLength>50</ObjectEntryNameLength>
Predeterminado: | Si no especificas este elemento o si especificas un número entero negativo, el sistema no aplica un límite. |
Presencia: | Opcional |
Tipo: | Entero |
Elemento <Source>
Mensaje que se validará para los ataques de carga útil de JASON. Normalmente, este se configura como request
, ya que, por lo general, deberás validar las solicitudes entrantes de las apps cliente.
Cuando se configura como message
, este elemento evaluará de manera automática el mensaje de solicitud cuando se adjunta al flujo de solicitudes y el mensaje de respuesta cuando se adjunta al flujo de respuesta.
<Source>request</Source>
Predeterminado: | solicitud |
Presencia: | Opcional |
Tipo: |
String. Valores válidos: solicitud, respuesta o mensaje. |
Elemento <StringValueLength>
Especifica la longitud máxima permitida para un valor de string.
<StringValueLength>500</StringValueLength>
Predeterminado: | Si no especificas este elemento o si especificas un número entero negativo, el sistema no aplica un límite. |
Presencia: | Opcional |
Tipo: | Entero |
Referencia de errores
.
This section describes the fault codes and error messages that are returned and fault variables that are set by Edge when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.
Runtime errors
These errors can occur when the policy executes.
Fault code | HTTP status | Cause | Fix |
---|---|---|---|
steps.jsonthreatprotection.ExecutionFailed |
500 | The JSONThreatProtection policy can throw many different types of ExecutionFailed errors. Most of these errors occur when a specific threshold set in the policy is exceeded. These types of errors include: object entry name length, object entry count, array element count, container depth, string string value length. This error also occurs when the payload contains an invalid JSON object. | build |
steps.jsonthreatprotection.SourceUnavailable |
500 |
This error occurs if the message
variable specified in the <Source> element is either:
|
build |
steps.jsonthreatprotection.NonMessageVariable |
500 |
This error occurs if the <Source> element is set to a variable which
is not of type
message.
|
build |
Deployment errors
None.
Fault variables
These variables are set when this policy triggers an error. For more information, see What you need to know about policy errors.
Variables | Where | Example |
---|---|---|
fault.name="fault_name" |
fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. | fault.name Matches "SourceUnavailable" |
jsonattack.policy_name.failed |
policy_name is the user-specified name of the policy that threw the fault. | jsonattack.JTP-SecureRequest.failed = true |
Example error response
{ "fault": { "faultstring": "JSONThreatProtection[JPT-SecureRequest]: Execution failed. reason: JSONThreatProtection[JTP-SecureRequest]: Exceeded object entry name length at line 2", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
Example fault rule
<FaultRule name="JSONThreatProtection Policy Faults">
<Step>
<Name>AM-CustomErrorResponse</Name>
<Condition>(fault.name Matches "ExecutionFailed") </Condition>
</Step>
<Condition>(jsonattack.JPT-SecureRequest.failed = true) </Condition>
</FaultRule>
Esquemas
Notas de uso
Al igual que los servicios basados en XML, las API que admiten la notación de objetos de JavaScript (JSON) son vulnerables a los ataques a nivel de contenido. Los ataques JSON simples intentan usar estructuras que sobrecarguen los analizadores de JSON para hacer fallar un servicio e inyectar ataques de denegación del servicio a nivel de la aplicación. Todas las opciones de configuración son opcionales y se deben ajustar para optimizar los requisitos de tu servicio contra posibles vulnerabilidades.