Stai visualizzando la documentazione di Apigee Edge.
Consulta la
documentazione di Apigee X. info
Cosa
Riduce al minimo il rischio posto dagli attacchi a livello di contenuti consentendoti di specificare limiti su varie strutture JSON, come array e stringhe.
Video: guarda un breve video per scoprire di più su come la policy JSONThreatProtection ti consente di proteggere le API dagli attacchi a livello di contenuti.
Video:guarda questo breve video sulla piattaforma API cross-cloud di Apigee.
Riferimento elemento
Il riferimento all'elemento descrive gli elementi e gli attributi della policy 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 del criterio:
| Attributo | Descrizione | Predefinito | Presenza |
|---|---|---|---|
name |
Il nome interno del criterio. Il valore dell'attributo Se vuoi, puoi utilizzare l'elemento |
N/D | Obbligatorio |
continueOnError |
Imposta il valore su Imposta su |
falso | Facoltativo |
enabled |
Imposta il valore su Imposta |
true | Facoltativo |
async |
Questo attributo è obsoleto. |
falso | Deprecato |
<DisplayName> elemento
Da utilizzare in aggiunta all'attributo name per etichettare il criterio in
editor proxy della UI di gestione con un nome diverso e in linguaggio naturale.
<DisplayName>Policy Display Name</DisplayName>
| Predefinito |
N/D Se ometti questo elemento, il valore dell'attributo |
|---|---|
| Presenza | 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 applica un limite. |
| Presenza : | Facoltativo |
| Tipo : | Numero intero |
Elemento <ContainerDepth>
Specifica la profondità massima di contenimento consentita, dove i contenitori sono oggetti o array. Ad esempio, un array contenente un oggetto che contiene un oggetto comporterebbe 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 un nome di 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 applica un limite. |
| Presenza : | Facoltativo |
| Tipo : | Numero intero |
Elemento <Source>
Messaggio da esaminare per rilevare attacchi di payload JSON. In genere, questo valore è impostato su
request, in quanto in genere è necessario 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 : | request |
| 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 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. | 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>
Schemi
Note sull'utilizzo
Come i servizi basati su XML, le API che supportano la notazione degli oggetti JavaScript (JSON) sono vulnerabili agli attacchi a livello di contenuti. I semplici attacchi JSON tentano di utilizzare strutture che sovraccaricano gli analizzatori JSON per arrestare un servizio e indurre attacchi Denial of Service a livello di applicazione. Tutte le impostazioni sono facoltative e devono essere ottimizzate in base ai requisiti del servizio rispetto alle potenziali vulnerabilità.