Skip to content
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

Broadcast events for logging, email notifications, etc #526

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iandunn
Copy link
Member

@iandunn iandunn commented Feb 17, 2023

This is a rough sketch of a potential way to provide details on 2FA events, so that they can be logged (#459), emailed (#476), added to Stream (xwp/stream#1386), etc.

This takes a more generic approach than #462, and doesn't do any logging/etc itself, it just publishes the events so that other code can subscribe to them and do whatever is desired. It also allows for more granular events, rather than only failures in the providers.

I'd like to get some early feedback before adding anything else. What do y'all think of this approach?

Copy link
Member

@dd32 dd32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the approach myself, but as noted, I feel that exposing low-level protections of invalid input isn't useful, it only causes more logs of irrelevant details that hides actual important failures.

Comment on lines +1346 to +1347
* The only exception to that is a `WP_User` object, which will automatically be
* reduced to the `user_login`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The only exception to that is a `WP_User` object, which will automatically be
* reduced to the `user_login`.
* The only exception to that is a `WP_User` object in the 'user' key, which will
* automatically be reduced to the `user_login`.

@@ -886,6 +886,7 @@ public static function verify_login_nonce( $user_id, $nonce ) {
$login_nonce = get_user_meta( $user_id, self::USER_META_NONCE_KEY, true );

if ( ! $login_nonce || empty( $login_nonce['key'] ) || empty( $login_nonce['expiration'] ) ) {
self::broadcast( 'login_nonce_missing', compact( 'user_id' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that adding events for low-level validation is a bit over the top, yes, they could be used to pick up someone fuzzing the login forms, but they're not scenario's where a logger needs/should be aware of IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking it'd be useful to have a detailed audit trail when investigating a security incident, but at the same time I agree that we also don't wanna clutter everyday logs with standard pentesting.

Broadcasting low-level events doesn't mean they'll necessarily be used, though. #459 might only log high-level stuff by default, but log everything if a user changes a filter. I imagine #476 would hardcode a very short list of events that it chooses to send emails about.

The specifics will vary based on the caller, and the site, though. So IMO it's best to leave that choice up to them. What do you think?

I don't feel strongly, though. Broadcasting high-level stuff would be better than nothing, and we can always add more in the future if we change our minds.

class-two-factor-core.php Show resolved Hide resolved
class-two-factor-core.php Show resolved Hide resolved
providers/class-two-factor-totp.php Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants