fix: prevent non-admin users changing another user's gitAccount#1093
Merged
JamieSlome merged 4 commits intofinos:mainfrom Jul 10, 2025
Merged
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
jescalada
approved these changes
Jul 9, 2025
That makes sense - shows the intent Co-authored-by: Juan Escalada <97265671+jescalada@users.noreply.github.com> Signed-off-by: Andy Pols <andy@pols.co.uk>
Ah sorry, I have different setting on my IDE. I will run `npm run format` in future. Thanks for tip Co-authored-by: Juan Escalada <97265671+jescalada@users.noreply.github.com> Signed-off-by: Andy Pols <andy@pols.co.uk>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1093 +/- ##
==========================================
+ Coverage 77.37% 77.41% +0.03%
==========================================
Files 55 55
Lines 2272 2276 +4
Branches 255 255
==========================================
+ Hits 1758 1762 +4
Misses 484 484
Partials 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A recent penetration test identified a security issue in the
/api/v1/auth/gitAccountendpoint:Root Cause
The API only checks that the requester is authenticated; it does not verify whether the user is updating their own account or has admin privileges.
Fix
This PR introduces a guard clause that ensures the requesting user is either:
This change brings the backend access control in line with the intended behaviour already enforced in the UI.
I’ve added a new
auth.test.js. I chose not to expand the existingtestLogin.test.jsbecause I wanted to test at a lower level, where I can directly assert that the database is updated as expected.While the current endpoint lives under /auth, updating a user's Git account may conceptually belong on the /user endpoint. However, this change is out of scope for this fix and has been deferred.