<!-- canonical: https://0xsimao.com/findings/maple-finance-syrup-router-signatures-fully-compatible-eip712 -->

# Signatures in the SyrupRouter are not fully compatible with EIP712

Low/Info · Three Sigma · Permissionless lending · 21st May 2024

Finding 3S-Sy-N01 of the Maple Syrup Router security review.

- Protocol: https://maple.finance/
- Report: /reports/maple-syrup-router
- Source: https://github.com/0xsimao/audits/blob/main/Three%20Sigma/2024-05-21-maple-finance-syrup-router.pdf

---

### Description

EIP712 [defines](https://eips.ethereum.org/EIPS/eip-712#eth_signtypeddata) the digest as keccak256("\x19\x01" ‖ domainSeparator ‖
hashStruct(message)).
domainSeparator [is](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol#L88-L90) keccak256(abi.encode(TYPE_HASH, _hashedName,
_hashedVersion, block.chainid, address([this](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol#L37-L38)))).
TYPE_HASH [is](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MessageHashUtils.sol#L76) keccak256("EIP712Domain(string name,string version,uint256
chainId,address verifyingContract)");
hashStruct(message)) is dependent on the application, ERC20Permit is a good [example](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Permit.sol). In
this case it would be something like:
​
AUTH_TYPEHASH = keccak256("Auth(address lender,uint256 nonce,uint256
bitmap,uint256 deadline)");​
bytes32 structHash = keccak256(abi.encode(AUTH_TYPEHASH, msg.sender,
nonces[msg.sender]++, bitmap, deadline);​

And the final digest is keccak256(abi.encodePacked("\x19\x01", domainSeparator,
structHash).

### Recommendation

To be strictly compliant, the structure above should be applied. However, signatures are
signed by Maple so it has no impact on users.

### Status

Acknowledged

Disclosed by 0xSimao (https://0xsimao.com/).

---

Related findings:

- [Incorrect encoding of bytes for EIP712 digest in `TitleGraph` causes signatures generated by common EIP712 tools to be unusable](https://0xsimao.com/findings/titles-publishing-protocol-encoding-digest-tools-unusable): TITLES Publishing Protocol
- [`SyrupBitcoinRouter::processRedemptions()` could be optimized by batching transfers together](https://0xsimao.com/findings/maple-finance-iii-process-batching-transfers-together): Maple Withdrawal Queue
- [`SyrupBitcoinRouter::setAssetController()` could always allow the asset controller to be set to 0](https://0xsimao.com/findings/maple-finance-iii-syrup-bitcoin-asset-controller): Maple Withdrawal Queue
- [`SyrupBitcoinRouter::requestRedeem()` could also check if the asset picked to redeem has liquidity](https://0xsimao.com/findings/maple-finance-iii-syrup-bitcoin-redeem-picked): Maple Withdrawal Queue
