fix: audit log records new passwords in plain text (#31622)

With request auditing turned on, the audit log only masked fields named exactly "password". The new password from a password change, and passwords entered in admin settings such as YaCy or Jupyter, were written to the log as-is. Any field whose name ends in "password", in any letter case, is now replaced with asterisks.
This commit is contained in:
Classic298 authored and GitHub committed 2026-09-30 19:09:03 +04:00
1 parent b4ebd0d62f
commit d3dde3609d
1 file changed
+4 -3
+4 -3
View File
@@ -282,11 +282,12 @@ class AuditLoggingMiddleware:
response_body = context.response_body.decode('utf-8', errors='replace')
# Redact sensitive information
if 'password' in request_body:
if 'password' in request_body.lower():
request_body = re.sub(
r'"password":\s*"(.*?)"',
'"password": "********"',
r'"(\w*password)":\s*".*?"',
r'"\1": "********"',
request_body,
flags=re.IGNORECASE,
)
entry = AuditLogEntry(