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

🐛 Fix: Ensure backend service provides user id when updating an event #214

Conversation

that-one-arab
Copy link
Contributor

@that-one-arab that-one-arab commented Jan 6, 2025

Should fix issue

After attempting to reproduce the issue and following the trail, I realized the error mentioned in the issue is occurring whenever an event is unlinked from a user (a user property, that represents the user id, does not exist in the mongodb event document)

the user property is unlinked whenever we overwrite the event without a user property.

This happens because we rely on frontend request body event payload containing a user property, but as explained below there are instances when its not provided.

Update Event API relies on providing event id and user id to MongoDB API in order to update an event. The frontend provides the event object which contains the event id and the user id.

The issues are:

  • When editing the event, the user id inside the request body event payload is not provided sometimes (no 100% reproduce rate but happens often enough)
  • We should not depend on the frontend to provide a user id, backend service should overwrite it based on the authenticated user. This ensures that the software does not have a security risk

Interestingly I could not reproduce this behaviour on production, I reproduced it only on latest upstream changes.

As for why the frontend is not providing the user id sometimes, I am still investigating this.

Even if this PR solves the issue, we should still investigate why this unexpected behaviour is occurring as it could be a cause for larger issues in the future

Update Event API relies on providing event id and user id to MongoDB API in order to update an event.
The frontend provides the event object which contains the event id and the user id.

The issues are:
- When editing the event, the user id inside the request body event payload is not provided sometimes (no 100% reproduce rate but happens often enough)
- We should not depend on the frontend to provide a user id, backend service should overwrite it based on the authenticated user. This ensures that the software does not have a security risk

Interestingly I could not reproduce this behaviour on production, I reproduced it only on latest upstream changes.

As for why the frontend is not providing the user id sometimes, I am still investigating this. This commit serves as a solution to close this security gap and close the linked issue I believe.

Even if this commit solves the issue, we should still investigate why this unexpected behaviour is occurring as it could be a cause for larger issues in the future
@tyler-dane tyler-dane merged commit b79eba0 into SwitchbackTech:main Jan 7, 2025
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.

Site is refreshing after resizing or dragging event
2 participants