Configurazione di Dispatcher per impedire attacchi CSRF configuring-dispatcher-to-prevent-csrf-attacks
AEM fornisce un framework per prevenire gli attacchi di tipo Cross-Site Request Forgery. Per utilizzare correttamente questo framework, devi apportare le seguenti modifiche alla configurazione di Dispatcher:
- Nella sezione
/clientheaders
di dei file author-farm.any e publish-farm.any, aggiungi la seguente voce in fondo all’elenco:CSRF-Token
- Nella sezione /filters dei file
author-farm.any
epublish-farm.any
opublish-filters.any
, aggiungi la seguente riga per consentire le richieste di/libs/granite/csrf/token.json
tramite Dispatcher./0999 { /type "allow" /glob " * /libs/granite/csrf/token.json*" }
- Nella sezione
/cache /rules
del filepublish-farm.any
, aggiungi una regola per impedire a Dispatcher di memorizzare in cache il filetoken.json
. In genere, gli autori ignorano il caching, pertanto non è necessario aggiungere la regola nel fileauthor-farm.any
./0999 { /glob "/libs/granite/csrf/token.json" /type "deny" }
Per verificare che la configurazione funzioni, esamina il file dispatcher.log in modalità DEBUG per accertarti che il file token.json non sia memorizzato in cache e non sia bloccato da filtri. Dovresti vedere messaggi simili ai seguenti:... checking [/libs/granite/csrf/token.json]
... request URL not in cache rules: /libs/granite/csrf/token.json
... cache-action for [/libs/granite/csrf/token.json]: NONE
Puoi anche verificare che le richieste abbiano esito positivo nel file access_log
del tuo modulo Apache. Le richieste di ``/libs/granite/csrf/token.json devono restituire il codice di stato HTTP 200.