-
Notifications
You must be signed in to change notification settings - Fork 522
Add debug log when HMAC incorrect
#18474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
4be4ea0
7feedb9
944800d
8e45c6f
95a084e
e079104
a0ada44
1aac00f
7e5ef26
fea75ae
7f4a06b
6b13fbd
b44e5d7
57da8ba
34c101b
5735d66
3cf7dbf
b1e96ae
19aeeee
b8bc1e3
3707374
5b1020c
78e29dc
c00a3e7
5716db6
e2e0e0c
b15bf3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add debug logging for HMAC digest verification failures when using the admin API to register users. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,14 @@ | |
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| user_registration_debug_logger = logging.getLogger( | ||
| "synapse.rest.admin.users.registration_debug" | ||
|
anoadragon453 marked this conversation as resolved.
|
||
| ) | ||
| """ | ||
| A logger for debugging the user registration process. This is separate from the main | ||
| logger as it logs sensitive information such as passwords and `registration_shared_secret`. | ||
| """ | ||
|
|
||
|
|
||
| class UsersRestServletV2(RestServlet): | ||
| PATTERNS = admin_patterns("/users$", "v2") | ||
|
|
@@ -633,6 +641,13 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: | |
| want_mac = want_mac_builder.hexdigest() | ||
|
|
||
| if not hmac.compare_digest(want_mac.encode("ascii"), got_mac.encode("ascii")): | ||
| user_registration_debug_logger.debug( | ||
| "UserRegisterServlet: Incorrect HMAC digest: actual=%s, expected=%s, registration_shared_secret=%s, body=%s", | ||
| got_mac, | ||
| want_mac, | ||
| self.hs.config.registration.registration_shared_secret, | ||
| body, | ||
| ) | ||
|
MadLittleMods marked this conversation as resolved.
Outdated
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an update on the root cause on why we were seeing of Basically, we're running into the default Synapse behavior (of creating the file and secret if it doesn't exist) masking our deployment race condition where we would start up Synapse before the
|
||
| raise SynapseError(HTTPStatus.FORBIDDEN, "HMAC incorrect") | ||
|
|
||
| should_issue_refresh_token = body.get("refresh_token", False) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.