auditing-search-queries.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. [[auditing-search-queries]]
  2. === Auditing search queries
  3. There is no <<audit-event-types, audit event type>> specifically
  4. dedicated to search queries. Search queries are analyzed and then processed; the
  5. processing triggers authorization actions that are audited.
  6. However, the original raw query, as submitted by the client, is not accessible
  7. downstream when authorization auditing occurs.
  8. Search queries are contained inside HTTP request bodies, however, and some
  9. audit events that are generated by the REST layer, on the coordinating node,
  10. can be toggled to output the request body to the audit log. Therefore, one
  11. must audit request bodies in order to audit search queries.
  12. To make certain audit events include the request body, edit the following
  13. setting in the `elasticsearch.yml` file:
  14. [source,yaml]
  15. ----------------------------
  16. xpack.security.audit.logfile.events.emit_request_body: true
  17. ----------------------------
  18. IMPORTANT: No filtering is performed when auditing, so sensitive data might be
  19. audited in plain text when audit events include the request body. Also, the
  20. request body can contain malicious content that can break a parser consuming
  21. the audit logs.
  22. The request body is printed as an escaped JSON string value (RFC 4627) to the `request.body`
  23. event attribute.
  24. Not all events contain the `request.body` attribute, even when the above setting
  25. is toggled. The ones that do are: `authentication_success`,
  26. `authentication_failed`, `realm_authentication_failed`, `tampered_request`, `run_as_denied`,
  27. and `anonymous_access_denied`. The `request.body` attribute is printed on the coordinating node only
  28. (the node that handles the REST request). Most of these event types are
  29. <<xpack-sa-lf-events-include, not included by default>>.
  30. A good practical piece of advice is to add `authentication_success` to the event
  31. types that are audited (add it to the list in the `xpack.security.audit.logfile.events.include`),
  32. as this event type is not audited by default.
  33. NOTE: Typically, the include list contains other event types as well, such as
  34. `access_granted` or `access_denied`.