-
Notifications
You must be signed in to change notification settings - Fork 141
fix: prevent DOS when checking an unknown repo #1095
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍🏼
I looked around the mongo
handlers and it seems there aren't any other similar bugs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1095 +/- ##
=======================================
Coverage 82.78% 82.78%
=======================================
Files 66 66
Lines 2783 2783
Branches 332 332
=======================================
Hits 2304 2304
Misses 431 431
Partials 48 48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Kris West <[email protected]> Signed-off-by: Andy Pols <[email protected]>
@andypols you should be able to update this now against main. Please check its not re-introducing any functions that are not needed - we've done some consolidation of the duplicated code in the DB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls rebase and assess against current state of main
@finos/git-proxy-maintainers I've merged with latest changes and all is left following @kriswest checking is the test. Please can you review and merge is all ok. Thanks |
Summary
This PR fixes a potential denial-of-service (DoS) vulnerability:
When pushing to an unknown repository, the MongoDB implementation throws a TypeError due to attempting to access properties on a null object:
Root Cause
The file-based database implementation correctly checks for the existence of a repository before accessing its fields. However, the MongoDB implementation does not.
Specifically,
checkUserPushPermission
callsisUserPushAllowed
, which assumes the repository exists. If the repository is not found, accessing its properties throws a TypeError and stops the service.Fix
This PR addresses the issue by:
Adding a guard clause in the MongoDB implementation of
isUserPushAllowed
to handle missing repositories safely.Adds a unit test to verify behaviour when the repository does not exist.