solidity-argus 0.1.8 → 0.3.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 (178) hide show
  1. package/AGENTS.md +3 -3
  2. package/README.md +229 -13
  3. package/package.json +37 -8
  4. package/skills/INVENTORY.md +88 -57
  5. package/skills/README.md +72 -6
  6. package/skills/case-studies/beanstalk-governance/SKILL.md +52 -0
  7. package/skills/case-studies/bzx-flash-loan/SKILL.md +53 -0
  8. package/skills/case-studies/cream-finance/SKILL.md +52 -0
  9. package/skills/case-studies/curve-reentrancy/SKILL.md +52 -0
  10. package/skills/case-studies/dao-hack/SKILL.md +51 -0
  11. package/skills/case-studies/euler-finance/SKILL.md +52 -0
  12. package/skills/case-studies/harvest-finance/SKILL.md +52 -0
  13. package/skills/case-studies/level-finance/SKILL.md +51 -0
  14. package/skills/case-studies/mango-markets/SKILL.md +53 -0
  15. package/skills/case-studies/nomad-bridge/SKILL.md +51 -0
  16. package/skills/case-studies/parity-multisig/SKILL.md +55 -0
  17. package/skills/case-studies/poly-network/SKILL.md +51 -0
  18. package/skills/case-studies/rari-fuse/SKILL.md +51 -0
  19. package/skills/case-studies/ronin-bridge/SKILL.md +52 -0
  20. package/skills/case-studies/wormhole-bridge/SKILL.md +51 -0
  21. package/skills/checklists/cyfrin-defi-core/SKILL.md +3 -0
  22. package/skills/manifests/cyfrin.json +16 -0
  23. package/skills/manifests/defifofum.json +25 -0
  24. package/skills/manifests/kadenzipfel.json +48 -0
  25. package/skills/manifests/scvd.json +9 -0
  26. package/skills/manifests/smartbugs.json +9 -0
  27. package/skills/manifests/solodit.json +9 -0
  28. package/skills/manifests/sunweb3sec.json +9 -0
  29. package/skills/manifests/trailofbits.json +9 -0
  30. package/skills/methodology/audit-workflow/SKILL.md +3 -0
  31. package/skills/protocol-patterns/amm-dex/SKILL.md +3 -0
  32. package/skills/references/exploit-reference/SKILL.md +3 -0
  33. package/skills/vulnerability-patterns/access-control/SKILL.md +27 -0
  34. package/skills/vulnerability-patterns/arbitrary-storage-location/SKILL.md +13 -1
  35. package/skills/vulnerability-patterns/assert-violation/SKILL.md +8 -1
  36. package/skills/vulnerability-patterns/asserting-contract-from-code-size/SKILL.md +12 -1
  37. package/skills/vulnerability-patterns/authorization-txorigin/SKILL.md +8 -1
  38. package/skills/vulnerability-patterns/cross-chain-bridge-vulnerabilities/SKILL.md +217 -0
  39. package/skills/vulnerability-patterns/default-visibility/SKILL.md +13 -1
  40. package/skills/vulnerability-patterns/delegatecall-untrusted-callee/SKILL.md +8 -1
  41. package/skills/vulnerability-patterns/dos-gas-limit/SKILL.md +8 -1
  42. package/skills/vulnerability-patterns/dos-revert/SKILL.md +14 -1
  43. package/skills/vulnerability-patterns/erc4626-exchange-rate-manipulation/SKILL.md +64 -0
  44. package/skills/vulnerability-patterns/fee-on-transfer-tokens/SKILL.md +93 -0
  45. package/skills/vulnerability-patterns/flash-loan-attacks/SKILL.md +13 -0
  46. package/skills/vulnerability-patterns/floating-pragma/SKILL.md +8 -1
  47. package/skills/vulnerability-patterns/front-running-attacks/SKILL.md +209 -0
  48. package/skills/vulnerability-patterns/gas-optimization-patterns/SKILL.md +203 -0
  49. package/skills/vulnerability-patterns/governance-attacks/SKILL.md +208 -0
  50. package/skills/vulnerability-patterns/hash-collision/SKILL.md +8 -1
  51. package/skills/vulnerability-patterns/inadherence-to-standards/SKILL.md +12 -1
  52. package/skills/vulnerability-patterns/incorrect-constructor/SKILL.md +8 -1
  53. package/skills/vulnerability-patterns/incorrect-inheritance-order/SKILL.md +8 -1
  54. package/skills/vulnerability-patterns/insufficient-gas-griefing/SKILL.md +12 -1
  55. package/skills/vulnerability-patterns/lack-of-precision/SKILL.md +7 -1
  56. package/skills/vulnerability-patterns/logic-errors/SKILL.md +10 -0
  57. package/skills/vulnerability-patterns/missing-parameter-bounds/SKILL.md +44 -0
  58. package/skills/vulnerability-patterns/missing-protection-signature-replay/SKILL.md +17 -1
  59. package/skills/vulnerability-patterns/msgvalue-loop/SKILL.md +12 -1
  60. package/skills/vulnerability-patterns/off-by-one/SKILL.md +7 -1
  61. package/skills/vulnerability-patterns/oracle-manipulation/SKILL.md +22 -0
  62. package/skills/vulnerability-patterns/outdated-compiler-version/SKILL.md +8 -1
  63. package/skills/vulnerability-patterns/overflow-underflow/SKILL.md +11 -1
  64. package/skills/vulnerability-patterns/proxy-vulnerabilities/SKILL.md +209 -0
  65. package/skills/vulnerability-patterns/reentrancy/SKILL.md +22 -0
  66. package/skills/vulnerability-patterns/shadowing-state-variables/SKILL.md +8 -1
  67. package/skills/vulnerability-patterns/share-accounting-desynchronization/SKILL.md +44 -0
  68. package/skills/vulnerability-patterns/signature-malleability/SKILL.md +11 -1
  69. package/skills/vulnerability-patterns/stateful-parameter-update-drift/SKILL.md +44 -0
  70. package/skills/vulnerability-patterns/unbounded-return-data/SKILL.md +12 -1
  71. package/skills/vulnerability-patterns/unchecked-return-values/SKILL.md +13 -1
  72. package/skills/vulnerability-patterns/unencrypted-private-data-on-chain/SKILL.md +8 -1
  73. package/skills/vulnerability-patterns/unexpected-ecrecover-null-address/SKILL.md +8 -1
  74. package/skills/vulnerability-patterns/uninitialized-storage-pointer/SKILL.md +8 -1
  75. package/skills/vulnerability-patterns/unsafe-erc20-transfers/SKILL.md +132 -0
  76. package/skills/vulnerability-patterns/unsafe-low-level-call/SKILL.md +12 -1
  77. package/skills/vulnerability-patterns/unsecure-signatures/SKILL.md +12 -1
  78. package/skills/vulnerability-patterns/unsupported-opcodes/SKILL.md +11 -1
  79. package/skills/vulnerability-patterns/unused-variables/SKILL.md +8 -1
  80. package/skills/vulnerability-patterns/use-of-deprecated-functions/SKILL.md +8 -1
  81. package/skills/vulnerability-patterns/weak-sources-randomness/SKILL.md +8 -1
  82. package/skills/vulnerability-patterns/weird-tokens/SKILL.md +10 -0
  83. package/skills/vulnerability-patterns/zero-address-misconfiguration/SKILL.md +48 -0
  84. package/src/agents/argus-prompt.ts +27 -10
  85. package/src/agents/pythia-prompt.ts +7 -8
  86. package/src/agents/scribe-prompt.ts +10 -5
  87. package/src/agents/sentinel-prompt.ts +36 -7
  88. package/src/cli/cli-output.ts +16 -0
  89. package/src/cli/cli-program.ts +29 -22
  90. package/src/cli/commands/check-skills.ts +135 -0
  91. package/src/cli/commands/doctor.ts +303 -23
  92. package/src/cli/commands/init.ts +8 -6
  93. package/src/cli/commands/install.ts +10 -8
  94. package/src/cli/commands/lint-skills.ts +118 -0
  95. package/src/cli/index.ts +5 -5
  96. package/src/cli/tui-prompts.ts +4 -2
  97. package/src/cli/types.ts +3 -3
  98. package/src/config/index.ts +1 -1
  99. package/src/config/loader.ts +4 -6
  100. package/src/config/schema.ts +6 -5
  101. package/src/config/types.ts +2 -2
  102. package/src/constants/defaults.ts +2 -0
  103. package/src/create-hooks.ts +225 -29
  104. package/src/create-managers.ts +10 -8
  105. package/src/create-tools.ts +14 -8
  106. package/src/features/background-agent/background-manager.ts +93 -87
  107. package/src/features/background-agent/index.ts +1 -1
  108. package/src/features/context-monitor/context-monitor.ts +3 -3
  109. package/src/features/context-monitor/index.ts +2 -2
  110. package/src/features/error-recovery/session-recovery.ts +2 -4
  111. package/src/features/error-recovery/tool-error-recovery.ts +79 -19
  112. package/src/features/index.ts +5 -5
  113. package/src/features/persistent-state/audit-state-manager.ts +158 -52
  114. package/src/features/persistent-state/global-run-index.ts +38 -0
  115. package/src/features/persistent-state/index.ts +1 -1
  116. package/src/features/persistent-state/run-journal.ts +86 -0
  117. package/src/hooks/agent-tracker.ts +53 -0
  118. package/src/hooks/compaction-hook.ts +46 -37
  119. package/src/hooks/config-handler.ts +31 -11
  120. package/src/hooks/context-budget.ts +42 -0
  121. package/src/hooks/event-hook.ts +48 -23
  122. package/src/hooks/hook-system.ts +4 -4
  123. package/src/hooks/index.ts +5 -5
  124. package/src/hooks/knowledge-sync-hook.ts +19 -21
  125. package/src/hooks/recon-context-builder.ts +66 -0
  126. package/src/hooks/safe-create-hook.ts +9 -11
  127. package/src/hooks/system-prompt-hook.ts +128 -0
  128. package/src/hooks/tool-tracking-hook.ts +162 -29
  129. package/src/hooks/types.ts +2 -1
  130. package/src/index.ts +23 -13
  131. package/src/knowledge/retry.ts +53 -0
  132. package/src/knowledge/scvd-client.ts +103 -83
  133. package/src/knowledge/scvd-errors.ts +89 -0
  134. package/src/knowledge/scvd-index.ts +110 -62
  135. package/src/knowledge/scvd-sync.ts +223 -47
  136. package/src/knowledge/source-manifest.ts +102 -0
  137. package/src/managers/index.ts +1 -1
  138. package/src/managers/types.ts +19 -14
  139. package/src/plugin-interface.ts +19 -8
  140. package/src/shared/binary-utils.ts +44 -34
  141. package/src/shared/deep-merge.ts +55 -36
  142. package/src/shared/file-utils.ts +21 -19
  143. package/src/shared/index.ts +11 -5
  144. package/src/shared/jsonc-parser.ts +123 -28
  145. package/src/shared/logger.ts +91 -17
  146. package/src/shared/project-utils.ts +30 -0
  147. package/src/skills/analysis/cluster.ts +414 -0
  148. package/src/skills/analysis/gates.ts +227 -0
  149. package/src/skills/analysis/index.ts +33 -0
  150. package/src/skills/analysis/normalize.ts +217 -0
  151. package/src/skills/analysis/similarity.ts +224 -0
  152. package/src/skills/argus-skill-resolver.ts +237 -0
  153. package/src/skills/skill-schema.ts +99 -0
  154. package/src/solodit-lifecycle.ts +202 -0
  155. package/src/state/audit-state.ts +10 -8
  156. package/src/state/finding-store.ts +68 -55
  157. package/src/state/types.ts +96 -44
  158. package/src/tools/argus-skill-load-tool.ts +78 -0
  159. package/src/tools/contract-analyzer-tool.ts +60 -77
  160. package/src/tools/forge-coverage-tool.ts +226 -0
  161. package/src/tools/forge-fuzz-tool.ts +127 -127
  162. package/src/tools/forge-test-tool.ts +153 -157
  163. package/src/tools/gas-analysis-tool.ts +264 -0
  164. package/src/tools/pattern-checker-tool.ts +206 -167
  165. package/src/tools/pattern-loader.ts +77 -0
  166. package/src/tools/pattern-schema.ts +51 -0
  167. package/src/tools/proxy-detection-tool.ts +224 -0
  168. package/src/tools/report-generator-tool.ts +333 -142
  169. package/src/tools/slither-tool.ts +300 -210
  170. package/src/tools/solodit-search-tool.ts +255 -80
  171. package/src/tools/sync-knowledge-tool.ts +7 -11
  172. package/src/utils/audit-artifact-detector.ts +118 -0
  173. package/src/utils/dependency-scanner.ts +93 -0
  174. package/src/utils/project-detector.ts +175 -86
  175. package/src/utils/solidity-parser.ts +112 -67
  176. package/src/utils/solodit-health.ts +29 -0
  177. package/src/hooks/event-hook-v2.ts +0 -99
  178. package/src/state/plugin-state.ts +0 -14
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: unexpected-ecrecover-null-address
3
- description: - Contract uses `ecrecover` directly (not via OpenZeppelin's ECDSA library)
3
+ description: '- Contract uses `ecrecover` directly (not via OpenZeppelin''s ECDSA library)'
4
+ pattern_category: signature
5
+ detection_rules:
6
+ - regex: 'ecrecover\([^\n]*\)'
7
+ severity: Medium
8
+ confidence: Medium
9
+ swc: SWC-117
10
+ description: Raw ecrecover call that requires explicit address(0) handling
4
11
  ---
5
12
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
13
 
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: uninitialized-storage-pointer
3
- description: - Solidity version <0.5.0
3
+ description: '- Solidity version <0.5.0'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: 'storage\b'
7
+ severity: Low
8
+ confidence: Low
9
+ swc: SWC-109
10
+ description: Storage data-location usage that may indicate legacy pointer hazards
4
11
  ---
5
12
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
13
 
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: unsafe-erc20-transfers
3
+ description: Unsafe ERC20 transfer and approve calls that silently fail on non-standard tokens.
4
+ category: vulnerability-pattern
5
+ pattern_category: token-standard
6
+ source_url: https://github.com/bailsec/BailSec
7
+ source_license: CC0
8
+ imported_at: "2026-02-20T00:00:00Z"
9
+ detection_rules:
10
+ - regex: '\.transfer\([^)]+\)\s*;'
11
+ severity: Medium
12
+ confidence: Medium
13
+ description: Direct ERC20 transfer without SafeERC20 wrapper — may silently fail on non-standard tokens
14
+ - regex: '\.approve\([^)]+\)\s*;'
15
+ severity: Medium
16
+ confidence: Medium
17
+ description: Direct ERC20 approve without SafeERC20 wrapper — may silently fail on USDT-like tokens
18
+ - regex: 'IERC20\([^)]+\)\.transfer'
19
+ severity: Medium
20
+ confidence: High
21
+ description: Interface-cast ERC20 transfer without safe wrapper — return value not checked
22
+ - regex: 'IERC20\([^)]+\)\.approve'
23
+ severity: Medium
24
+ confidence: High
25
+ description: Interface-cast ERC20 approve without safe wrapper — return value not checked
26
+ ---
27
+
28
+ <!-- Source: BailSec audit reports (CC0) -->
29
+ <!-- Extracted via audit-ingest pipeline from 4 independent protocol audits -->
30
+
31
+ # Unsafe ERC20 Transfer and Approve Calls
32
+
33
+ ## Overview
34
+
35
+ The standard ERC20 interface specifies that `transfer()`, `transferFrom()`, and `approve()` return a `bool` indicating success. However, many widely-used tokens deviate from this standard:
36
+
37
+ - **USDT** does not return a boolean on `transfer`/`approve`
38
+ - **BNB**, **OMG** have missing return values
39
+ - Some tokens return `false` on failure instead of reverting
40
+
41
+ Contracts that call these functions directly (without SafeERC20) either:
42
+ 1. **Ignore the return value** → silent failure, tokens not actually transferred
43
+ 2. **Expect a boolean return** → revert on tokens that don't return one (like USDT)
44
+
45
+ **Severity:** Low to Medium
46
+
47
+ **Prevalence:** Found in 4 independent BailSec audits: Hypertrade V3 Core, Meuna, Robinos, SwapX Exchange.
48
+
49
+ ---
50
+
51
+ ## Vulnerable Pattern
52
+
53
+ ```solidity
54
+ // VULNERABLE: Direct transfer — no return value check
55
+ function withdraw(address token, uint256 amount) external {
56
+ IERC20(token).transfer(msg.sender, amount);
57
+ // If token returns false instead of reverting, this silently fails
58
+ // If token doesn't return bool (USDT), this reverts unexpectedly
59
+ balances[msg.sender] -= amount; // State updated even if transfer failed!
60
+ }
61
+
62
+ // VULNERABLE: Direct approve — breaks with USDT
63
+ function approveSpender(address token, address spender, uint256 amount) external {
64
+ IERC20(token).approve(spender, amount);
65
+ // USDT requires setting allowance to 0 before changing to non-zero
66
+ // Direct approve also doesn't handle missing return values
67
+ }
68
+ ```
69
+
70
+ ## Secure Pattern
71
+
72
+ ```solidity
73
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
74
+
75
+ using SafeERC20 for IERC20;
76
+
77
+ // SECURE: SafeERC20 handles all non-standard token behaviors
78
+ function withdraw(address token, uint256 amount) external {
79
+ IERC20(token).safeTransfer(msg.sender, amount);
80
+ // Reverts on failure for ALL token types
81
+ balances[msg.sender] -= amount;
82
+ }
83
+
84
+ // SECURE: forceApprove handles USDT's approve quirk
85
+ function approveSpender(address token, address spender, uint256 amount) external {
86
+ IERC20(token).forceApprove(spender, amount);
87
+ // Sets to 0 first if needed (USDT), handles missing return values
88
+ }
89
+ ```
90
+
91
+ ## Impact
92
+
93
+ - **Silent failure**: Token transfer returns `false` but contract proceeds as if successful — leads to accounting mismatch
94
+ - **Unexpected revert**: Contract fails on widely-used tokens (USDT, BNB) that don't conform to standard return types
95
+ - **Stuck funds**: Approve fails on USDT when changing non-zero allowance without zeroing first
96
+ - **Loss of funds**: State changes applied after a silently failed transfer result in fund loss
97
+
98
+ ## Affected Token Examples
99
+
100
+ | Token | Issue | Consequence |
101
+ |-------|-------|-------------|
102
+ | USDT | No bool return on transfer/approve | Reverts if caller expects bool return |
103
+ | USDT | Requires approve(0) before approve(N) | Approve fails for non-zero to non-zero |
104
+ | BNB | Missing return value | Reverts on standard interface call |
105
+ | OMG | Missing return value | Reverts on standard interface call |
106
+ | ZRX | Returns false on failure (no revert) | Silent failure if return unchecked |
107
+
108
+ ## Detection Checklist
109
+
110
+ 1. Does the contract use `IERC20.transfer()` or `IERC20.transferFrom()` directly?
111
+ 2. Is OpenZeppelin's `SafeERC20` imported and applied via `using SafeERC20 for IERC20`?
112
+ 3. Are `safeTransfer`, `safeTransferFrom`, and `forceApprove` used instead of raw calls?
113
+ 4. Does the contract need to support USDT or other non-standard tokens?
114
+
115
+ ## Relationship to Other Patterns
116
+
117
+ - **unchecked-return-values**: Covers low-level `.call()`, `.send()`, `.delegatecall()` return values — different from ERC20 interface returns
118
+ - **weird-tokens**: Broader reference covering all non-standard token behaviors — this skill focuses specifically on the transfer/approve safety wrapper pattern
119
+ - **fee-on-transfer-tokens**: Covers amount mismatch due to transfer fees — complementary to this pattern
120
+
121
+ ## Remediation
122
+
123
+ 1. **Use SafeERC20**: Import and apply `using SafeERC20 for IERC20` for all ERC20 interactions
124
+ 2. **Use forceApprove**: Replace `approve()` with `forceApprove()` to handle USDT
125
+ 3. **Audit token list**: Verify which tokens the protocol supports and test with non-standard ones
126
+ 4. **Add integration tests**: Test deposit/withdraw flows with USDT, USDC, and at least one missing-return-value token
127
+
128
+ ## References
129
+
130
+ - [OpenZeppelin SafeERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#SafeERC20)
131
+ - [Weird ERC20 — Missing Return Values](https://github.com/d-xo/weird-erc20#missing-return-values)
132
+ - BailSec audit reports: Hypertrade V3 Core, Meuna, Robinos, SwapX Exchange
@@ -1,6 +1,17 @@
1
1
  ---
2
2
  name: unsafe-low-level-call
3
- description: - Contract uses `.call()`, `.delegatecall()`, `.staticcall()`, or `.send()` for external interactions
3
+ description: '- Contract uses `.call()`, `.delegatecall()`, `.staticcall()`, or `.send()` for external interactions'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: '\.call\('
7
+ severity: Medium
8
+ confidence: Medium
9
+ swc: SWC-104
10
+ description: Low-level call usage requiring strict target and return-value checks
11
+ - regex: '\.delegatecall\('
12
+ severity: High
13
+ confidence: Medium
14
+ description: delegatecall usage with elevated storage-context risk
4
15
  ---
5
16
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
17
 
@@ -1,6 +1,17 @@
1
1
  ---
2
2
  name: unsecure-signatures
3
- description: - Contract uses ECDSA signatures for authorization, authentication, or message verification
3
+ description: '- Contract uses ECDSA signatures for authorization, authentication, or message verification'
4
+ pattern_category: signature
5
+ detection_rules:
6
+ - regex: 'ecrecover\(\s*'
7
+ severity: Medium
8
+ confidence: Medium
9
+ swc: SWC-117
10
+ description: Signature recovery path needing malleability and null-address protections
11
+ - regex: 'keccak256\(abi\.encodePacked\('
12
+ severity: Medium
13
+ confidence: Low
14
+ description: Packed hash construction in signature domain may enable collisions
4
15
  ---
5
16
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
17
 
@@ -1,6 +1,16 @@
1
1
  ---
2
2
  name: unsupported-opcodes
3
- description: - Contract is intended for deployment on an EVM-compatible chain other than Ethereum mainnet (zkSync Era, Arbitrum, Optimism, Polygon, BNB Chain, etc.)
3
+ description: '- Contract is intended for deployment on an EVM-compatible chain other than Ethereum mainnet (zkSync Era, Arbitrum, Optimism, Polygon, BNB Chain, etc.)'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: 'selfdestruct\('
7
+ severity: Medium
8
+ confidence: High
9
+ description: Opcode/functionality that can be unsupported or altered on target chains
10
+ - regex: '\.transfer\('
11
+ severity: Low
12
+ confidence: Low
13
+ description: transfer stipend behavior may break on non-mainnet EVMs
4
14
  ---
5
15
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
16
 
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: unused-variables
3
- description: - Contract declares state variables, local variables, function parameters, or imports that are never referenced
3
+ description: '- Contract declares state variables, local variables, function parameters, or imports that are never referenced'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: '(uint256|address|bool|bytes|string|mapping)\s+\w+\s*;'
7
+ severity: Informational
8
+ confidence: Low
9
+ swc: SWC-131
10
+ description: Declaration pattern that can surface potentially unused variables
4
11
  ---
5
12
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
13
 
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: use-of-deprecated-functions
3
- description: - Contract uses Solidity functions, keywords, or language features that have been deprecated or removed
3
+ description: '- Contract uses Solidity functions, keywords, or language features that have been deprecated or removed'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: '(suicide|sha3|block\.blockhash|msg\.gas)\('
7
+ severity: Informational
8
+ confidence: High
9
+ swc: SWC-111
10
+ description: Deprecated Solidity built-ins or aliases
4
11
  ---
5
12
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
13
 
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: weak-sources-randomness
3
- description: - Contract generates \"random\" values using on-chain data: `block.timestamp`, `blockhash`, `block.difficulty` / `block.prevrandao`, `block.number`, or combinations thereof
3
+ description: '- Contract generates "random" values using on-chain data: `block.timestamp`, `blockhash`, `block.difficulty` / `block.prevrandao`, `block.number`, or combinations thereof'
4
+ pattern_category: logic-error
5
+ detection_rules:
6
+ - regex: '(block\.timestamp|block\.prevrandao|block\.difficulty|blockhash)\b'
7
+ severity: Medium
8
+ confidence: Medium
9
+ swc: SWC-120
10
+ description: On-chain attributes used as randomness source
4
11
  ---
5
12
  <!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
6
13
 
@@ -1,6 +1,16 @@
1
1
  ---
2
2
  name: weird-tokens
3
3
  description: Non-standard ERC20 behaviors, integration pitfalls, and token-handling safeguards.
4
+ pattern_category: token-standard
5
+ detection_rules:
6
+ - regex: 'IERC20\('
7
+ severity: Informational
8
+ confidence: Low
9
+ description: ERC20 integration point where non-standard token behavior may break assumptions
10
+ - regex: '\.approve\('
11
+ severity: Low
12
+ confidence: Low
13
+ description: approve usage requires allowance race and non-standard token handling checks
4
14
  ---
5
15
  <!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
6
16
 
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: zero-address-misconfiguration
3
+ description: "Critical addresses are set to address(0), causing hard reverts, fund loss paths, or permanently broken flows."
4
+ category: vulnerability-pattern
5
+ pattern_category: access-control
6
+ source_url: "https://github.com/bailsec/BailSec"
7
+ source_license: "CC0"
8
+ imported_at: "2025-02-20T00:00:00Z"
9
+ detection_rules:
10
+ - regex: "(set|update|initialize|constructor).*(address|receiver|collector|team).*=\\s*address\\(0\\)"
11
+ severity: "High"
12
+ description: "Administrative path allows writing a critical address to zero"
13
+ - regex: "transfer\\(address\\(0\\)|safeTransfer\\(address\\(0\\)"
14
+ severity: "Medium"
15
+ description: "Outbound transfer path can target zero address after misconfiguration"
16
+ - regex: 'address\(0\)'
17
+ severity: Medium
18
+ confidence: Low
19
+ description: Reference to zero address — potential missing zero-address validation
20
+ ---
21
+ <!-- Source: BailSec audit reports (CC0) -->
22
+
23
+ # Zero Address Misconfiguration Vulnerabilities
24
+
25
+ ## Overview
26
+ Zero-address handling is an input validation and configuration integrity problem: critical system variables are set to `address(0)` even though downstream logic assumes a live recipient. In production this often appears in admin setters or constructor parameters for fee collectors, fallback receivers, team wallets, bridge modules, or reward sinks. The system usually works until one of these addresses is consumed by a transfer, mint, distribution, or callback path, then starts reverting in critical operations.
27
+
28
+ This pattern is dangerous because it can be triggered accidentally (operator error), by weak deployment scripts, or after key compromise. It is also commonly missed in reviews because the setter itself may look harmless while the breakage happens in unrelated functions.
29
+
30
+ ## Common Patterns
31
+ - Missing `require(newAddr != address(0))` in privileged setter functions.
32
+ - Constructor checks differ from setter checks, so unsafe values are allowed in one path.
33
+ - Protocol assumes a non-zero recipient in periodic distribution or epoch updates.
34
+ - Emergency plans rely on setting an address to zero, but no explicit pause-mode logic exists.
35
+
36
+ ## Detection Heuristics
37
+ - Trace every role-controlled address from write path to first transfer/mint usage.
38
+ - Flag any critical address that can be set to zero without explicit documented semantics.
39
+ - Check whether "zero means disabled" is consistently implemented across all read sites.
40
+ - Verify deployment scripts and upgrade initializers enforce non-zero invariants.
41
+
42
+ ## Examples from Audits
43
+ - Fee-aggregation routing where a primary aggregator could be set to zero, causing later fee forwarding to fail.
44
+ - Fallback distribution receiver settable to zero, leading weekly distribution flow to revert.
45
+ - Team emission address allowed to become zero, which can break epoch update and lock normal emissions.
46
+
47
+ ## Remediation
48
+ Use strict non-zero validation in constructors, initializers, and all mutating setters for critical addresses. If zero has a valid "disabled" meaning, encode that explicitly with a separate boolean mode and guarded control flow; do not overload zero as a hidden state. Add invariant tests that assert all transfer sinks remain valid after governance actions and upgrades. During operations, enforce config guards in runbooks and monitoring so zero-address writes are blocked or alerted before they reach production.
@@ -1,4 +1,3 @@
1
-
2
1
  export const ARGUS_PROMPT = `You are **Argus Panoptes**, the All-Seeing Guardian — an autonomous Solidity smart contract security auditor. You orchestrate a team of specialist subagents to conduct comprehensive security audits. Your mission is to identify vulnerabilities, logic flaws, and security risks in smart contracts with the precision and depth of a top-tier human auditor.
3
2
 
4
3
  ## IDENTITY & ROLE
@@ -23,6 +22,7 @@ Before analyzing code, understand the system.
23
22
  - Determine the "crown jewels" (e.g., user funds, admin privileges).
24
23
  - Map trust boundaries: Who is trusted? What external calls are made?
25
24
  - Define the scope: Which contracts are in scope? Which are out of scope?
25
+ - Use \`argus_proxy_detection\` to identify proxy/upgradeable patterns early.
26
26
  - **Key Questions**:
27
27
  - What is the intended business logic?
28
28
  - Who are the actors (users, admins, keepers)?
@@ -90,6 +90,8 @@ Prove the existence of vulnerabilities.
90
90
  - **Actions**:
91
91
  - Delegate to **@sentinel** to write and run reproduction tests using \`argus_forge_test\`.
92
92
  - If a function is complex or handles math/assets, delegate to **@sentinel** to run \`argus_forge_fuzz\`.
93
+ - Use \`argus_forge_coverage\` to measure test coverage gaps and prioritize untested code paths.
94
+ - Use \`argus_gas_analysis\` to identify gas-intensive hotspots that may indicate inefficient or vulnerable logic.
93
95
  - Verify that the fix (remediation) actually works.
94
96
  - Do not report a "Critical" or "High" issue without a Proof of Concept (PoC) or strong reasoning if a PoC is impossible.
95
97
  - **Techniques**:
@@ -181,14 +183,14 @@ Task(subagent_type="scribe", prompt="Generate the final audit report for Project
181
183
  - \`Task\` — for delegating to subagents
182
184
 
183
185
  **Only subagents can use (via Task delegation):**
184
- - \`argus_slither_analyze\`, \`argus_forge_test\`, \`argus_forge_fuzz\` → delegate to **sentinel**
185
- - \`argus_analyze_contract\`, \`argus_check_patterns\` → delegate to **sentinel**
186
+ - \`argus_slither_analyze\`, \`argus_forge_test\`, \`argus_forge_fuzz\`, \`argus_forge_coverage\`, \`argus_gas_analysis\` → delegate to **sentinel**
187
+ - \`argus_analyze_contract\`, \`argus_check_patterns\`, \`argus_proxy_detection\` → delegate to **sentinel**
186
188
  - \`argus_solodit_search\`, Solodit MCP search → delegate to **pythia**
187
189
  - \`argus_generate_report\` → delegate to **scribe**
188
190
 
189
191
  ### **@sentinel** (The Executor)
190
192
  - **Role**: Static analysis, dynamic testing, fuzzing.
191
- - **Tools**: \`argus_slither_analyze\`, \`argus_forge_test\`, \`argus_forge_fuzz\`, \`argus_analyze_contract\`, \`argus_check_patterns\`
193
+ - **Tools**: \`argus_slither_analyze\`, \`argus_forge_test\`, \`argus_forge_fuzz\`, \`argus_forge_coverage\`, \`argus_gas_analysis\`, \`argus_analyze_contract\`, \`argus_check_patterns\`, \`argus_proxy_detection\`
192
194
  - **Delegation Examples**:
193
195
  \`\`\`
194
196
  Task(subagent_type="sentinel", prompt="Run Slither on packages/my-project/ and analyze the Vault.sol contract in detail. Report all findings with severity.")
@@ -267,9 +269,24 @@ Your subagents have access to these specialized tools. Know when to delegate eac
267
269
  - **Purpose**: Updates the local vulnerability database (SCVD).
268
270
  - **Note**: Run if you suspect your knowledge base is stale or if the tool reports it's offline.
269
271
 
272
+ - **\`argus_forge_coverage\`**:
273
+ - **Use**: During Testing & Verification.
274
+ - **Purpose**: Measures test coverage per file (lines, statements, branches, functions).
275
+ - **Note**: Use to identify untested code paths that may harbor hidden vulnerabilities. Low branch coverage in critical contracts warrants additional testing.
276
+
277
+ - **\`argus_proxy_detection\`**:
278
+ - **Use**: During Reconnaissance.
279
+ - **Purpose**: Detects proxy patterns (ERC1967, UUPS, transparent, beacon, diamond) with confidence scoring.
280
+ - **Note**: Run early to identify upgradeability risks. Proxy contracts require special attention for storage collisions and initialization issues.
281
+
282
+ - **\`argus_gas_analysis\`**:
283
+ - **Use**: During Testing & Verification.
284
+ - **Purpose**: Runs gas report analysis and identifies high-gas hotspots above configurable threshold.
285
+ - **Note**: Gas-intensive functions often indicate complex logic that may be vulnerable or cause DoS under certain conditions.
286
+
270
287
  ## SKILL SYSTEM
271
288
 
272
- You have access to OpenCode Skills through the \`skill\` tool. Skills are specialized knowledge modules and must be used proactively when they improve audit accuracy.
289
+ Instruct subagents to use \`argus_skill_load\` only when domain-specific context is needed. It is namespaced for Argus and works with OMO-compatible discovery plus Argus-native fallback. The knowledge base includes 75+ curated SKILL.md files, 13 YAML pattern packs, and 15 real-world exploit case studies covering $3B+ in losses.
273
290
 
274
291
  - **Curated skill map (load these first)**:
275
292
  - **Reconnaissance**: \`amm-dex\`, \`lending-borrowing\`, \`bridges-cross-chain\`
@@ -277,9 +294,9 @@ You have access to OpenCode Skills through the \`skill\` tool. Skills are specia
277
294
  - **Verification**: \`cyfrin-defi-core\`, \`severity-classification\`, \`report-template\`
278
295
 
279
296
  - **Deterministic trigger rules**:
280
- - If the protocol uses AMM reserves or pool math, load \`amm-dex\` before Attack Surface Mapping.
281
- - If price feeds or spot prices influence critical state changes, load \`oracle-manipulation\` before severity assessment.
282
- - If proxy/upgrade patterns are present, load \`cyfrin-best-practices-upgrades\` before final recommendations.
297
+ - If the protocol uses AMM reserves or pool math, load \`amm-dex\` via \`argus_skill_load\` before Attack Surface Mapping.
298
+ - If price feeds or spot prices influence critical state changes, load \`oracle-manipulation\` via \`argus_skill_load\` before severity assessment.
299
+ - If proxy/upgrade patterns are present, load \`cyfrin-best-practices-upgrades\` via \`argus_skill_load\` before final recommendations.
283
300
 
284
301
  - **Trail of Bits skills**:
285
302
  - For pre-audit deep context modeling and attack-surface grounding: \`audit-context-building\`
@@ -420,8 +437,8 @@ You do NOT need to pass raw JSON or serialized audit state. Just pass your findi
420
437
  **If you have zero findings, still invoke Scribe** with an empty findings list. A clean report is still a report.
421
438
 
422
439
  You are the guardian. Nothing escapes your gaze. Begin the audit.
423
- `;
440
+ `
424
441
 
425
442
  export function getArgusPrompt(): string {
426
- return ARGUS_PROMPT;
443
+ return ARGUS_PROMPT
427
444
  }
@@ -1,4 +1,3 @@
1
-
2
1
  export const PYTHIA_PROMPT = `You are **Pythia**, the Oracle — a specialized research subagent of Argus Panoptes. While Sentinel hunts for bugs in the code, you consult the archives of knowledge. You are the bridge between the current codebase and the history of all smart contract security failures.
3
2
 
4
3
  ## IDENTITY & ROLE
@@ -87,20 +86,20 @@ You have two primary tools. Master them.
87
86
 
88
87
  ## SKILLS SYSTEM
89
88
 
90
- OpenCode has a powerful **Skills** system that allows you to load specialized knowledge modules.
89
+ OpenCode has a powerful **Skills** system that allows you to load specialized knowledge modules. The Argus knowledge base includes 75+ curated SKILL.md files, 13 YAML pattern packs, and 15 real-world exploit case studies covering $3B+ in losses.
91
90
 
92
91
  **How to use**:
93
92
  - Load a relevant skill before deep research when protocol context is non-trivial.
94
93
  - Prioritize vulnerability pattern skills, protocol pattern skills, and reference skills for exploit precedent mapping.
95
- - Use the \`skill\` tool directly when available to load the exact skill you need.
94
+ - Use \`argus_skill_load\` only when specialized context is needed, and load the exact skill you need.
96
95
  - **Curated skill map**:
97
96
  - \`reentrancy\`, \`oracle-manipulation\`, \`flash-loan-attacks\`
98
97
  - \`lending-borrowing\`, \`amm-dex\`
99
98
  - \`exploit-reference\`
100
99
  - **Deterministic trigger rules**:
101
- - If you investigate spot-price dependencies, load \`oracle-manipulation\` first.
102
- - If capital-efficient attacks or same-block loops are plausible, load \`flash-loan-attacks\` first.
103
- - If the protocol integrates arbitrary ERC20s, load ToB \`token-integration-analyzer\` (building-secure-contracts plugin) before recommendation drafting.
100
+ - If you investigate spot-price dependencies, load \`oracle-manipulation\` with \`argus_skill_load\` first.
101
+ - If capital-efficient attacks or same-block loops are plausible, load \`flash-loan-attacks\` with \`argus_skill_load\` first.
102
+ - If the protocol integrates arbitrary ERC20s, load ToB \`token-integration-analyzer\` (building-secure-contracts plugin) with \`argus_skill_load\` before recommendation drafting.
104
103
  - **Examples**:
105
104
  - "I am loading \`reentrancy\` to cross-reference known exploit patterns and missed edge cases."
106
105
  - "I am loading \`lending-borrowing\` to map lending-specific oracle and liquidation failure modes."
@@ -139,8 +138,8 @@ Report your findings to Argus using this Markdown structure. Focus on **Preceden
139
138
  - **False Positives**: If \`argus_check_patterns\` returns noise, filter it out. Do not report false positives to Argus.
140
139
 
141
140
  You are Pythia. The past is your map, and the code is the territory. Guide us to safety.
142
- `;
141
+ `
143
142
 
144
143
  export function getPythiaPrompt(): string {
145
- return PYTHIA_PROMPT;
144
+ return PYTHIA_PROMPT
146
145
  }
@@ -24,6 +24,11 @@ Your output must always follow this professional structure:
24
24
  5. **Recommendations**: Strategic advice for improving the overall security posture.
25
25
  6. **Appendix**: Tool execution logs or supplementary data.
26
26
 
27
+ ### Optional Sections (include when data is available)
28
+ - **Test Coverage Analysis**: Include coverage metrics from \`argus_forge_coverage\` if available. Highlight files with low branch/statement coverage.
29
+ - **Gas Hotspot Analysis**: Include gas analysis from \`argus_gas_analysis\` if available. Flag functions exceeding gas thresholds.
30
+ - **Proxy & Upgradeability Analysis**: Include proxy detection findings from \`argus_proxy_detection\` if available. Document proxy patterns identified and associated risks.
31
+
27
32
  ## WRITING STYLE GUIDE
28
33
 
29
34
  You must adhere to these strict writing standards:
@@ -62,15 +67,15 @@ Before generating the report, verify:
62
67
 
63
68
  ## SKILL SYSTEM
64
69
 
65
- Use the \`skill\` tool when needed to improve report quality and consistency.
70
+ Use \`argus_skill_load\` only when needed to improve report quality and consistency.
66
71
 
67
72
  - **Curated skill map**:
68
73
  - \`report-template\`, \`severity-classification\`
69
74
  - \`cyfrin-defi-core\`
70
75
  - \`exploit-reference\`
71
76
  - **Deterministic trigger rules**:
72
- - If severity wording drifts, load \`severity-classification\` before publishing.
73
- - If recommendation quality is generic, load \`cyfrin-defi-core\` before final edits.
77
+ - If severity wording drifts, load \`severity-classification\` with \`argus_skill_load\` before publishing.
78
+ - If recommendation quality is generic, load \`cyfrin-defi-core\` with \`argus_skill_load\` before final edits.
74
79
 
75
80
  ## OUTPUT FORMAT
76
81
 
@@ -92,8 +97,8 @@ Write the full report in Markdown. Use the standard finding format:
92
97
  \`\`\`
93
98
 
94
99
  You are Scribe. Your words define the security of the protocol. Write with precision.
95
- `;
100
+ `
96
101
 
97
102
  export function getScribePrompt(): string {
98
- return SCRIBE_PROMPT;
103
+ return SCRIBE_PROMPT
99
104
  }
@@ -1,4 +1,3 @@
1
-
2
1
  export const SENTINEL_PROMPT = `You are **Sentinel**, the Tactical Guardian — a specialized subagent of Argus Panoptes. You are the "hands" of the audit, responsible for rigorous execution, static analysis, and dynamic verification. While Argus strategizes, you hunt.
3
2
 
4
3
  ## IDENTITY & ROLE
@@ -18,6 +17,7 @@ You operate in a loop of **Scan -> Analyze -> Verify**.
18
17
  1. **Broad Scan**:
19
18
  - Start with \`argus_slither_analyze\` to get a high-level overview of potential issues.
20
19
  - Use \`argus_check_patterns\` to scan for specific dangerous patterns (e.g., read-only reentrancy).
20
+ - Use \`argus_proxy_detection\` to identify proxy patterns (ERC1967, UUPS, transparent, beacon, diamond).
21
21
 
22
22
  2. **Deep Analysis**:
23
23
  - For interesting contracts, use \`argus_analyze_contract\` to understand their structure, inheritance, and risk indicators.
@@ -27,6 +27,8 @@ You operate in a loop of **Scan -> Analyze -> Verify**.
27
27
  - If you suspect a bug, write a reproduction test case.
28
28
  - Use \`argus_forge_test\` to run this test.
29
29
  - If the logic is complex (e.g., math, state transitions), use \`argus_forge_fuzz\` to hammer it with inputs.
30
+ - After running tests, check coverage with \`argus_forge_coverage\` to identify untested code paths.
31
+ - Use \`argus_gas_analysis\` to identify gas-intensive functions that may indicate inefficient or vulnerable logic.
30
32
 
31
33
  4. **Reporting**:
32
34
  - Format your findings strictly according to the Output Format section.
@@ -87,18 +89,45 @@ You have access to a specific set of tools. Use them effectively.
87
89
  **Interpretation**:
88
90
  - Look at the \`counterexamples\`. They tell you exactly what inputs broke the code.
89
91
 
92
+ ### 6. \`argus_forge_coverage\`
93
+ **Purpose**: Measure test coverage to find untested code paths.
94
+ **When to use**: After running tests, to identify gaps in coverage.
95
+ **Arguments**:
96
+ - \`target\` (string): Path to the project directory (default ".").
97
+ **Interpretation**:
98
+ - Focus on low branch coverage in critical contracts (vaults, token transfers, access control).
99
+ - Untested code paths are prime candidates for hidden vulnerabilities.
100
+
101
+ ### 7. \`argus_proxy_detection\`
102
+ **Purpose**: Detect proxy/upgradeable contract patterns.
103
+ **When to use**: During initial scanning to identify upgradeability risks early.
104
+ **Arguments**:
105
+ - \`file_path\` (string): Path to the .sol file to analyze.
106
+ **Interpretation**:
107
+ - Identifies ERC1967, UUPS, transparent, beacon, and diamond proxy patterns.
108
+ - Proxy contracts require special attention for storage collisions and initialization issues.
109
+
110
+ ### 8. \`argus_gas_analysis\`
111
+ **Purpose**: Identify gas-intensive functions that may indicate complex or vulnerable logic.
112
+ **When to use**: During verification, to flag functions with abnormally high gas usage.
113
+ **Arguments**:
114
+ - \`target\` (string): Path to the project directory (default ".").
115
+ **Interpretation**:
116
+ - High gas consumption often correlates with complex logic, unbounded loops, or storage-heavy operations.
117
+ - Gas hotspots are prime candidates for DoS vulnerabilities.
118
+
90
119
  ## SKILL SYSTEM
91
120
 
92
- Use the \`skill\` tool to load specialized skills before deep verification work.
121
+ Use \`argus_skill_load\` only when specialized context is needed before deep verification work.
93
122
 
94
123
  - **Curated skill map**:
95
124
  - \`reentrancy\`, \`access-control\`, \`oracle-manipulation\`
96
125
  - \`cyfrin-defi-integrations\`, \`severity-classification\`
97
126
  - Trail of Bits: \`property-based-testing\`, \`variant-analysis\`
98
127
  - **Deterministic trigger rules**:
99
- - If external calls and mutable state interleave, load \`reentrancy\` before writing PoCs.
100
- - If privileged flows are central to the finding, load \`access-control\` before severity scoring.
101
- - If fuzzing strategy is unclear, load ToB \`property-based-testing\` before selecting invariants.
128
+ - If external calls and mutable state interleave, load \`reentrancy\` with \`argus_skill_load\` before writing PoCs.
129
+ - If privileged flows are central to the finding, load \`access-control\` with \`argus_skill_load\` before severity scoring.
130
+ - If fuzzing strategy is unclear, load ToB \`property-based-testing\` with \`argus_skill_load\` before selecting invariants.
102
131
 
103
132
  ## OUTPUT FORMAT
104
133
 
@@ -139,8 +168,8 @@ Return your findings to Argus in this structured Markdown format. Do not deviate
139
168
  - **Be Precise**: A vague finding is useless. Point to the line, the variable, the specific interaction.
140
169
 
141
170
  You are the Sentinel. The code cannot hide its secrets from you.
142
- `;
171
+ `
143
172
 
144
173
  export function getSentinelPrompt(): string {
145
- return SENTINEL_PROMPT;
174
+ return SENTINEL_PROMPT
146
175
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Thin CLI output abstraction for user-facing CLI output.
3
+ * Distinct from createLogger() which writes structured logs to file (~/.cache/solidity-argus/argus.log).
4
+ * CLI output goes to stdout/stderr for user-visible formatted output (doctor reports, init messages, etc.)
5
+ */
6
+ export const cliOutput = {
7
+ log(...args: unknown[]): void {
8
+ console.log(...args)
9
+ },
10
+ warn(...args: unknown[]): void {
11
+ console.warn(...args)
12
+ },
13
+ error(...args: unknown[]): void {
14
+ console.error(...args)
15
+ },
16
+ }