Unable to upload guardian shares on social backup
The upload-share endpoint only searches AccountState.backups for a backup ciphertext, but social backups are stored in AccountState.rec.social, so it returns 'Backup not found'. This prevents guardians from uploading their shares, making social recovery impossible.
montecristo Follow with 0xvd, ChainSentry and 12 others
Originally disclosed on Code4rena
Submitted by montecristo, also found by 0xvd, ChainSentry, count-sum, Egbe, eightzerofour, Goodman, JuggerNaut63, niffylord, RotiTelur, SanketKogekar, ScientificKatie420, ShredSecurity, Spektor, and touristS
contracts/src/http/endpoints/reconstruction/upload_share.rs #L48-L50
The upload-share endpoint fails to locate social backup ciphertexts because it only searches the AccountState.backups field while social backups are stored separately in AccountState.rec.social. This prevents guardians from uploading their shares, making social recovery impossible.
Finding description and impact
Social backup is a special recovery backup that stores the social recovery key ($\mathsf{msk\_ss\_social}$) and distributes its encryption to guardians.
The whole integration flow is demonstrated in SwafeContractTest::testNewRecoveryFlow, and is summarized as the following:
-
Account is updated on chain using the above account update string
At this point,
$\mathsf{BackupCipherText}$is stored inAccountState.rec.social, as we can confirm in the below code:635: pub fn update<R: Rng + CryptoRng>(&self, rng: &mut R) -> Result<AccountUpdate> { ... 703: let st = AccountStateV0 { 704: cnt, 705: backups: self.backups.clone(), 706: recover: self.recover.clone(), 707: pke: self.pke.encryption_key(), 708: sig: self.sig.verification_key(), 709: act, 710: rec: RecoveryStateV0 { 711: pke: None, 712: assoc, 713: // TODO: unfortunately we cannot generate this anew every time 714:@> social: self.recovery.social.clone(), 715: enc_msk, 716: }, 717: };
The test ends here, but we’ll have to upload guardian share to guardian nodes for guardian distribution. Otherwise, guardian shares are not available on nodes when recovery request is received.
If we take a look at upload-share handler:
File: contracts/src/http/endpoints/reconstruction/upload_share.rs
33: pub fn handler(
34: mut ctx: OffChainContext,
35: state: ContractState,
36: request: HttpRequestData,
37: _params: Params,
38: ) -> Result<HttpResponseData, ContractError> {
39: let request: Request = deserialize_request_body(&request)?;
40:
41: let backup_id = request.backup_id.0;
42: let account_id = request.account_id.0;
43:
44: let account = state
45: .get_account(account_id)
46: .ok_or_else(|| ServerError::NotFound("Account not found".to_string()))?;
47:
48:@> let backup: &BackupCiphertext = account.recover_id(backup_id).ok_or_else(|| {
49: ServerError::NotFound(format!("Backup not found for backup_id: {}", backup_id))
50: })?;
We need to provide account_id, backup_id to identify $\mathsf{BackupCipherText}$ stored in step 3, and later match it to our guardian share.
However, since account.recover_id finds backups only from AccountState.backups(trace1, trace2, trace3), upload-share endpoint will revert with “Backup not found” error.
Impact
- Unable to upload guardian shares generated for social backup
- Guardians cannot recover
$\mathsf{msk\_ss\_social}$because they do not have corresponding guardian shares in their nodes
Recommended mitigation steps
Look backup in AccountState.backups and AccountState.rec.social.
self.backups.iter().collect()→self.recover.iter().chain(once(&self.rec.social)).collect()
Status: Mitigation confirmed. Full details in reports from montecristo, niffylord, and DCENT09.
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 upload-share handler uses a lookup function that only checks AccountState.backups, while social backup ciphertexts are stored in AccountState.rec.social.
Impact
Guardians cannot upload their shares, so they cannot recover the social master key and social recovery is impossible.
What the attacker needed
A social backup configured; guardian shares generated; recovery initiated
The fix
The lookup should search both AccountState.backups and AccountState.rec.social; the project mitigated it accordingly and the mitigation was confirmed.
How it was found
- Set up a social backup so that the backup ciphertext is stored in AccountState.rec.social.
- Initiate recovery and generate guardian shares.
- Call the upload-share endpoint with the account_id and backup_id.
- The endpoint fails to find the backup and returns 'Backup not found'.
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 social backup lets a group of trusted people (guardians) help recover an account. Each guardian must upload a piece of the recovery key to their node, but the upload endpoint looks in the wrong place for the backup data, so it always says 'not found'. As a result, the recovery pieces never reach the nodes and the account cannot be recovered.
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.