BaseAuth.recoverSapientSignature returns a constant instead of signer image hash, breaking sapient signer flows
BaseAuth.recoverSapientSignature returns a hardcoded constant instead of the signer's image hash, contrary to the ISapient interface. When a Sequence wallet is used as a sapient signer, the wrong value is fed into the Merkle leaf calculation, so the reconstructed wallet image hash does not match and signature validation fails, making those configurations unusable.
Submitted by Agontuk, also found by 0xnija, axelot, francoHacker, and Nora
Finding Description
BaseAuth.recoverSapientSignature() violates the ISapient interface contract by returning a constant value instead of the signer’s imageHash. The ISapient interface specifies that sapient signers “return their own imageHash” for the provided payload and signature via recoverSapientSignature(...). However, the implementation in BaseAuth.recoverSapientSignature() unconditionally returns bytes32(uint256(1)).
Walkthrough and root cause:
-
BaseAuth.recoverSapientSignature():- Mutates
_payload.parentWalletsby appendingmsg.sender. - Calls
signatureValidation(...)to validate the signature. - On success, it returns
bytes32(uint256(1))rather than the actual sapient signer image hash.
- Mutates
-
ISapient.recoverSapientSignature()contract:recoverSapientSignaturecommunicates that the function must return the correct signer image hash.
-
Downstream consumer:
BaseSig.recoverBranch()consumes the return value fromISapient(addr).recoverSapientSignature(...)as a real image hash to construct the Merkle leaf via_leafForSapient(...).- When
BaseAuth.recoverSapientSignature()returns0x...01,BaseSigincorporates this incorrect “image hash” into the merkle calculation, corrupting the final image hash.
Highest-impact scenario: If a Sequence wallet is configured to use another Sequence wallet (or itself) as a sapient signer, any signature path that relies on BaseAuth.recoverSapientSignature() will produce an incorrect sapient leaf (imageHash = 0x...01), causing the overall wallet image hash to mismatch the expected configuration. This results in signature validation failure (denial of service) for those flows, making such configurations unusable.
Impact
Medium. The bug violates a public interface contract and deterministically breaks configurations where a Sequence wallet is used as a sapient signer. This leads to denial of service / mis-integration (not a direct privilege escalation), but it renders a supported path unusable. It undermines the correctness of merkle image reconstruction, a core invariant of the system.
Likelihood
Medium. Sapient signers are a first-class feature and used in complex configs. Any integration using BaseAuth as a sapient signer will consistently hit this bug. The issue triggers deterministically whenever recoverSapientSignature() is invoked and the signature validates, because the function always returns the constant.
Recommended mitigation steps
Return the actual signer image hash from BaseAuth.recoverSapientSignature() to conform to ISapient and maintain merkle image correctness.
Two straightforward approaches:
- Extend
signatureValidation(...)to also return the derivedimageHash(it already computes it in the dynamic branch viaBaseSig.recover(...)) and return that fromrecoverSapientSignature(). - Or directly call
BaseSig.recover(_payload, _signature, false, address(0))insiderecoverSapientSignature()and return theimageHash.
Proof of Concept
Add PoC test into test/modules/BaseSig.t.sol (BaseSigTest), import BaseAuth.sol, Add a helper contract MinimalSapient
+ import { BaseAuth } from "../../src/modules/auth/BaseAuth.sol";
Helper contract:
contract MinimalSapient is BaseAuth {
function _updateImageHash(bytes32) internal override {}
function _isValidImage(bytes32) internal view override returns (bool) { return true; }
}
PoC test:
function test_BaseAuth_recoverSapientSignature_ReturnsConstant() external {
MinimalSapient sap = new MinimalSapient();
Payload.Decoded memory payload;
// Minimal dynamic signature:
// - signatureFlag = 0x00 (no chain id, no checkpoint bytes, 1-byte threshold)
// - threshold byte = 0x00 (threshold = 0)
// - no branch content -> weight defaults to 0, passes since threshold=0
bytes memory innerSig = hex"0000";
bytes32 ret = sap.recoverSapientSignature(payload, innerSig);
assertEq(ret, bytes32(uint256(1)));
}
Before running the test, run a server using the following command:
cd ../sequence.js
pnpm build:packages
pnpm dev:server
Then run the test from repo root:
forge test --mt test_BaseAuth_recoverSapientSignature_ReturnsConstant -vvv
- The new helper contract
MinimalSapientinheritsBaseAuth, implements_updateImageHash()and_isValidImage()trivially to allow calls. - The PoC test deploys
MinimalSapient, crafts a minimal valid dynamic base-auth signature withthreshold = 0and no branch content so it passessignatureValidation(), then callsrecoverSapientSignature(...). - Asserts that the function returns
bytes32(uint256(1)), demonstrating the incorrect constant return instead of a real image hash.
Test result: Test passes, confirming the function returns a constant rather than a true image hash.
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
The implementation returns a hardcoded constant rather than the actual signer image hash, violating the ISapient interface contract.
Impact
Configurations where a Sequence wallet is used as a sapient signer deterministically fail signature validation, causing a denial of service for that supported path; the report states this is not a direct privilege escalation.
What the attacker needed
Wallet configured with a sapient signer; signature path uses recoverSapientSignature
The fix
The function should return the real signer image hash, either by having signatureValidation also return the derived image hash or by calling BaseSig.recover directly and returning its image hash.
How it was found
- Deploy a minimal contract inheriting BaseAuth with trivial image hash and validity overrides.
- Craft a minimal valid dynamic base-auth signature with threshold zero and no branch content.
- Call recoverSapientSignature with that payload and signature.
- Observe that the returned value is the constant one rather than a real image hash.
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 wallet can be set up so that another wallet acts as one of its signers. To check such a signature, the code asks the signer wallet for a short fingerprint of itself, called an image hash, and uses it to rebuild the wallet's overall fingerprint. Here the signer wallet always answers with the same fixed number instead of its real fingerprint, so the rebuilt fingerprint never matches and the signature is rejected.
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.