fix: prevent DOS when checking an unknown repo#1095
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
jescalada
left a comment
There was a problem hiding this comment.
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:
|
Co-authored-by: Kris West <kristopher.west@natwest.com> Signed-off-by: Andy Pols <andy@pols.co.uk>
|
@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. |
kriswest
left a comment
There was a problem hiding this comment.
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,
checkUserPushPermissioncallsisUserPushAllowed, 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
isUserPushAllowedto handle missing repositories safely.Adds a unit test to verify behaviour when the repository does not exist.