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

[Bug]: Wordpress integration records unauthenticated users as usr.id 0 #2423

Closed
JamesHarrison opened this issue Dec 14, 2023 · 1 comment · Fixed by #2424
Closed

[Bug]: Wordpress integration records unauthenticated users as usr.id 0 #2423

JamesHarrison opened this issue Dec 14, 2023 · 1 comment · Fixed by #2424
Assignees
Labels
🐛 bug Something isn't working

Comments

@JamesHarrison
Copy link

Bug report

For traces collected from a Wordpress environment with the new Wordpress integration enabled, unauthenticated users are recorded as usr.id 0.

This bit of code specifically seems to be the issue - wp_get_current_user() will return a user in all cases, but the user ID is 0 if the user's not logged in. This should check to see if the user ID is not 0 and only call set_user if so:

https://github.com/DataDog/dd-trace-php/blob/master/src/Integrations/Integrations/WordPress/V2/WordPressIntegrationLoader.php#L283

This behaviour by default can lead to exciting but unexpected problems with ASM - specifically, that any rules which block users will block all unauthenticated users the second an unauthenticated user triggers such a rule.

If a user is not authenticated, usr.id should not be set.

PHP version

8.2.7

Tracer or profiler version

0.95.0

Installed extensions

No response

Output of phpinfo()

No response

Upgrading from

No response

@JamesHarrison JamesHarrison added the 🐛 bug Something isn't working label Dec 14, 2023
@PROFeNoM PROFeNoM self-assigned this Dec 14, 2023
@PROFeNoM
Copy link
Contributor

Thank you for bringing up the issue and providing a detailed description of the situation! I have submitted PR #2424 with your suggested fix 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants