Norme di JSONThreatProtection

Stai visualizzando la documentazione di Apigee Edge.
Vai alla sezione Documentazione di Apigee X.
Informazioni

Cosa

Riduce al minimo il rischio degli attacchi a livello di contenuti consentendo di specificare limiti per vari Strutture JSON, come array e stringhe.

Video: guarda un breve video per ulteriori informazioni su come la Il criterio JSONThreatProtection consente di proteggere le API da attacchi a livello di contenuto.

Video: guarda questo breve video sulla piattaforma API cross-cloud Apigee.

Riferimento elemento

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

&lt;JSONThreatProtection&gt; attributi

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

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

&lt;ArrayElementCount&gt; elemento

Specifica il numero massimo di elementi consentiti in un array.

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

&lt;ContainerDepth&gt; elemento

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

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

&lt;ObjectEntryCount&gt; elemento

Specifica il numero massimo di voci consentite in un oggetto.

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

&lt;ObjectEntryNameLength&gt; elemento

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

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

&lt;Source&gt; elemento

Messaggio da verificare per gli attacchi di payload JSON. Il valore generalmente impostato è request, poiché in genere occorre convalidare le richieste in entrata provenienti dalle app client. Se impostato su message, questo elemento valuterà automaticamente il messaggio di richiesta quando allegato al flusso della richiesta e il messaggio di risposta quando allegato alla risposta flusso di lavoro.

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

Stringa.

Valori validi: richiesta, risposta o messaggio.

&lt;StringValueLength&gt; elemento

Specifica la lunghezza massima consentita per un valore stringa.

<StringValueLength>500</StringValueLength>
Predefinita: Se non specifichi questo elemento o se indichi un numero intero negativo, il sistema non applica 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 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.
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 JSON (JavaScript Object Notation) sono vulnerabili alle attacchi a livello di contenuto. Semplici attacchi JSON tentano di utilizzare strutture che sovraccaricano i parser JSON per arrestare un servizio e indurre attacchi denial-of-service a livello di applicazione. Tutte le impostazioni sono facoltativa e deve essere ottimizzata per ottimizzare i requisiti dei servizi rispetto le vulnerabilità.

Argomenti correlati

Criteri di JSONtoXML

Criterio XMLThreatProtection

Criterio RegularExpressionProtection