Norme di JSONThreatProtection

Policy estensibile

Questa pagina si applica ad Apigee e Apigee hybrid.

Visualizza la documentazione di Apigee Edge.

Le API che accettano payload JSON sono vulnerabili ad attacchi dannosi progettati per sovraccaricare il parser JSON. Questi attacchi potrebbero includere payload con elementi di array eccessivi, strutture profondamente nidificate o stringhe incredibilmente lunghe, che possono causare l'arresto anomalo del servizio o consumare memoria eccessiva.

Il criterio JSONThreatProtection riduce al minimo questo rischio esaminando le richieste in entrata per i payload che violano i limiti definiti per strutture come array e stringhe, proteggendo efficacemente i tuoi servizi di backend da questi attacchi di tipo denial of service o parser.

Queste norme sono estendibili e il loro utilizzo potrebbe avere implicazioni in termini di costi o utilizzo, a seconda della licenza Apigee. Per informazioni sui tipi di policy e sulle implicazioni di utilizzo, consulta Tipi di policy.

Riferimento elemento

Il riferimento all'elemento descrive gli elementi e gli attributi del criterio 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>

Attributi <JSONThreatProtection>

<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">

The following table describes attributes that are common to all policy parent elements:

Attribute Description Default Presence
name

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

N/A Required
continueOnError

Set to false to return an error when a policy fails. This is expected behavior for most policies.

Set to true to have flow execution continue even after a policy fails. See also:

false Optional
enabled

Set to true to enforce the policy.

Set to false to turn off the policy. The policy will not be enforced even if it remains attached to a flow.

true Optional
async

This attribute is deprecated.

false Deprecated

<DisplayName> element

Use in addition to the name attribute to label the policy in the management UI proxy editor with a different, natural-language name.

<DisplayName>Policy Display Name</DisplayName>
Default

N/A

If you omit this element, the value of the policy's name attribute is used.

Presence Optional
Type String

Elemento <ArrayElementCount>

Specifica il numero massimo di elementi consentiti in un array.

<ArrayElementCount>20</ArrayElementCount>
Predefinito: Se non specifichi questo elemento o se specifichi un numero intero negativo, il sistema non impone un limite.
Presenza: Facoltativo
Tipo: Numero intero

Elemento <ContainerDepth>

Specifica la profondità massima di contenimento consentita, in cui i contenitori sono oggetti o array. Ad esempio, un array contenente un oggetto che contiene un oggetto avrebbe una profondità di contenimento di 3.

<ContainerDepth>10</ContainerDepth>
Predefinito: Se non specifichi questo elemento o se specifichi un numero intero negativo, il sistema non applica alcun limite.
Presenza: Facoltativo
Tipo: Numero intero

Elemento <ObjectEntryCount>

Specifica il numero massimo di voci consentite in un oggetto.

<ObjectEntryCount>15</ObjectEntryCount>
Predefinito: Se non specifichi questo elemento o se specifichi un numero intero negativo, il sistema non applica alcun limite.
Presenza: Facoltativo
Tipo: Numero intero

Elemento <ObjectEntryNameLength>

Specifica la lunghezza massima della stringa consentita per il nome di una proprietà all'interno di un oggetto.

<ObjectEntryNameLength>50</ObjectEntryNameLength>
Predefinito: Se non specifichi questo elemento o se specifichi un numero intero negativo, il sistema non impone un limite.
Presenza: Facoltativo
Tipo: Numero intero

Elemento <Source>

Messaggio da analizzare per rilevare attacchi al payload JSON. Questo valore è in genere impostato su request, poiché in genere devi convalidare le richieste in entrata dalle app client. Se impostato su message, questo elemento valuterà automaticamente il messaggio di richiesta se collegato al flusso di richiesta e il messaggio di risposta se collegato al flusso di risposta.

<Source>request</Source>
Predefinito: richiesta
Presenza: Facoltativo
Tipo:

Stringa.

Valori validi: request, response o message.

Elemento <StringValueLength>

Specifica la lunghezza massima consentita per un valore stringa.

<StringValueLength>500</StringValueLength>
Predefinito: Se non specifichi questo elemento o se specifichi un numero intero negativo, il sistema non impone un limite.
Presenza: Facoltativo
Tipo: Numero intero

Messaggi di errore

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee 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.
steps.jsonthreatprotection.SourceUnavailable 500 This error occurs if the message variable specified in the <Source> element is either:
  • Out of scope (not available in the specific flow where the policy is being executed)
  • Is not one of the valid values request, response, or message
steps.jsonthreatprotection.NonMessageVariable 500 This error occurs if the <Source> element is set to a variable which is not of type message.

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>

Schemi

Note sull'utilizzo

Come i servizi basati su XML, le API che supportano la notazione di oggetti JavaScript (JSON) sono vulnerabili agli attacchi a livello di contenuti. I semplici attacchi JSON tentano di utilizzare strutture che sovraccaricano i parser JSON per bloccare un servizio e indurre attacchi DoS a livello di applicazione. Tutte le impostazioni sono facoltative e devono essere ottimizzate per soddisfare i requisiti del servizio in base alle potenziali vulnerabilità.

Argomenti correlati

Policy JSONtoXML

Policy XMLThreatProtection

Norme RegularExpressionProtection