Integrity
Add an HMAC hash to each entry, then detect an entry that was changed after it was written.
Enable integrity
The secret must have at least 32 bytes:
symfonycorp_audit_log:
integrity:
secret: '%env(AUDIT_LOG_SECRET)%'
algorithm: sha256Check the entries
$ bin/console audit-log:verify
$ bin/console audit-log:verify --output=dbalThe command exists only when integrity is enabled. It reads every entry. It reports an entry that it cannot read, for example a context with invalid JSON, as a violation. It exits with a non-zero code when it finds a violation. Run it on a schedule and alert on this code.
The EasyAdmin detail page shows the result of one entry as a badge: Verified, Tampered, Missing hash, Cannot verify or Not protected.
Limits
- Each hash covers one entry. The command does not detect a deleted or reordered entry.
- With
dbalandelasticsearch, the hash does not cover thecontext_*columns and fields that the context filter uses. - If the hash cannot be computed, the entry is not written. The bundle logs the failure, or throws it when
silent_failuresisfalse. - A person who has the secret can make valid hashes. Do not keep the secret in the database of the entries.
- If you change the secret or the algorithm, the old entries fail the check.
- The time of an entry comes from the server clock. No trusted third party timestamps the entries.
- Do not edit an entry to erase personal data: delete it. See Erasure.