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

GeoJSON.get() and MVT.get() views have side effects #10664

Closed
jacobtylerwalls opened this issue Mar 7, 2024 · 0 comments · Fixed by #11491
Closed

GeoJSON.get() and MVT.get() views have side effects #10664

jacobtylerwalls opened this issue Mar 7, 2024 · 0 comments · Fixed by #11491

Comments

@jacobtylerwalls
Copy link
Member

Was reading up on CSRF today and recalled that HTTP GET requests shouldn't have side-effects (and for that reason aren't protected against CSRF).

We have a couple GET views that save UserProfile rows:

if hasattr(request.user, "userprofile") is not True:
models.UserProfile.objects.create(user=request.user)

if hasattr(request.user, "userprofile") is not True:
models.UserProfile.objects.create(user=request.user)

I can't see any attack vector here, so this is just a cleanup opportunity. We seem to be doing this merely for the sake of calling the UserProfile.viewable_nodegroups property. Creating a db row just for the sake of calling a function is something we can avoid: one, to be more RESTful, and two, to shave off a db query.

jacobtylerwalls added a commit that referenced this issue Sep 24, 2024
UserProfiles always exist since #8022.
1ca5c32 removed some cruft guards for missing profiles.
This removes the rest, which makes it more clear that these GETs
do not have side-effects (and thus CSRF attack vectors).
@jacobtylerwalls jacobtylerwalls linked a pull request Sep 24, 2024 that will close this issue
3 tasks
jacobtylerwalls added a commit that referenced this issue Oct 7, 2024
UserProfiles always exist since #8022.
1ca5c32 removed some cruft guards for missing profiles.
This removes the rest, which makes it more clear that these GETs
do not have side-effects (and thus CSRF attack vectors).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant