Norme di JSONThreatProtection

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">

La tabella seguente descrive gli attributi comuni a tutti gli elementi principali dei criteri:

Attributo Descrizione Predefinito Presence
name

Il nome interno del criterio. Il valore dell'attributo name può contenere lettere, numeri, spazi, trattini, trattini bassi e punti. Questo valore non può superare i 255 caratteri.

Se vuoi, utilizza l'elemento <DisplayName> per etichettare il criterio nell'editor proxy dell'interfaccia utente di gestione con un nome diverso in linguaggio naturale.

N/D Obbligatorio
continueOnError

Imposta su false per restituire un errore quando un criterio non va a buon fine. Questo è un comportamento previsto per la maggior parte dei criteri.

Imposta su true per continuare l'esecuzione del flusso anche dopo un fallimento del criterio. Vedi anche:

falso Facoltativo
enabled

Imposta su true per applicare il criterio.

Imposta su false per disattivare il criterio. Il criterio non verrà applicato anche se rimane collegato a un flusso.

true Facoltativo
async

Questo attributo è stato ritirato.

falso Deprecato

Elemento <DisplayName>

Da utilizzare insieme all'attributo name per etichettare il criterio nell'editor proxy dell'interfaccia utente di gestione con un nome diverso in linguaggio naturale.

<DisplayName>Policy Display Name</DisplayName>
Predefinito

N/D

Se ometti questo elemento, viene utilizzato il valore dell'attributo name del criterio.

Presence Facoltativo
Tipo Stringa

Elemento <ArrayElementCount>

Specifica il numero massimo di elementi consentiti in un array.

<ArrayElementCount>20</ArrayElementCount>
Valore 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 a sua volta contiene un altro oggetto avrebbe una profondità di contenimento di 3.

<ContainerDepth>10</ContainerDepth>
Valore 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>
Valore 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>
Valore 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 quando è collegato al flusso di richiesta e il messaggio di risposta quando è collegato al flusso di risposta.

<Source>request</Source>
Valore 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>
Valore 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 JavaScript Object Notation (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 regolate per ottimizzare i requisiti del servizio in base alle potenziali vulnerabilità.

Argomenti correlati

Policy JSONtoXML

Policy XMLThreatProtection

Norme RegularExpressionProtection