Commit 49ea72e
authored
fix: close sponsored claim+burn bond extraction vulnerability (#107)
* fix: refund ownership bond to original payer, not UUID owner
Track who paid the ownership bond via uuidOwnershipBondPayer mapping.
For self-funded claims the payer is msg.sender; for sponsored claims
it is the treasury. On burn the bond refunds to the recorded payer,
closing a vulnerability where a whitelisted user could claim+burn
sponsored UUIDs to extract treasury funds to their own wallet.
Backward compatible: pre-upgrade tokens (bondPayer==address(0)) fall
back to uuidOwner. On token transfer, bondPayer follows only if the
previous owner was the payer (self-funded); sponsored bonds stay with
the treasury.
Storage: adds 1 mapping before __gap (reduced from 50 to 49 slots).
* feat: add per-user NODL bond allowance to BondTreasuryPaymaster
Defense-in-depth for the sponsored claim exploit: each whitelisted
user now has a token-denominated allowance that is decremented on
every consumeSponsoredBond call. When the allowance hits zero the
user cannot consume any more sponsored bonds regardless of the global
periodic quota.
Amount-based (not claim-count-based) so the cap stays correct even if
baseBond parameters change. Non-periodic: whitelist admin can top up
via increaseUserBondAllowance or overwrite via setUserBondAllowance.
New storage:
mapping(address => uint256) public userBondAllowance
New functions (WHITELIST_ADMIN_ROLE):
setUserBondAllowance(address user, uint256 allowance)
increaseUserBondAllowance(address user, uint256 amount)
New error: UserBondAllowanceExceeded
New events: UserBondAllowanceSet, UserBondAllowanceIncreased
* chore: fix spellcheck and formatting issues1 parent 153c20d commit 49ea72e
4 files changed
Lines changed: 584 additions & 164 deletions
File tree
- src
- paymasters
- swarms
- test
- paymasters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
| |||
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
63 | | - | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
70 | 83 | | |
71 | 84 | | |
72 | 85 | | |
73 | 86 | | |
74 | 87 | | |
75 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
76 | 104 | | |
77 | 105 | | |
78 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
201 | 212 | | |
202 | 213 | | |
203 | 214 | | |
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
207 | 218 | | |
208 | | - | |
| 219 | + | |
209 | 220 | | |
210 | 221 | | |
211 | 222 | | |
| |||
433 | 444 | | |
434 | 445 | | |
435 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
436 | 451 | | |
437 | 452 | | |
438 | 453 | | |
439 | | - | |
| 454 | + | |
440 | 455 | | |
441 | 456 | | |
442 | 457 | | |
| |||
486 | 501 | | |
487 | 502 | | |
488 | 503 | | |
| 504 | + | |
489 | 505 | | |
490 | 506 | | |
491 | 507 | | |
| |||
525 | 541 | | |
526 | 542 | | |
527 | 543 | | |
| 544 | + | |
528 | 545 | | |
529 | 546 | | |
530 | 547 | | |
| |||
660 | 677 | | |
661 | 678 | | |
662 | 679 | | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
| 680 | + | |
668 | 681 | | |
669 | 682 | | |
670 | 683 | | |
| |||
761 | 774 | | |
762 | 775 | | |
763 | 776 | | |
| 777 | + | |
764 | 778 | | |
765 | 779 | | |
766 | 780 | | |
| |||
832 | 846 | | |
833 | 847 | | |
834 | 848 | | |
| 849 | + | |
835 | 850 | | |
836 | 851 | | |
837 | 852 | | |
| |||
975 | 990 | | |
976 | 991 | | |
977 | 992 | | |
978 | | - | |
979 | | - | |
| 993 | + | |
980 | 994 | | |
981 | 995 | | |
982 | 996 | | |
| |||
1114 | 1128 | | |
1115 | 1129 | | |
1116 | 1130 | | |
1117 | | - | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1118 | 1138 | | |
1119 | 1139 | | |
1120 | 1140 | | |
| |||
0 commit comments