Repository navigation
Conversation
Author
|
@LabsCrypt both failing checks are green now. Before: Root cause & fix Head |
This branch has not been deployed
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.
Overview
contestDefaultinbackend/src/controllers/loanController.tsonly checked that aLoanDefaultedevent existed for the loan; it never verified that the authenticated caller was that loan's borrower. Any authenticated user could therefore contest someone else's default, and when an admin resolved the dispute the system would attribute it to the attacker (a Broken Object Level Authorization / IDOR defect).Related Issue
Closes #1802
Changes
[MODIFY]
backend/src/controllers/loanController.tsaddress(the loan's borrower) instead of onlyloan_id.address !== req.user.publicKeythe handler throwsAppError.forbidden(...)— HTTP 403.requireLoanOwner; this controller-level check makes the handler safe wherever it is mounted (defence in depth).[MODIFY]
backend/src/__tests__/loanDispute.test.tsLoanDefaultedlookup returns the caller's own address.LoanDefaultedevent owned by another borrower now yields HTTP 403.[MODIFY]
backend/src/__tests__/integration/loanDisputeFlow.test.tsVerification Results
borrower = req.user.publicKeyis assertedloanBorrower !== borrowerguard added incontestDefaultAppError.forbiddenthrown before any INSERTaddressread from theLoanDefaultedcontract_eventsrow