solidity-argus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/AGENTS.md +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +249 -0
  4. package/package.json +43 -0
  5. package/skills/INVENTORY.md +79 -0
  6. package/skills/README.md +56 -0
  7. package/skills/checklists/cyfrin-best-practices-runtime/SKILL.md +424 -0
  8. package/skills/checklists/cyfrin-best-practices-upgrades/SKILL.md +157 -0
  9. package/skills/checklists/cyfrin-defi-core/SKILL.md +373 -0
  10. package/skills/checklists/cyfrin-defi-integrations/SKILL.md +412 -0
  11. package/skills/checklists/cyfrin-gas/SKILL.md +55 -0
  12. package/skills/checklists/general-audit/SKILL.md +433 -0
  13. package/skills/methodology/audit-workflow/SKILL.md +129 -0
  14. package/skills/methodology/report-template/SKILL.md +190 -0
  15. package/skills/methodology/severity-classification/SKILL.md +179 -0
  16. package/skills/protocol-patterns/amm-dex/SKILL.md +229 -0
  17. package/skills/protocol-patterns/bridges-cross-chain/SKILL.md +317 -0
  18. package/skills/protocol-patterns/dao-governance/SKILL.md +281 -0
  19. package/skills/protocol-patterns/lending-borrowing/SKILL.md +221 -0
  20. package/skills/protocol-patterns/staking-vesting/SKILL.md +247 -0
  21. package/skills/references/exploit-reference/SKILL.md +259 -0
  22. package/skills/references/smartbugs-examples/SKILL.md +296 -0
  23. package/skills/vulnerability-patterns/access-control/SKILL.md +298 -0
  24. package/skills/vulnerability-patterns/arbitrary-storage-location/SKILL.md +59 -0
  25. package/skills/vulnerability-patterns/assert-violation/SKILL.md +59 -0
  26. package/skills/vulnerability-patterns/asserting-contract-from-code-size/SKILL.md +61 -0
  27. package/skills/vulnerability-patterns/authorization-txorigin/SKILL.md +55 -0
  28. package/skills/vulnerability-patterns/default-visibility/SKILL.md +62 -0
  29. package/skills/vulnerability-patterns/delegatecall-untrusted-callee/SKILL.md +60 -0
  30. package/skills/vulnerability-patterns/dos-gas-limit/SKILL.md +59 -0
  31. package/skills/vulnerability-patterns/dos-revert/SKILL.md +72 -0
  32. package/skills/vulnerability-patterns/flash-loan-attacks/SKILL.md +249 -0
  33. package/skills/vulnerability-patterns/floating-pragma/SKILL.md +51 -0
  34. package/skills/vulnerability-patterns/hash-collision/SKILL.md +52 -0
  35. package/skills/vulnerability-patterns/inadherence-to-standards/SKILL.md +61 -0
  36. package/skills/vulnerability-patterns/incorrect-constructor/SKILL.md +60 -0
  37. package/skills/vulnerability-patterns/incorrect-inheritance-order/SKILL.md +59 -0
  38. package/skills/vulnerability-patterns/insufficient-gas-griefing/SKILL.md +61 -0
  39. package/skills/vulnerability-patterns/lack-of-precision/SKILL.md +61 -0
  40. package/skills/vulnerability-patterns/logic-errors/SKILL.md +333 -0
  41. package/skills/vulnerability-patterns/missing-protection-signature-replay/SKILL.md +60 -0
  42. package/skills/vulnerability-patterns/msgvalue-loop/SKILL.md +66 -0
  43. package/skills/vulnerability-patterns/off-by-one/SKILL.md +67 -0
  44. package/skills/vulnerability-patterns/oracle-manipulation/SKILL.md +252 -0
  45. package/skills/vulnerability-patterns/outdated-compiler-version/SKILL.md +65 -0
  46. package/skills/vulnerability-patterns/overflow-underflow/SKILL.md +61 -0
  47. package/skills/vulnerability-patterns/reentrancy/SKILL.md +266 -0
  48. package/skills/vulnerability-patterns/shadowing-state-variables/SKILL.md +72 -0
  49. package/skills/vulnerability-patterns/signature-malleability/SKILL.md +59 -0
  50. package/skills/vulnerability-patterns/unbounded-return-data/SKILL.md +63 -0
  51. package/skills/vulnerability-patterns/unchecked-return-values/SKILL.md +52 -0
  52. package/skills/vulnerability-patterns/unencrypted-private-data-on-chain/SKILL.md +65 -0
  53. package/skills/vulnerability-patterns/unexpected-ecrecover-null-address/SKILL.md +61 -0
  54. package/skills/vulnerability-patterns/uninitialized-storage-pointer/SKILL.md +63 -0
  55. package/skills/vulnerability-patterns/unsafe-low-level-call/SKILL.md +56 -0
  56. package/skills/vulnerability-patterns/unsecure-signatures/SKILL.md +80 -0
  57. package/skills/vulnerability-patterns/unsupported-opcodes/SKILL.md +69 -0
  58. package/skills/vulnerability-patterns/unused-variables/SKILL.md +70 -0
  59. package/skills/vulnerability-patterns/use-of-deprecated-functions/SKILL.md +81 -0
  60. package/skills/vulnerability-patterns/weak-sources-randomness/SKILL.md +77 -0
  61. package/skills/vulnerability-patterns/weird-tokens/SKILL.md +294 -0
  62. package/src/agents/argus-prompt.ts +407 -0
  63. package/src/agents/pythia-prompt.ts +134 -0
  64. package/src/agents/scribe-prompt.ts +87 -0
  65. package/src/agents/sentinel-prompt.ts +133 -0
  66. package/src/cli/cli-program.ts +67 -0
  67. package/src/cli/commands/doctor.ts +83 -0
  68. package/src/cli/commands/init.ts +46 -0
  69. package/src/cli/commands/install.ts +55 -0
  70. package/src/cli/index.ts +13 -0
  71. package/src/cli/tui-prompts.ts +75 -0
  72. package/src/cli/types.ts +9 -0
  73. package/src/config/index.ts +3 -0
  74. package/src/config/loader.ts +36 -0
  75. package/src/config/schema.ts +82 -0
  76. package/src/config/types.ts +4 -0
  77. package/src/constants/defaults.ts +6 -0
  78. package/src/create-hooks.ts +84 -0
  79. package/src/create-managers.ts +26 -0
  80. package/src/create-tools.ts +30 -0
  81. package/src/features/audit-enforcer/audit-enforcer.ts +34 -0
  82. package/src/features/audit-enforcer/index.ts +1 -0
  83. package/src/features/background-agent/background-manager.ts +200 -0
  84. package/src/features/background-agent/index.ts +1 -0
  85. package/src/features/context-monitor/context-monitor.ts +48 -0
  86. package/src/features/context-monitor/index.ts +4 -0
  87. package/src/features/context-monitor/tool-output-truncator.ts +17 -0
  88. package/src/features/error-recovery/index.ts +2 -0
  89. package/src/features/error-recovery/session-recovery.ts +27 -0
  90. package/src/features/error-recovery/tool-error-recovery.ts +35 -0
  91. package/src/features/index.ts +5 -0
  92. package/src/features/persistent-state/audit-state-manager.ts +121 -0
  93. package/src/features/persistent-state/index.ts +1 -0
  94. package/src/hooks/compaction-hook.ts +50 -0
  95. package/src/hooks/config-handler.ts +116 -0
  96. package/src/hooks/event-hook-v2.ts +93 -0
  97. package/src/hooks/event-hook.ts +74 -0
  98. package/src/hooks/hook-system.ts +9 -0
  99. package/src/hooks/index.ts +5 -0
  100. package/src/hooks/knowledge-sync-hook.ts +57 -0
  101. package/src/hooks/safe-create-hook.ts +15 -0
  102. package/src/hooks/system-prompt-hook.ts +126 -0
  103. package/src/hooks/tool-tracking-hook.ts +234 -0
  104. package/src/hooks/types.ts +16 -0
  105. package/src/index.ts +36 -0
  106. package/src/knowledge/scvd-client.ts +242 -0
  107. package/src/knowledge/scvd-index.ts +183 -0
  108. package/src/knowledge/scvd-sync.ts +85 -0
  109. package/src/managers/index.ts +1 -0
  110. package/src/managers/types.ts +85 -0
  111. package/src/plugin-interface.ts +38 -0
  112. package/src/shared/binary-utils.ts +63 -0
  113. package/src/shared/deep-merge.ts +71 -0
  114. package/src/shared/file-utils.ts +56 -0
  115. package/src/shared/index.ts +5 -0
  116. package/src/shared/jsonc-parser.ts +39 -0
  117. package/src/shared/logger.ts +36 -0
  118. package/src/state/audit-state.ts +27 -0
  119. package/src/state/finding-store.ts +126 -0
  120. package/src/state/plugin-state.ts +14 -0
  121. package/src/state/types.ts +61 -0
  122. package/src/tools/contract-analyzer-tool.ts +184 -0
  123. package/src/tools/forge-fuzz-tool.ts +311 -0
  124. package/src/tools/forge-test-tool.ts +397 -0
  125. package/src/tools/pattern-checker-tool.ts +337 -0
  126. package/src/tools/report-generator-tool.ts +308 -0
  127. package/src/tools/slither-tool.ts +465 -0
  128. package/src/tools/solodit-search-tool.ts +131 -0
  129. package/src/tools/sync-knowledge-tool.ts +116 -0
  130. package/src/utils/project-detector.ts +133 -0
  131. package/src/utils/solidity-parser.ts +174 -0
@@ -0,0 +1,433 @@
1
+ ---
2
+ name: general-audit
3
+ description: Comprehensive Solidity audit checklist spanning access control, reentrancy, oracles, and integrations.
4
+ ---
5
+
6
+ <!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
7
+ <!-- Source: Cyfrin/audit-checklist -->
8
+
9
+ # Solidity Audit Checklist
10
+
11
+ ## How to Use
12
+
13
+ - [ ] Check each item during manual review
14
+ - Mark as: ✅ Checked/Safe | ⚠️ Finding | ➖ N/A
15
+ - Reference SWC IDs for standard vulnerabilities
16
+
17
+ ---
18
+
19
+ ## 1. Access Control (SWC-105, SWC-106)
20
+
21
+ ### Ownership & Roles
22
+ - [ ] All privileged functions have access control modifiers
23
+ - [ ] Ownership can only be transferred intentionally (2-step preferred)
24
+ - [ ] Role changes emit events
25
+ - [ ] Critical operations require multi-sig or timelock
26
+ - [ ] No unprotected `selfdestruct`
27
+
28
+ ### Initializers
29
+ - [ ] `initialize()` can only be called once
30
+ - [ ] `initializer` modifier used correctly
31
+ - [ ] No uninitialized proxy implementations
32
+ - [ ] Constructor vs initializer logic is correct
33
+
34
+ ### Function Visibility
35
+ - [ ] Functions default to most restrictive visibility
36
+ - [ ] No unintended `public`/`external` functions
37
+ - [ ] Internal functions not callable via delegatecall from untrusted contracts
38
+
39
+ ---
40
+
41
+ ## 2. Reentrancy (SWC-107)
42
+
43
+ ### Pattern Detection
44
+ - [ ] External calls identified and mapped
45
+ - [ ] State changes occur BEFORE external calls (CEI pattern)
46
+ - [ ] `ReentrancyGuard` used on state-changing functions with external calls
47
+ - [ ] Read-only reentrancy considered (view functions reading stale state)
48
+
49
+ ### Cross-Function Reentrancy
50
+ - [ ] Multiple functions sharing state checked
51
+ - [ ] Callbacks (ERC777, ERC721 `onReceived`, etc.) don't break invariants
52
+ - [ ] Flash loan callbacks don't enable reentrancy
53
+
54
+ ### Cross-Contract Reentrancy
55
+ - [ ] External protocol integrations checked for callbacks
56
+ - [ ] Composability with other protocols considered
57
+
58
+ ---
59
+
60
+ ## 3. Arithmetic & Precision (SWC-101)
61
+
62
+ ### Overflow/Underflow
63
+ - [ ] Solidity >=0.8 or SafeMath used
64
+ - [ ] `unchecked` blocks reviewed carefully
65
+ - [ ] Casting between types checked (uint256 → uint128, etc.)
66
+
67
+ ### Precision Loss
68
+ - [ ] Division before multiplication avoided
69
+ - [ ] Rounding direction is protocol-favorable
70
+ - [ ] Decimal handling correct (6 vs 18 decimals)
71
+ - [ ] Small amounts don't round to zero unexpectedly
72
+
73
+ ### Edge Cases
74
+ - [ ] Zero amounts handled correctly
75
+ - [ ] Max uint256 values don't cause issues
76
+ - [ ] Negative scenarios (if using int types)
77
+
78
+ ---
79
+
80
+ ## 4. Input Validation (SWC-123, SWC-129)
81
+
82
+ ### Parameter Checks
83
+ - [ ] All external inputs validated
84
+ - [ ] Array lengths checked before use
85
+ - [ ] Array lengths match when processing multiple arrays
86
+ - [ ] Address(0) checks where appropriate
87
+ - [ ] Bounds checking on indices
88
+
89
+ ### Slippage & Deadlines
90
+ - [ ] Slippage protection enforced (not just user-settable)
91
+ - [ ] Deadline parameters validated and used
92
+ - [ ] Price impact limits enforced
93
+
94
+ ---
95
+
96
+ ## 5. External Calls (SWC-104, SWC-113)
97
+
98
+ ### Return Values
99
+ - [ ] All return values checked
100
+ - [ ] Low-level calls check success boolean
101
+ - [ ] ERC20 `transfer`/`transferFrom` return values handled (or SafeERC20 used)
102
+
103
+ ### Call Patterns
104
+ - [ ] No unbounded loops with external calls
105
+ - [ ] Gas limits on calls considered
106
+ - [ ] Fallback behavior on failed calls appropriate
107
+
108
+ ### Delegatecall
109
+ - [ ] Delegatecall targets are trusted/immutable
110
+ - [ ] Storage layout compatible with delegate targets
111
+ - [ ] No user-controlled delegatecall targets
112
+
113
+ ---
114
+
115
+ ## 6. Token Handling
116
+
117
+ ### ERC20 Weirdness
118
+ - [ ] Fee-on-transfer tokens: measure balance before/after
119
+ - [ ] Rebasing tokens: don't cache balances
120
+ - [ ] Missing return values: use SafeERC20
121
+ - [ ] Pausable tokens: handle gracefully
122
+ - [ ] Blocklist tokens: consider implications
123
+ - [ ] Multiple addresses: verify canonical address
124
+ - [ ] Approval race condition: use increaseAllowance or set to 0 first
125
+
126
+ ### ERC721/1155
127
+ - [ ] `onERC721Received` reentrancy considered
128
+ - [ ] Token IDs validated
129
+ - [ ] Batch operations gas-bounded
130
+
131
+ ### Native ETH
132
+ - [ ] ETH and WETH handled consistently
133
+ - [ ] `msg.value` not reused in loops
134
+ - [ ] ETH sent to contracts can be received
135
+
136
+ ---
137
+
138
+ ## 7. Oracle & Price Feeds
139
+
140
+ ### Data Freshness
141
+ - [ ] Stale price checks implemented
142
+ - [ ] Heartbeat/threshold appropriate for use case
143
+ - [ ] Fallback oracle behavior defined
144
+
145
+ ### Manipulation Resistance
146
+ - [ ] TWAP vs spot price appropriate
147
+ - [ ] Flash loan resistance verified
148
+ - [ ] Multiple oracle sources considered
149
+ - [ ] Sequencer uptime checked (L2s)
150
+
151
+ ### Integration
152
+ - [ ] Oracle decimals handled correctly
153
+ - [ ] Price ≤ 0 cases handled
154
+ - [ ] Round completeness verified (Chainlink)
155
+
156
+ ---
157
+
158
+ ## 8. State & Storage
159
+
160
+ ### State Consistency
161
+ - [ ] State updates atomic where needed
162
+ - [ ] No partial state on revert
163
+ - [ ] Mappings deleted correctly (can't delete mapping)
164
+
165
+ ### Storage Collisions
166
+ - [ ] Proxy storage gaps defined
167
+ - [ ] No storage slot conflicts in upgrades
168
+ - [ ] Struct packing intentional
169
+
170
+ ### Events
171
+ - [ ] All state changes emit events
172
+ - [ ] Events indexed appropriately
173
+ - [ ] No sensitive data in events
174
+
175
+ ---
176
+
177
+ ## 9. Denial of Service (SWC-113, SWC-128)
178
+
179
+ ### Unbounded Operations
180
+ - [ ] Loops are bounded
181
+ - [ ] Array operations don't exceed block gas limit
182
+ - [ ] Push operations have limits
183
+
184
+ ### Griefing
185
+ - [ ] Can't force contract into bad state
186
+ - [ ] Emergency withdrawal paths exist
187
+ - [ ] Time-based locks have reasonable limits
188
+
189
+ ### External Dependencies
190
+ - [ ] Protocol continues if oracle fails
191
+ - [ ] External contract failures handled gracefully
192
+
193
+ ---
194
+
195
+ ## 10. Frontrunning & MEV (SWC-114)
196
+
197
+ ### Transaction Ordering
198
+ - [ ] Commit-reveal for sensitive operations
199
+ - [ ] Slippage protection on swaps
200
+ - [ ] Deadline parameters enforced
201
+
202
+ ### Sandwich Attacks
203
+ - [ ] Large trades protected
204
+ - [ ] Price impact limits enforced
205
+
206
+ ### Information Leakage
207
+ - [ ] No profitable frontrunning opportunities
208
+ - [ ] Auction mechanisms fair
209
+
210
+ ---
211
+
212
+ ## 11. Governance & Timelocks
213
+
214
+ ### Proposals
215
+ - [ ] Proposal execution delayed appropriately
216
+ - [ ] Quorum requirements sensible
217
+ - [ ] Flash loan governance attacks mitigated
218
+
219
+ ### Emergency Functions
220
+ - [ ] Emergency pause exists
221
+ - [ ] Emergency withdrawal paths exist
222
+ - [ ] Guardian powers limited and documented
223
+
224
+ ---
225
+
226
+ ## 12. Upgradeability (SWC-102)
227
+
228
+ ### Proxy Patterns
229
+ - [ ] Implementation can't be initialized directly
230
+ - [ ] `_disableInitializers()` in constructor
231
+ - [ ] Storage gaps for future variables
232
+
233
+ ### Upgrade Safety
234
+ - [ ] Upgrade function protected
235
+ - [ ] State migration handled
236
+ - [ ] Rollback plan exists
237
+
238
+ ---
239
+
240
+ ## 13. Cryptography & Signatures (SWC-117, SWC-121, SWC-122)
241
+
242
+ ### Signature Handling
243
+ - [ ] Replay protection (nonces, domain separator)
244
+ - [ ] EIP-712 structured data used
245
+ - [ ] Signature malleability prevented
246
+ - [ ] ecrecover return value checked (not address(0))
247
+
248
+ ### Randomness
249
+ - [ ] No on-chain randomness for value-bearing operations
250
+ - [ ] VRF or commit-reveal for randomness
251
+
252
+ ---
253
+
254
+ ## 14. Gas & Efficiency
255
+
256
+ ### Gas Limits
257
+ - [ ] Loops bounded
258
+ - [ ] No gas griefing vectors
259
+ - [ ] Estimated gas within block limits
260
+
261
+ ### Optimizations
262
+ - [ ] Storage reads minimized (cache in memory)
263
+ - [ ] Calldata used where possible
264
+ - [ ] Events used instead of storage for historical data
265
+
266
+ ---
267
+
268
+ ## 15. Code Quality
269
+
270
+ ### Documentation
271
+ - [ ] NatSpec on public/external functions
272
+ - [ ] Complex logic commented
273
+ - [ ] Invariants documented
274
+
275
+ ### Testing
276
+ - [ ] >80% code coverage
277
+ - [ ] Edge cases tested
278
+ - [ ] Fuzz testing on critical functions
279
+ - [ ] Invariant tests defined
280
+
281
+ ### Best Practices
282
+ - [ ] Consistent naming conventions
283
+ - [ ] No magic numbers (use constants)
284
+ - [ ] Compiler version locked
285
+ - [ ] No floating pragma
286
+
287
+ ---
288
+
289
+ ## Quick Reference: SWC IDs
290
+
291
+ | ID | Name |
292
+ |----|------|
293
+ | SWC-100 | Function Default Visibility |
294
+ | SWC-101 | Integer Overflow/Underflow |
295
+ | SWC-102 | Outdated Compiler |
296
+ | SWC-103 | Floating Pragma |
297
+ | SWC-104 | Unchecked Call Return Value |
298
+ | SWC-105 | Unprotected Ether Withdrawal |
299
+ | SWC-106 | Unprotected SELFDESTRUCT |
300
+ | SWC-107 | Reentrancy |
301
+ | SWC-108 | State Variable Default Visibility |
302
+ | SWC-110 | Assert Violation |
303
+ | SWC-111 | Use of Deprecated Functions |
304
+ | SWC-112 | Delegatecall to Untrusted Callee |
305
+ | SWC-113 | DoS with Failed Call |
306
+ | SWC-114 | Transaction Order Dependence |
307
+ | SWC-115 | Authorization through tx.origin |
308
+ | SWC-116 | Block Timestamp Dependence |
309
+ | SWC-117 | Signature Malleability |
310
+ | SWC-118 | Incorrect Constructor Name |
311
+ | SWC-119 | Shadowing State Variables |
312
+ | SWC-120 | Weak Sources of Randomness |
313
+ | SWC-121 | Missing Protection against Signature Replay |
314
+ | SWC-122 | Lack of Proper Signature Verification |
315
+ | SWC-123 | Requirement Violation |
316
+ | SWC-124 | Write to Arbitrary Storage Location |
317
+ | SWC-125 | Incorrect Inheritance Order |
318
+ | SWC-126 | Insufficient Gas Griefing |
319
+ | SWC-127 | Arbitrary Jump with Function Type Variable |
320
+ | SWC-128 | DoS With Block Gas Limit |
321
+ | SWC-129 | Typographical Error |
322
+ | SWC-130 | Right-To-Left-Override control character |
323
+ | SWC-131 | Presence of Unused Variables |
324
+ | SWC-132 | Unexpected Ether balance |
325
+ | SWC-133 | Hash Collisions With Multiple Variable Length Arguments |
326
+ | SWC-134 | Message call with hardcoded gas amount |
327
+ | SWC-135 | Code With No Effects |
328
+ | SWC-136 | Unencrypted Private Data On-Chain |
329
+
330
+ ## Additional Checklist IDs (Cyfrin)
331
+
332
+ - [ ] **[SOL-AM-DOSA-1]** Is the withdrawal pattern followed to prevent denial of service?
333
+ - [ ] **[SOL-AM-DOSA-2]** Is there a minimum transaction amount enforced?
334
+ - [ ] **[SOL-AM-DOSA-3]** How does the protocol handle tokens with blacklisting functionality?
335
+ - [ ] **[SOL-AM-DOSA-4]** Can forcing the protocol to process a queue lead to DOS?
336
+ - [ ] **[SOL-AM-DOSA-5]** What happens with low decimal tokens that might cause DOS?
337
+ - [ ] **[SOL-AM-DOSA-6]** Does the protocol handle external contract interactions safely?
338
+ - [ ] **[SOL-AM-GA-1]** Is there an external function that relies on states that can be changed by others?
339
+ - [ ] **[SOL-AM-GA-2]** Can the contract operations be manipulated with precise gas limit specifications?
340
+ - [ ] **[SOL-AM-MA-1]** Is block.timestamp used for time-sensitive operations?
341
+ - [ ] **[SOL-AM-MA-2]** Is the contract using block properties like timestamp or difficulty for randomness generation?
342
+ - [ ] **[SOL-AM-MA-3]** Is contract logic sensitive to transaction ordering?
343
+ - [ ] **[SOL-AM-ReentrancyAttack-1]** Is there a view function that can return a stale value during interactions?
344
+ - [ ] **[SOL-AM-ReentrancyAttack-2]** Is there any state change after interaction to an external contract?
345
+ - [ ] **[SOL-AM-ReplayAttack-1]** Are there protections against replay attacks for failed transactions?
346
+ - [ ] **[SOL-AM-ReplayAttack-2]** Is there protection against replaying signatures on different chains?
347
+ - [ ] **[SOL-AM-RP-1]** Can the admin of the protocol pull assets from the protocol?
348
+ - [ ] **[SOL-AM-SybilAttack-1]** Is there a mechanism depending on the number of users?
349
+ - [ ] **[SOL-Basics-AC-1]** Did you clarify all the actors and their allowed interactions in the protocol?
350
+ - [ ] **[SOL-Basics-AC-2]** Are there functions lacking proper access controls?
351
+ - [ ] **[SOL-Basics-AC-3]** Do certain addresses require whitelisting?
352
+ - [ ] **[SOL-Basics-AC-4]** Does the protocol allow transfer of privileges?
353
+ - [ ] **[SOL-Basics-AC-5]** What happens during the transfer of privileges?
354
+ - [ ] **[SOL-Basics-AC-6]** Does the contract inherit others?
355
+ - [ ] **[SOL-Basics-AC-7]** Does the contract use `tx.origin` in validation?
356
+ - [ ] **[SOL-Basics-AL-1]** What happens on the first and the last cycle of the iteration?
357
+ - [ ] **[SOL-Basics-AL-4]** How does the protocol remove an item from an array?
358
+ - [ ] **[SOL-Basics-AL-5]** Does any function get an index of an array as an argument?
359
+ - [ ] **[SOL-Basics-AL-6]** Is the summing of variables done accurately compared to separate calculations?
360
+ - [ ] **[SOL-Basics-AL-7]** Is it fine to have duplicate items in the array?
361
+ - [ ] **[SOL-Basics-AL-8]** Is there any issue with the first and the last iteration?
362
+ - [ ] **[SOL-Basics-AL-9]** Is there possibility of iteration of a huge array?
363
+ - [ ] **[SOL-Basics-AL-10]** Is there a potential for a Denial-of-Service (DoS) attack in the loop?
364
+ - [ ] **[SOL-Basics-AL-11]** Is `msg.value` used within a loop?
365
+ - [ ] **[SOL-Basics-AL-12]** Is there a loop to handle batch fund transfer?
366
+ - [ ] **[SOL-Basics-AL-13]** Is there a break or continue inside a loop?
367
+ - [ ] **[SOL-Basics-Event-1]** Does the protocol emit events on important state changes?
368
+ - [ ] **[SOL-Basics-Function-1]** Are the inputs validated?
369
+ - [ ] **[SOL-Basics-Function-2]** Are the outputs validated?
370
+ - [ ] **[SOL-Basics-Function-3]** Can the function be front-run?
371
+ - [ ] **[SOL-Basics-Function-4]** Are the code comments coherent with the implementation?
372
+ - [ ] **[SOL-Basics-Function-5]** Can edge case inputs (0, max) result in unexpected behavior?
373
+ - [ ] **[SOL-Basics-Function-6]** Does the function allow arbitrary user input?
374
+ - [ ] **[SOL-Basics-Function-7]** Should it be `external`/`public`?
375
+ - [ ] **[SOL-Basics-Function-8]** Does this function need to be called by only EOA or only contracts?
376
+ - [ ] **[SOL-Basics-Function-9]** Does this function need to be restricted for specific callers?
377
+ - [ ] **[SOL-Basics-Inheritance-1]** Is it necessary to limit visibility of parent contract's public functions?
378
+ - [ ] **[SOL-Basics-Inheritance-2]** Were all necessary functions implemented to fulfill inheritance purpose?
379
+ - [ ] **[SOL-Basics-Inheritance-3]** Has the contract implemented an interface?
380
+ - [ ] **[SOL-Basics-Inheritance-4]** Does the inheritance order matter?
381
+ - [ ] **[SOL-Basics-Initialization-1]** Are important state variables initialized properly?
382
+ - [ ] **[SOL-Basics-Initialization-2]** Has the contract inherited OpenZeppelin's Initializable?
383
+ - [ ] **[SOL-Basics-Initialization-3]** Does the contract have a separate initializer function other than a constructor?
384
+ - [ ] **[SOL-Basics-Map-1]** Is there need to delete the existing item from a map?
385
+ - [ ] **[SOL-Basics-Math-1]** Is the mathematical calculation accurate?
386
+ - [ ] **[SOL-Basics-Math-2]** Is there any loss of precision in time calculations?
387
+ - [ ] **[SOL-Basics-Math-3]** Are you aware that expressions like `1 day` are cast to `uint24`, potentially causing overflows?
388
+ - [ ] **[SOL-Basics-Math-4]** Is there any case where dividing is done before multiplication?
389
+ - [ ] **[SOL-Basics-Math-5]** Does the rounding direction matter?
390
+ - [ ] **[SOL-Basics-Math-6]** Is there a possibility of division by zero?
391
+ - [ ] **[SOL-Basics-Math-7]** Even in versions like `>0.8.0`, have you ensured variables won't underflow or overflow leading to reverts?
392
+ - [ ] **[SOL-Basics-Math-8]** Are you aware that assigning a negative value to an unsigned integer causes a revert?
393
+ - [ ] **[SOL-Basics-Math-9]** Have you properly reviewed all usages of `unchecked{}`?
394
+ - [ ] **[SOL-Basics-Math-10]** In comparisons using < or >, should you instead be using ≤ or ≥?
395
+ - [ ] **[SOL-Basics-Math-11]** Have you taken into consideration mathematical operations in inline assembly?
396
+ - [ ] **[SOL-Basics-Math-12]** What happens for the minimum/maximum values included in the calculation?
397
+ - [ ] **[SOL-Basics-Payment-1]** Is it possible for the receiver to revert?
398
+ - [ ] **[SOL-Basics-Payment-2]** Does the function gets the payment amount as a parameter?
399
+ - [ ] **[SOL-Basics-Payment-3]** Are there vulnerabilities related to force-feeding?
400
+ - [ ] **[SOL-Basics-Payment-4]** What is the minimum deposit/withdrawal amount?
401
+ - [ ] **[SOL-Basics-Payment-5]** How is the withdrawal handled?
402
+ - [ ] **[SOL-Basics-Payment-7]** Is it possible for native ETH to be locked in the contract?
403
+ - [ ] **[SOL-Basics-Type-1]** Is there a forced type casting?
404
+ - [ ] **[SOL-Basics-Type-2]** Does the protocol use time units like `days`?
405
+ - [ ] **[SOL-CR-1]** What happens to the user accounting in special conditions?
406
+ - [ ] **[SOL-CR-2]** Is there a pause mechanism?
407
+ - [ ] **[SOL-CR-3]** Is there a functionality for the admin to withdraw from the protocol?
408
+ - [ ] **[SOL-CR-4]** Can the admin change critical protocol property immediately?
409
+ - [ ] **[SOL-CR-5]** Is there any admin setter function missing events?
410
+ - [ ] **[SOL-CR-6]** How is the ownership/privilege transferred??
411
+ - [ ] **[SOL-CR-7]** Is there a proper validation in privileged setter functions?
412
+ - [ ] **[SOL-EC-1]** What are the implications if the call reenters a different function?
413
+ - [ ] **[SOL-EC-2]** Is there a multi-call?
414
+ - [ ] **[SOL-EC-3]** What are the risks associated with using delegatecall in smart contracts?
415
+ - [ ] **[SOL-EC-4]** Is the external contract call necessary?
416
+ - [ ] **[SOL-EC-5]** Has the called address been whitelisted?
417
+ - [ ] **[SOL-EC-6]** Is there suspicion when a fixed gas amount is specified?
418
+ - [ ] **[SOL-EC-8]** Is the contract passing large data to an unknown address?
419
+ - [ ] **[SOL-EC-10]** Are there any delegate calls to non-library contracts?
420
+ - [ ] **[SOL-EC-11]** Is there a strict policy against delegate calls to untrusted contracts?
421
+ - [ ] **[SOL-EC-12]** Is the address's existence verified?
422
+ - [ ] **[SOL-EC-13]** Is the check-effect-interaction pattern being utilized?
423
+ - [ ] **[SOL-EC-14]** How is the msg.sender handled?
424
+ - [ ] **[SOL-LL-1]** Is there validation on the size of the input data?
425
+ - [ ] **[SOL-LL-2]** What happens if there is no matching function signature?
426
+ - [ ] **[SOL-LL-3]** Is it checked if the target address of a call has the code?
427
+ - [ ] **[SOL-LL-4]** Is there a check on the return data size when calling precompiled code?
428
+ - [ ] **[SOL-LL-5]** Is there a non-zero check for the denominator?
429
+ - [ ] **[SOL-Signature-1]** Are signatures guarded against replay attacks?
430
+ - [ ] **[SOL-Signature-2]** Are signatures protected against malleability issues?
431
+ - [ ] **[SOL-Signature-3]** Does the returned public key from the signature verification match the expected public key?
432
+ - [ ] **[SOL-Signature-4]** Is the signature originating from the appropriate entity?
433
+ - [ ] **[SOL-Signature-5]** If the signature has a deadline, is it still valid?
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: audit-workflow
3
+ description: Five-phase Solidity audit workflow covering recon, static analysis, manual review, verification, and reporting.
4
+ ---
5
+ <!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
6
+
7
+ ## Audit Methodology
8
+
9
+ ### Phase 1: Reconnaissance (15%)
10
+
11
+ **Objective:** Understand what you're auditing before looking for bugs.
12
+
13
+ 1. **Scope Definition**
14
+ - [ ] Identify all in-scope contracts
15
+ - [ ] Note external dependencies (OpenZeppelin, etc.)
16
+ - [ ] Identify upgrade patterns (proxy, diamond, etc.)
17
+
18
+ 2. **Architecture Mapping**
19
+ - [ ] Draw contract inheritance graph
20
+ - [ ] Map external calls (who calls who)
21
+ - [ ] Identify entry points (public/external functions)
22
+ - [ ] Note privileged roles (owner, admin, guardian)
23
+
24
+ 3. **Documentation Review**
25
+ - [ ] Read protocol documentation/whitepaper
26
+ - [ ] Understand intended behavior
27
+ - [ ] Note claimed invariants
28
+
29
+ **Output:** Architecture diagram, entry point list, role map
30
+
31
+ ### Phase 2: Static Analysis (20%)
32
+
33
+ **Objective:** Catch low-hanging fruit automatically.
34
+
35
+ 1. **Run Slither**
36
+ ```bash
37
+ slither . --print human-summary
38
+ slither . --print contract-summary
39
+ slither .
40
+ ```
41
+ - [ ] Review all HIGH/MEDIUM findings
42
+ - [ ] Triage false positives with evidence
43
+ - [ ] Document true positives
44
+
45
+ 2. **Check Compiler Warnings**
46
+ ```bash
47
+ forge build --force 2>&1 | grep -i warning
48
+ ```
49
+
50
+ 3. **Run Additional Detectors**
51
+ - [ ] `slither-check-erc` for token conformance
52
+ - [ ] `slither-check-upgradeability` for proxies
53
+
54
+ **Output:** Slither report, triaged findings
55
+
56
+ ### Phase 3: Manual Review (50%)
57
+
58
+ **Objective:** Find bugs that tools miss.
59
+
60
+ #### 3.1 Access Control
61
+ - [ ] All privileged functions have access control
62
+ - [ ] Modifiers are applied consistently
63
+ - [ ] No unprotected initializers
64
+ - [ ] Role changes require multi-sig or timelock
65
+
66
+ #### 3.2 Reentrancy
67
+ - [ ] State changes before external calls (CEI pattern)
68
+ - [ ] ReentrancyGuard on vulnerable functions
69
+ - [ ] Read-only reentrancy considered
70
+ - [ ] Cross-function reentrancy paths checked
71
+
72
+ #### 3.3 Input Validation
73
+ - [ ] All external inputs validated
74
+ - [ ] Array lengths checked
75
+ - [ ] Address(0) checks where needed
76
+ - [ ] Slippage parameters enforced
77
+
78
+ #### 3.4 Arithmetic
79
+ - [ ] Precision loss in divisions
80
+ - [ ] Rounding direction (protocol-favorable)
81
+ - [ ] Overflow in Solidity <0.8 or unchecked blocks
82
+ - [ ] Casting between types
83
+
84
+ #### 3.5 Oracle & Price Feeds
85
+ - [ ] Stale price checks
86
+ - [ ] Freshness thresholds appropriate
87
+ - [ ] Flash loan resistance (TWAP vs spot)
88
+ - [ ] Fallback oracle behavior
89
+
90
+ #### 3.6 External Integrations
91
+ - [ ] Return values checked
92
+ - [ ] Weird token handling (fee-on-transfer, rebasing)
93
+ - [ ] Reentrancy from callbacks
94
+ - [ ] Protocol assumptions documented
95
+
96
+ #### 3.7 Economic/Logic
97
+ - [ ] Incentive alignment
98
+ - [ ] Sandwich/frontrunning vectors
99
+ - [ ] Flash loan attack paths
100
+ - [ ] Governance manipulation
101
+
102
+ **See:** `resources/checklist.md` for full 100+ item checklist
103
+
104
+ ### Phase 4: Verification (10%)
105
+
106
+ **Objective:** Confirm findings with evidence.
107
+
108
+ 1. **Write PoC Tests**
109
+ - Each HIGH/CRITICAL needs a Foundry test
110
+ - Show exact attack path
111
+ - Quantify impact (funds at risk)
112
+
113
+ 2. **Test Edge Cases**
114
+ ```bash
115
+ forge test --match-contract Exploit -vvvv
116
+ ```
117
+
118
+ 3. **Fuzz Critical Functions**
119
+ ```bash
120
+ forge test --match-test testFuzz
121
+ ```
122
+
123
+ ### Phase 5: Reporting (5%)
124
+
125
+ **Objective:** Communicate findings clearly.
126
+
127
+ **See:** `resources/report-template.md`
128
+
129
+ ---