# maybeResendFromStore may wrongly submit a checkpoint transaction twice

Babylon vigilante relayer resends checkpoint tx on any GetRawTransaction error, not just 'not found', causing duplicate submission and blocking second tx resubmission.

- Payout: Audit contest
- Severity: medium
- Program: Babylon
- Found by: valuevalk
- Disclosed: 2024-12-09
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-babylon-judging/issues/23
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-babylon%3AM-3
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium technique:source-review vuln:business-logic

**Target:** vigilante relayer Go module
**Root cause:** maybeResendFromStore treats any error from GetRawTransaction as 'transaction not found', triggering resend even for network/RPC errors.
**Steps:**
1. `getRawTransaction` returns a non-'not found' error (e.g., network failure).
2. `sendTransaction(tx)` is called for `storedCkpt.Tx1`, but fails because tx already on chain.
3. Error propagates from `maybeResendFromStore` to `submitter.go`, causing `continue` and skipping `MaybeResubmitSecondCheckpointTx`.
4. `storedCkpt.Tx2` is never resubmitted if needed.
**How found:** Code review of `maybeResendFromStore` revealed it ignores the specific error type from `GetRawTransaction`, treating all errors as 'not found'.
**Exploitation:** Trigger a transient RPC error during checkpoint submission; the relayer attempts to resend an already-confirmed tx, fails, and aborts the submission loop, preventing resubmission of the second checkpoint tx.
**Insight:** When using error returns to gate retry logic, always distinguish 'not found' from transient errors; otherwise a network blip can cause duplicate submissions and block subsequent operations.

## Proof of concept (copied exactly from the original report)

**maybeResendFromStore resends on any getRawTransaction error**

```
maybeResendFunc := func(tx *wire.MsgTx) error {
		txID := tx.TxHash()
@>>	_, err = getRawTransaction(&txID) // todo(lazar): check for specific not found err
@>>	if err != nil {
@>>		_, err := sendTransaction(tx)
			if err != nil {
@>>			return err //we could end up here
			}
			// we know about this tx, but we needed to resend it from already constructed tx from db
			return nil
		}
		// tx exists in mempool and is known to us
		return nil
	}
@>>	if err := maybeResendFunc(storedCkpt.Tx1); err != nil {
		return false, err
	}
@>>	if err := maybeResendFunc(storedCkpt.Tx2); err != nil {
		return false, err
	}
```

