nlrType type is not signed by strategist, which could allow fraudulent behavior as new types are added
The strategist signs a merkle root of allowed strategies but does not include the lien type (nlrType) in the signed data. If two strategy types have overlapping struct schemas, a borrower could submit a lien with one type but have it validated against a different strategy, bypassing the strategist's intended requirements.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/72
Found by
obront
Summary
The strategist signs the merkle root, their nonce, and the deadline of all strategies to ensure that new borrowers meet their criteria. However, the lien type (nlrType) is not signed. Currently, the structs for the different types are unique, so there is no ability to borrow one type as another, but if struct schemas of different types overlap in the future, this will open the door for exploits.
Vulnerability Detail
When a new lien is requested, the borrower submits a Lien Request, which is filled with the parameters at which they would like to borrow. This is kept honest and aligned with the lenders intent because the merkle root, strategist nonce, and deadline are all signed by the strategist.
Because the merkle root is signed, the borrower must submit lien parameters (nlrDetails) that align with one of the strategies that the strategist has chosen to allow (represented as leaves in the merkle tree). The schemas of these signed structs differ depending on the validator being used, which is defined in the nlrType parameter.
Currently, each of the validators has a unique schema for their struct. However, if there is an overlap in the schema of the Details struct of multiple validators, where the different parameters represent different values, it opens the door to having a fraudulent lien accepted.
Here's an example of how this might work:
- Type A has a Details struct with the shape { uint8 version, bool requirementX, IAstariaRouter.LienDetails lien }.
- The lender includes in their merkle tree the following { version: 1, requirementX: true, lien: { ... maxAmount: 1 ether ... }
- Type B has a Details struct with the shape { uint8 version, bool requirementY, IAstariaRouter.LienDetails lien }
- The lender includes in their merkle tree the following strategy: { version: 1, requirementY: true, lien { ... maxAmount: 1 ether ... }
- The lender signs a merkle root including both of these strategies
- A borrower who meets requirementX but not requirementY could submit
lienDetailswithnlrType = Type Aand send the validation to the wrong strategy validator, thus bypassing the expected checks
Impact
As more strategy types are added, conflicts in struct schemas could open the door to fraudulent behavior.
Code Snippet
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/AstariaRouter.sol#L222-L232
Current Details struct schemas:
Tool used
Manual Review
Recommendation
Include the nlrType in the data signed by the strategist. The easiest way to do this would be to pack it in with each leaf when assembling the leaves that will create the merkle tree:
function assembleLeaf(ICollectionValidator.Details memory details, address nlrType)
public
pure
returns (bytes memory)
{
return abi.encode(details, nlrType);
}
function validateAndParse... {
...
leaf = keccak256(assembleLeaf(cd, params.nlrType));
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the nlrType parameter is not included in the signed merkle leaf, so the strategist's approval does not bind the loan type to the specific validation logic.
Impact
As more strategy types are added, conflicts in struct schemas could open the door to fraudulent behavior.
What the attacker needed
Two strategy types with overlapping struct schemas; lender signs a merkle root including both strategies; borrower meets one requirement but not the other
The fix
Include the nlrType in the data signed by the strategist, for example by packing it into each leaf when assembling the merkle tree.
How it was found
- Lender includes two strategies with overlapping struct schemas in the merkle tree and signs the root.
- Borrower meets requirementX but not requirementY.
- Borrower submits lienDetails with nlrType = Type A but sends validation to the wrong strategy validator.
- The validation passes because the struct schemas overlap, bypassing the expected checks.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A strategist approves certain loan conditions by signing a list (merkle root). The type of loan is not part of that signed list. If two loan types have similar data layouts, a borrower could pretend to use one type but actually get checked against another, potentially getting a loan they shouldn't.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.