You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2dd9ba2
Browse filesBrowse the repository at this point in the historyBrowse files
fix(admin): record a logout in the audit history only when the request has a valid session (#1234)
## Description
`POST /admin/logout` is public by design: it has to clear the session
cookie whoever sends the request. `handleLogout` called the audit hook
(`void this.auditHook?.('logout', request)`) for every request, whether
or not the request carried a valid session, so each anonymous `POST
/admin/logout` wrote an `admin.logout` record, with the caller's
address, to the shared audit history in Redis. That history is
retention-limited, so someone who can reach the admin routes could post
to this endpoint in a loop, fill it with logouts that never happened,
and push the real administrator records (settings changes, logins) out
of it.
- the audit record is now written only when the request presents a valid
session, as a cookie or a Bearer token, and only after that session has
been revoked, which is where the code already was for a valid session;
- a request with no token, a token that was not signed by the relay, a
malformed one or an expired one still gets the cookie cleared and a 200
(the response stays idempotent, as it was), and writes nothing;
- a failed revocation still answers 500 and writes nothing, as before.
I did not add a separate record for the anonymous requests. The issue
mentions that as optional, and a record per anonymous request is the
very thing that filled the history.
## Related Issue
Partly addresses #1022 (finding F-040). That issue groups nine findings,
so this PR does not close it. F-013 is in #1231.
## Motivation and Context
The audit history is the record an operator reads after an incident. A
caller with no session should not be able to write to it.
## How Has This Been Tested?
## Screenshots (if appropriate):
## Types of changes
- [ ] Non-functional change (docs, style, minor refactor)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [x] I have added tests to cover my code changes.
- [x] I added a changeset, or this is docs-only and I added an empty
changeset.
- [x] All new and existing tests passed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Admin logout audit records are created only when that request revokes
a valid session, whether authenticated by cookie or Bearer token.
* Repeated or concurrent logout requests for an already-revoked session
do not create duplicate audit records. Requests without a valid session
still clear the cookie and return a successful response.
* If session revocation fails, logout returns an internal server error
and does not create an audit record.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
fix(admin): record a logout in the audit history only when it ends a session
6
+
7
+
`POST /admin/logout` is public, because it has to clear the session cookie whoever sends the request, and it wrote an `admin.logout` record to the audit history for every request, with or without a session. Anyone who could reach the admin routes could post to it repeatedly and fill the shared, size-limited audit history in Redis with logouts that never happened, pushing real administrator records out of it. The record is now written only by the logout that ends a session: a request with a valid session (as a cookie or a Bearer token) whose session had not been revoked yet. Revoking a session now tells the caller whether it was this call that did it, in one atomic step, so a copy of a token that was already logged out, or several logouts of the same session at once, write nothing more. Every such request still gets the cookie cleared and a 200.
0 commit comments