-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Bug]: Wrong user name in log for system events #31861
Comments
cc @nextcloud/security |
Further information: |
I don't believe the user actually gained administrator privileges, but the log entries are wrong. |
@ruedigerkupper are your background jobs run per ajax, or cron? (check basic settings) |
cron |
I don't see it happening on 23 at least and am not aware of any other reports either. @come-nc maybe? |
Don't know if it's related. I see regular messages like this in the log:
Some of them have the user field set to "--" (which is probably the right value), others have the user-field set to the unprivileged user as described above. There is no conceivable pattern. |
Like e.g.
Looks like the same message, but user keeps changing between "--" and "[pupil]" randomly. |
Just a very wild guess: Do administrators usually get listed at the very front of the user list? Somehow, the alphabetically first user keeps dropping in for "administrator". |
More wild guessing: The problem could be in the LDAP interface. All of our ~1000 users get imported through LDAP. There are just two users in the local database: one test user and me, the admin. My admin user name starts with "ak", also at the front of the alphabet. |
URL is |
Most probably the regular cron job. |
Could it be related to: nextcloud/activity#784 |
Could have the same root cause (cron executing) but one is about admin_audit the other one is about activity. |
Looks similar, at least. I'll check our oc_activity table and see if it has similar messages. |
I am the creator of nextcloud/activity#784 and it appears that the wrong user, reported as doing the action he cannot do, is the first in alphabetical order on my nextcloud instance. |
We are observing and investigating similar behavior across multiple Nextcloud instances ran by distinct teams. Here are some details :
We have a couple of SQL queries to identify activity related to this bug, the most naive and simple being looking for activity across accounts over an object that never appears in any share-related activity. This is not perfect but it matches the most obvious case, where a user is notified of activity on their calendars and contacts while neither the calendar nor the addressbook was ever shared.
We will keep this issue updated as we keep investigating. We might drop the ball at some point since this seems fixed anyway, and simply advertise the possibly misattributed activity so our users do not panic while reviewing their logs. |
After investigating a bit more, and still relating to nextcloud/activity#784, we were able to confirme that at least 90% of the issue is due to logs or activitiy generated by cron jobs (still trying to link card updates to cron jobs, but I am confident we will) :
This would mean that somewhere in the course of Nextcloud 22, possibly around 22.2.6, something broke about determining the proper user for logging or generating activity when no user is actually logged in, a.k.a. during background jobs. We are going down the rabbit hole of system logs formatting, how the user is extracted from session at some point, and what happens if no session is available. Will keep this issue updated. |
Quick update: the issue is actually not fixed with Nextcloud 23, but upgrading to 23 broke cron jobs on our instance; re-enabling crons triggered the issue again. On the bright side: it is definitely related to assigning a wrong username during background jobs, and not any authentication or other nasty bug. |
Just as a follow-up from nextcloud/activity#784, the issue there is being fixed by avoiding the misattributed activity from being generated in the first place. This still does not fix this bug related to cron jobs in general, but is a great step forward for those experiencing this the nasty way: users complaining random people are deleting stuff from their calendar. |
We are having/seeing the same issue here. Our setup is also LDAP-centric and the user mentioned in the logs doesn't posess the necessary privileges. |
@ruedigerkupper Do you have the LDAP extension enabled for the CLI-Version of PHP as well? That was the culprit for us. Edit: Nevermind, this didn't solve the problem. |
|
We can confirm this issue with PHP 8.0, Nextcloud 24.0.4 and LDAP usage |
Hi, please update to at least 23.0.12 and report back if it fixes the issue. Thank you! |
This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions. |
Bug description
We deploy NC at a school. Last night our teachers received an email notification stating they had been added to the group "teachers" by a certain user. This user was a seventh-grade pupil. Naturally, pupils are unprivileged users who could never have initiated this event. However, the message that a seventh-grade pupil apparently had the power of adding users to the "teachers" group caused … considerable concern among teachers.
Analysis
Checking the nextcloud/auditing log revealed that the respective user is actually listed as the initiating user for all kinds of "system events", such as old file versions having been deleted. This is clearly wrong.
The wrong username is not randomly picked, it's the name of the alphabetically first known user (who happens to be that seventh-grade pupil in our case). So users who should receive the notifiaction "An administrator has added you to the group …" instead receive "[wrong-username] has added you to the group …".
I remember that notifications were correct in the past, this bug must have been introduced with one of the later updates to NC 22. We are unable to upgrade at this moment, so I cannot be sure if it is present in NC 23.
Steps to reproduce
unclear
Expected behavior
logs (and notifications) have "an administrator" for system events, not the name of the alphabetically first known user.
Installation method
Manual installation
Operating system
Linux (Ubuntu Server)
PHP engine version
PHP 7.4
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Updated from a minor version (ex. 22.2.3 to 22.2.4)
Are you using the Nextcloud Server Encryption module?
No.
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
One example entry:
Additional info
No response
The text was updated successfully, but these errors were encountered: