solidity-argus 0.2.0 → 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.
- package/AGENTS.md +3 -3
- package/README.md +93 -37
- package/package.json +33 -7
- package/skills/INVENTORY.md +88 -57
- package/skills/README.md +26 -23
- package/skills/case-studies/beanstalk-governance/SKILL.md +52 -0
- package/skills/case-studies/bzx-flash-loan/SKILL.md +53 -0
- package/skills/case-studies/cream-finance/SKILL.md +52 -0
- package/skills/case-studies/curve-reentrancy/SKILL.md +52 -0
- package/skills/case-studies/dao-hack/SKILL.md +51 -0
- package/skills/case-studies/euler-finance/SKILL.md +52 -0
- package/skills/case-studies/harvest-finance/SKILL.md +52 -0
- package/skills/case-studies/level-finance/SKILL.md +51 -0
- package/skills/case-studies/mango-markets/SKILL.md +53 -0
- package/skills/case-studies/nomad-bridge/SKILL.md +51 -0
- package/skills/case-studies/parity-multisig/SKILL.md +55 -0
- package/skills/case-studies/poly-network/SKILL.md +51 -0
- package/skills/case-studies/rari-fuse/SKILL.md +51 -0
- package/skills/case-studies/ronin-bridge/SKILL.md +52 -0
- package/skills/case-studies/wormhole-bridge/SKILL.md +51 -0
- package/skills/manifests/smartbugs.json +1 -3
- package/skills/manifests/sunweb3sec.json +1 -3
- package/skills/vulnerability-patterns/access-control/SKILL.md +14 -0
- package/skills/vulnerability-patterns/arbitrary-storage-location/SKILL.md +13 -1
- package/skills/vulnerability-patterns/assert-violation/SKILL.md +8 -1
- package/skills/vulnerability-patterns/asserting-contract-from-code-size/SKILL.md +12 -1
- package/skills/vulnerability-patterns/authorization-txorigin/SKILL.md +2 -1
- package/skills/vulnerability-patterns/cross-chain-bridge-vulnerabilities/SKILL.md +217 -0
- package/skills/vulnerability-patterns/default-visibility/SKILL.md +13 -1
- package/skills/vulnerability-patterns/delegatecall-untrusted-callee/SKILL.md +2 -1
- package/skills/vulnerability-patterns/dos-gas-limit/SKILL.md +8 -1
- package/skills/vulnerability-patterns/dos-revert/SKILL.md +1 -0
- package/skills/vulnerability-patterns/erc4626-exchange-rate-manipulation/SKILL.md +64 -0
- package/skills/vulnerability-patterns/fee-on-transfer-tokens/SKILL.md +93 -0
- package/skills/vulnerability-patterns/flash-loan-attacks/SKILL.md +1 -0
- package/skills/vulnerability-patterns/floating-pragma/SKILL.md +8 -1
- package/skills/vulnerability-patterns/front-running-attacks/SKILL.md +209 -0
- package/skills/vulnerability-patterns/gas-optimization-patterns/SKILL.md +203 -0
- package/skills/vulnerability-patterns/governance-attacks/SKILL.md +208 -0
- package/skills/vulnerability-patterns/hash-collision/SKILL.md +8 -1
- package/skills/vulnerability-patterns/inadherence-to-standards/SKILL.md +12 -1
- package/skills/vulnerability-patterns/incorrect-constructor/SKILL.md +8 -1
- package/skills/vulnerability-patterns/incorrect-inheritance-order/SKILL.md +8 -1
- package/skills/vulnerability-patterns/insufficient-gas-griefing/SKILL.md +12 -1
- package/skills/vulnerability-patterns/lack-of-precision/SKILL.md +7 -1
- package/skills/vulnerability-patterns/logic-errors/SKILL.md +10 -0
- package/skills/vulnerability-patterns/missing-parameter-bounds/SKILL.md +44 -0
- package/skills/vulnerability-patterns/missing-protection-signature-replay/SKILL.md +17 -1
- package/skills/vulnerability-patterns/msgvalue-loop/SKILL.md +12 -1
- package/skills/vulnerability-patterns/off-by-one/SKILL.md +7 -1
- package/skills/vulnerability-patterns/oracle-manipulation/SKILL.md +9 -0
- package/skills/vulnerability-patterns/outdated-compiler-version/SKILL.md +8 -1
- package/skills/vulnerability-patterns/overflow-underflow/SKILL.md +1 -0
- package/skills/vulnerability-patterns/proxy-vulnerabilities/SKILL.md +209 -0
- package/skills/vulnerability-patterns/reentrancy/SKILL.md +9 -0
- package/skills/vulnerability-patterns/shadowing-state-variables/SKILL.md +8 -1
- package/skills/vulnerability-patterns/share-accounting-desynchronization/SKILL.md +44 -0
- package/skills/vulnerability-patterns/signature-malleability/SKILL.md +2 -1
- package/skills/vulnerability-patterns/stateful-parameter-update-drift/SKILL.md +44 -0
- package/skills/vulnerability-patterns/unbounded-return-data/SKILL.md +12 -1
- package/skills/vulnerability-patterns/unchecked-return-values/SKILL.md +2 -1
- package/skills/vulnerability-patterns/unencrypted-private-data-on-chain/SKILL.md +8 -1
- package/skills/vulnerability-patterns/unexpected-ecrecover-null-address/SKILL.md +8 -1
- package/skills/vulnerability-patterns/uninitialized-storage-pointer/SKILL.md +8 -1
- package/skills/vulnerability-patterns/unsafe-erc20-transfers/SKILL.md +132 -0
- package/skills/vulnerability-patterns/unsafe-low-level-call/SKILL.md +12 -1
- package/skills/vulnerability-patterns/unsecure-signatures/SKILL.md +12 -1
- package/skills/vulnerability-patterns/unsupported-opcodes/SKILL.md +11 -1
- package/skills/vulnerability-patterns/unused-variables/SKILL.md +8 -1
- package/skills/vulnerability-patterns/use-of-deprecated-functions/SKILL.md +8 -1
- package/skills/vulnerability-patterns/weak-sources-randomness/SKILL.md +8 -1
- package/skills/vulnerability-patterns/weird-tokens/SKILL.md +10 -0
- package/skills/vulnerability-patterns/zero-address-misconfiguration/SKILL.md +48 -0
- package/src/agents/argus-prompt.ts +24 -7
- package/src/agents/pythia-prompt.ts +3 -4
- package/src/agents/scribe-prompt.ts +7 -2
- package/src/agents/sentinel-prompt.ts +32 -3
- package/src/cli/cli-program.ts +29 -26
- package/src/cli/commands/check-skills.ts +135 -0
- package/src/cli/commands/doctor.ts +48 -26
- package/src/cli/commands/init.ts +5 -3
- package/src/cli/commands/install.ts +7 -5
- package/src/cli/commands/lint-skills.ts +16 -12
- package/src/cli/index.ts +5 -5
- package/src/cli/types.ts +3 -3
- package/src/config/index.ts +1 -1
- package/src/config/loader.ts +4 -6
- package/src/config/schema.ts +4 -5
- package/src/config/types.ts +2 -2
- package/src/constants/defaults.ts +2 -0
- package/src/create-hooks.ts +145 -34
- package/src/create-managers.ts +10 -8
- package/src/create-tools.ts +13 -9
- package/src/features/background-agent/background-manager.ts +93 -87
- package/src/features/background-agent/index.ts +1 -1
- package/src/features/context-monitor/context-monitor.ts +3 -3
- package/src/features/context-monitor/index.ts +2 -2
- package/src/features/error-recovery/session-recovery.ts +2 -4
- package/src/features/error-recovery/tool-error-recovery.ts +12 -7
- package/src/features/index.ts +5 -5
- package/src/features/persistent-state/audit-state-manager.ts +143 -60
- package/src/features/persistent-state/global-run-index.ts +38 -0
- package/src/features/persistent-state/index.ts +1 -1
- package/src/features/persistent-state/run-journal.ts +86 -0
- package/src/hooks/config-handler.ts +28 -11
- package/src/hooks/context-budget.ts +2 -5
- package/src/hooks/event-hook.ts +47 -23
- package/src/hooks/hook-system.ts +4 -4
- package/src/hooks/index.ts +5 -5
- package/src/hooks/knowledge-sync-hook.ts +18 -21
- package/src/hooks/recon-context-builder.ts +2 -2
- package/src/hooks/safe-create-hook.ts +6 -7
- package/src/hooks/tool-tracking-hook.ts +104 -50
- package/src/hooks/types.ts +2 -1
- package/src/index.ts +23 -36
- package/src/knowledge/retry.ts +22 -22
- package/src/knowledge/scvd-client.ts +88 -95
- package/src/knowledge/scvd-errors.ts +35 -35
- package/src/knowledge/scvd-index.ts +78 -80
- package/src/knowledge/scvd-sync.ts +106 -101
- package/src/managers/index.ts +1 -1
- package/src/managers/types.ts +19 -14
- package/src/plugin-interface.ts +7 -9
- package/src/shared/binary-utils.ts +44 -35
- package/src/shared/deep-merge.ts +55 -36
- package/src/shared/file-utils.ts +21 -19
- package/src/shared/index.ts +11 -5
- package/src/shared/jsonc-parser.ts +123 -28
- package/src/shared/logger.ts +16 -3
- package/src/shared/project-utils.ts +30 -0
- package/src/skills/analysis/cluster.ts +414 -0
- package/src/skills/analysis/gates.ts +227 -0
- package/src/skills/analysis/index.ts +33 -0
- package/src/skills/analysis/normalize.ts +217 -0
- package/src/skills/analysis/similarity.ts +224 -0
- package/src/skills/argus-skill-resolver.ts +17 -6
- package/src/skills/skill-schema.ts +11 -10
- package/src/solodit-lifecycle.ts +202 -0
- package/src/state/audit-state.ts +8 -8
- package/src/state/finding-store.ts +68 -55
- package/src/state/types.ts +88 -67
- package/src/tools/argus-skill-load-tool.ts +12 -7
- package/src/tools/contract-analyzer-tool.ts +60 -77
- package/src/tools/forge-coverage-tool.ts +226 -0
- package/src/tools/forge-fuzz-tool.ts +127 -127
- package/src/tools/forge-test-tool.ts +153 -157
- package/src/tools/gas-analysis-tool.ts +264 -0
- package/src/tools/pattern-checker-tool.ts +185 -190
- package/src/tools/pattern-loader.ts +5 -111
- package/src/tools/proxy-detection-tool.ts +224 -0
- package/src/tools/report-generator-tool.ts +268 -200
- package/src/tools/slither-tool.ts +266 -218
- package/src/tools/solodit-search-tool.ts +216 -119
- package/src/tools/sync-knowledge-tool.ts +7 -11
- package/src/utils/audit-artifact-detector.ts +28 -29
- package/src/utils/dependency-scanner.ts +37 -37
- package/src/utils/project-detector.ts +111 -124
- package/src/utils/solidity-parser.ts +103 -74
- package/skills/patterns/access-control.yaml +0 -31
- package/skills/patterns/erc4626.yaml +0 -29
- package/skills/patterns/flash-loan.yaml +0 -20
- package/skills/patterns/oracle.yaml +0 -30
- package/skills/patterns/proxy.yaml +0 -30
- package/skills/patterns/reentrancy.yaml +0 -30
- package/skills/patterns/signature.yaml +0 -31
- package/src/hooks/event-hook-v2.ts +0 -99
- package/src/state/plugin-state.ts +0 -14
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: proxy-vulnerabilities
|
|
3
|
+
description: Proxy pattern vulnerabilities including storage collision, uninitialized proxy, and function selector clash
|
|
4
|
+
category: vulnerability-pattern
|
|
5
|
+
pattern_category: proxy
|
|
6
|
+
detection_rules:
|
|
7
|
+
- regex: 'delegatecall|IMPLEMENTATION_SLOT'
|
|
8
|
+
severity: Critical
|
|
9
|
+
confidence: Medium
|
|
10
|
+
swc: SWC-112
|
|
11
|
+
description: Delegatecall or implementation slot usage - potential storage collision between proxy and implementation contracts if storage layouts diverge
|
|
12
|
+
- regex: '_disableInitializers|initializer'
|
|
13
|
+
severity: High
|
|
14
|
+
confidence: Medium
|
|
15
|
+
description: Proxy initialization pattern detected - verify implementation contract calls _disableInitializers() in constructor and proxy calls initialize()
|
|
16
|
+
- regex: 'fallback\(\)|receive\(\).*delegatecall'
|
|
17
|
+
severity: Medium
|
|
18
|
+
confidence: Low
|
|
19
|
+
description: Fallback or receive function with delegatecall - risk of function selector clash between proxy admin functions and implementation functions
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Proxy Vulnerability Patterns
|
|
23
|
+
|
|
24
|
+
## Overview
|
|
25
|
+
|
|
26
|
+
Upgradeable proxy systems trade immutability for maintainability. That trade introduces a second security model: execution context and storage live in the proxy, while logic lives in implementations reached through `delegatecall`. Any mismatch between expected and actual layout, initialization state, or function routing can grant attackers full control.
|
|
27
|
+
|
|
28
|
+
Most proxy exploits are not complex cryptographic breaks. They are integration failures across deployment scripts, upgrade procedures, and ABI boundaries. A proxy setup can be technically standards-compliant and still vulnerable if governance, initialization, or selector design is weak.
|
|
29
|
+
|
|
30
|
+
Auditing proxies requires system-level reasoning across deployment transactions, upgrade authority, storage layout evolution, and fallback behavior. Reviewing only implementation code misses critical attack surface in proxy shell contracts and admin operations.
|
|
31
|
+
|
|
32
|
+
## Key Attack Vectors
|
|
33
|
+
|
|
34
|
+
- Storage collision between proxy slots and implementation variables.
|
|
35
|
+
- Uninitialized implementation contracts that an attacker can initialize directly.
|
|
36
|
+
- Uninitialized proxies where initializer can be called by arbitrary users.
|
|
37
|
+
- Selector clashes between admin functions and delegated user functions.
|
|
38
|
+
- Unsafe fallback routing that forwards admin calls into implementation logic.
|
|
39
|
+
- Upgrade functions lacking role checks, timelocks, or upgrade validation.
|
|
40
|
+
- Incompatible storage layout changes during upgrades.
|
|
41
|
+
- Missing rollback testing for UUPS upgrades.
|
|
42
|
+
- Delegatecall to untrusted implementation addresses.
|
|
43
|
+
|
|
44
|
+
### Typical Takeover Sequence (Uninitialized Proxy)
|
|
45
|
+
|
|
46
|
+
1. Proxy is deployed without atomic initialization.
|
|
47
|
+
2. Initializer remains externally callable.
|
|
48
|
+
3. Attacker calls `initialize()` first and becomes owner/admin.
|
|
49
|
+
4. Attacker upgrades implementation or drains managed assets.
|
|
50
|
+
5. Team loses control of proxy governance path.
|
|
51
|
+
|
|
52
|
+
### Typical Storage Collision Sequence
|
|
53
|
+
|
|
54
|
+
1. New implementation reorders or inserts state variables incorrectly.
|
|
55
|
+
2. Critical admin/value fields map to unexpected slots.
|
|
56
|
+
3. Routine function calls mutate sensitive proxy state.
|
|
57
|
+
4. Access control breaks or funds accounting corrupts.
|
|
58
|
+
5. Recovery requires emergency upgrade or migration.
|
|
59
|
+
|
|
60
|
+
## Detection Heuristics
|
|
61
|
+
|
|
62
|
+
### Proxy Primitive Identification
|
|
63
|
+
|
|
64
|
+
- Detect `delegatecall`, `fallback`, `receive`, and implementation slot constants.
|
|
65
|
+
- Identify whether system is Transparent, UUPS, Beacon, or custom hybrid.
|
|
66
|
+
- Enumerate upgrade entry points and admin authority graph.
|
|
67
|
+
- Verify proxy and implementation compile with compatible storage assumptions.
|
|
68
|
+
|
|
69
|
+
### Initialization Safety Checks
|
|
70
|
+
|
|
71
|
+
- Confirm implementation constructor calls `_disableInitializers()`.
|
|
72
|
+
- Ensure proxy initialization happens in deployment transaction.
|
|
73
|
+
- Verify initializer functions are single-use and role-gated where required.
|
|
74
|
+
- Check reinitializer versioning for upgrade modules.
|
|
75
|
+
|
|
76
|
+
### Storage Layout Safety Checks
|
|
77
|
+
|
|
78
|
+
- Compare storage layout before and after upgrade.
|
|
79
|
+
- Ensure inherited contracts preserve variable ordering.
|
|
80
|
+
- Validate use of storage gaps (`uint256[50] private __gap`) where applicable.
|
|
81
|
+
- Confirm EIP-1967 slots are used for implementation/admin/beacon pointers.
|
|
82
|
+
|
|
83
|
+
### Selector Clash and Routing Checks
|
|
84
|
+
|
|
85
|
+
- Enumerate proxy admin selectors and implementation public selectors.
|
|
86
|
+
- Detect collisions where admin and user paths share selectors.
|
|
87
|
+
- Ensure Transparent proxy blocks admin from falling through to implementation.
|
|
88
|
+
- For UUPS, verify `proxiableUUID` and upgrade authorization checks.
|
|
89
|
+
|
|
90
|
+
### Concrete Code Smells
|
|
91
|
+
|
|
92
|
+
```solidity
|
|
93
|
+
fallback() external payable {
|
|
94
|
+
(bool ok,) = implementation.delegatecall(msg.data);
|
|
95
|
+
require(ok);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```solidity
|
|
100
|
+
function initialize(address owner_) external initializer {
|
|
101
|
+
owner = owner_; // callable by first caller if not atomically initialized
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```solidity
|
|
106
|
+
bytes32 internal constant IMPLEMENTATION_SLOT =
|
|
107
|
+
keccak256("implementation"); // non-standard slot risks conflicts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Audit Checklist
|
|
111
|
+
|
|
112
|
+
- Is every proxy deployed with initialization calldata in the same transaction?
|
|
113
|
+
- Are implementation contracts permanently non-initializable post-deploy?
|
|
114
|
+
- Are storage layout diffs reviewed and enforced in CI before upgrade?
|
|
115
|
+
- Are upgrade operations timelocked, multisig-gated, and event-rich?
|
|
116
|
+
- Are selector collisions tested against full ABI surface?
|
|
117
|
+
|
|
118
|
+
## Prevention
|
|
119
|
+
|
|
120
|
+
### Use Battle-Tested Standards
|
|
121
|
+
|
|
122
|
+
- Prefer OpenZeppelin TransparentUpgradeableProxy or ERC1967/UUPS implementations.
|
|
123
|
+
- Use EIP-1967 storage slots and audited upgrade libraries.
|
|
124
|
+
- Avoid custom proxy shells unless necessary for protocol-specific requirements.
|
|
125
|
+
- Keep proxy logic minimal and immutable where possible.
|
|
126
|
+
|
|
127
|
+
### Initialization Hardening
|
|
128
|
+
|
|
129
|
+
- Call `_disableInitializers()` in implementation constructor.
|
|
130
|
+
- Supply initializer calldata during proxy deployment.
|
|
131
|
+
- Restrict or remove external initializer exposure after setup.
|
|
132
|
+
- Document and test upgrade-time reinitializer sequences.
|
|
133
|
+
|
|
134
|
+
### Upgrade Governance Controls
|
|
135
|
+
|
|
136
|
+
- Gate upgrades behind multisig + timelock.
|
|
137
|
+
- Require explicit implementation validation (`code.length > 0`, interface checks).
|
|
138
|
+
- Emit events for proposed and executed upgrades.
|
|
139
|
+
- Maintain emergency pause/rollback procedures with clear authority boundaries.
|
|
140
|
+
|
|
141
|
+
### Selector and Routing Safety
|
|
142
|
+
|
|
143
|
+
- For Transparent proxies, separate admin and user call paths strictly.
|
|
144
|
+
- For UUPS proxies, enforce `_authorizeUpgrade` with robust roles.
|
|
145
|
+
- Run selector collision scans in CI against proxy and implementation ABIs.
|
|
146
|
+
- Avoid exposing overlapping administrative selectors in implementations.
|
|
147
|
+
|
|
148
|
+
### Hardened Pattern Example
|
|
149
|
+
|
|
150
|
+
```solidity
|
|
151
|
+
contract Impl is Initializable, UUPSUpgradeable, OwnableUpgradeable {
|
|
152
|
+
constructor() {
|
|
153
|
+
_disableInitializers();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function initialize(address owner_) external initializer {
|
|
157
|
+
__Ownable_init(owner_);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _authorizeUpgrade(address newImplementation)
|
|
161
|
+
internal
|
|
162
|
+
override
|
|
163
|
+
onlyOwner
|
|
164
|
+
{}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Operational Practices
|
|
169
|
+
|
|
170
|
+
- Store upgrade runbooks with preflight and postflight checks.
|
|
171
|
+
- Simulate upgrades on forked state before production execution.
|
|
172
|
+
- Track implementation bytecode hashes and signed release artifacts.
|
|
173
|
+
- Include automated storage-layout regression gates in release pipelines.
|
|
174
|
+
|
|
175
|
+
## Real-World Examples
|
|
176
|
+
|
|
177
|
+
### Proxy Initialization Incidents
|
|
178
|
+
|
|
179
|
+
- Pattern: implementation or proxy left uninitialized.
|
|
180
|
+
- Impact: attacker claims ownership role and controls upgrade path.
|
|
181
|
+
- Lesson: initialization must be atomic, single-use, and scripted.
|
|
182
|
+
|
|
183
|
+
### Storage Layout Corruption Cases
|
|
184
|
+
|
|
185
|
+
- Pattern: variable order/type changes between implementation versions.
|
|
186
|
+
- Impact: admin slots and balances are overwritten unintentionally.
|
|
187
|
+
- Lesson: treat storage layout as immutable contract between versions.
|
|
188
|
+
|
|
189
|
+
### Selector Clash Risk in Custom Proxies
|
|
190
|
+
|
|
191
|
+
- Pattern: fallback delegatecalls overlap with proxy admin selectors.
|
|
192
|
+
- Impact: privileged calls routed incorrectly or user calls blocked.
|
|
193
|
+
- Lesson: transparent separation and selector audits are mandatory.
|
|
194
|
+
|
|
195
|
+
### Pattern-to-Impact Mapping
|
|
196
|
+
|
|
197
|
+
- `storage-collision` -> critical state corruption and privilege compromise.
|
|
198
|
+
- `uninitialized-proxy` -> hostile initialization and upgrade takeover.
|
|
199
|
+
- `selector-clash` -> call-path confusion and admin bypass risk.
|
|
200
|
+
|
|
201
|
+
## References
|
|
202
|
+
|
|
203
|
+
- SWC-112 (Delegatecall to untrusted callee): https://swcregistry.io/docs/SWC-112
|
|
204
|
+
- OpenZeppelin Upgrades docs: https://docs.openzeppelin.com/upgrades-plugins/1.x/
|
|
205
|
+
- OpenZeppelin proxy patterns: https://docs.openzeppelin.com/contracts/4.x/api/proxy
|
|
206
|
+
- EIP-1967 proxy storage slots: https://eips.ethereum.org/EIPS/eip-1967
|
|
207
|
+
- EIP-1822 (UUPS): https://eips.ethereum.org/EIPS/eip-1822
|
|
208
|
+
- ConsenSys best practices for upgradeability: https://consensys.github.io/smart-contract-best-practices/
|
|
209
|
+
- Trail of Bits proxy audit notes: https://blog.trailofbits.com/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reentrancy
|
|
3
3
|
description: Reentrancy attack patterns, real incidents, and defensive coding checks for Solidity protocols.
|
|
4
|
+
pattern_category: reentrancy
|
|
4
5
|
source_url: https://github.com/kadenzipfel/smart-contract-vulnerabilities
|
|
5
6
|
source_license: MIT
|
|
6
7
|
imported_at: "2025-01-15T00:00:00Z"
|
|
@@ -14,6 +15,14 @@ detection_rules:
|
|
|
14
15
|
severity: Medium
|
|
15
16
|
confidence: Medium
|
|
16
17
|
description: Low-level external call that can open a reentrancy window
|
|
18
|
+
- regex: '\.(transfer|transferFrom)\('
|
|
19
|
+
severity: Medium
|
|
20
|
+
confidence: Medium
|
|
21
|
+
description: ERC-20 token transfer that may precede state changes — reentrancy via token callback hooks (ERC-777, ERC-1155)
|
|
22
|
+
- regex: '(external|public)\s.*\{[^}]*\.call'
|
|
23
|
+
severity: High
|
|
24
|
+
confidence: Low
|
|
25
|
+
description: Public/external function with low-level call — potential cross-function reentrancy if shared state is read by other functions
|
|
17
26
|
---
|
|
18
27
|
|
|
19
28
|
<!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: shadowing-state-variables
|
|
3
|
-
description: - Contract inherits from one or more parent contracts
|
|
3
|
+
description: '- Contract inherits from one or more parent contracts'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'override\b'
|
|
7
|
+
severity: Informational
|
|
8
|
+
confidence: Low
|
|
9
|
+
swc: SWC-119
|
|
10
|
+
description: Override-heavy inheritance context worth shadowing review
|
|
4
11
|
---
|
|
5
12
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
13
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: share-accounting-desynchronization
|
|
3
|
+
description: "Asset/share systems drift out of sync across views, transfers, or reward logic, enabling value leakage, bypasses, or protocol lockups."
|
|
4
|
+
category: vulnerability-pattern
|
|
5
|
+
pattern_category: erc4626
|
|
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: "(sharesToToken|tokenToShares|previewWrap|previewUnwrap|accRewardPerShare|totalShares|totalSupply)"
|
|
11
|
+
severity: "High"
|
|
12
|
+
description: "Share conversion and accumulator surfaces prone to state drift"
|
|
13
|
+
- regex: "(round|mulDiv|division by zero|overflow|underflow)"
|
|
14
|
+
severity: "Medium"
|
|
15
|
+
description: "Numerical conditions that amplify desynchronization impact"
|
|
16
|
+
---
|
|
17
|
+
<!-- Source: BailSec audit reports (CC0) -->
|
|
18
|
+
|
|
19
|
+
# Share Accounting Desynchronization Vulnerabilities
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
Share-accounting desynchronization appears when a protocol tracks ownership in shares but exposes user actions, approvals, rewards, or integrations in asset-denominated values without guaranteed synchronization. If share supply, token supply, and fee accrual are updated at different times or with inconsistent caps, attackers and edge cases can exploit the mismatch to bypass approvals, drain value, lock funds, or break reward accounting.
|
|
23
|
+
|
|
24
|
+
Unlike a single arithmetic bug, this is a system-level failure of consistency across view logic, state updates, and transfer semantics.
|
|
25
|
+
|
|
26
|
+
## Common Patterns
|
|
27
|
+
- Approval consumption and transfer amount are evaluated in different units.
|
|
28
|
+
- View functions use theoretical future supply while state-changing paths use capped or delayed supply updates.
|
|
29
|
+
- Reward accumulators assume minted fees that are not actually minted.
|
|
30
|
+
- Rounding strategy differs across conversion helpers, causing exploitable drift in repeated operations.
|
|
31
|
+
|
|
32
|
+
## Detection Heuristics
|
|
33
|
+
- Map all conversions between shares and assets, then verify consistent rounding direction by context.
|
|
34
|
+
- Compare view-only paths (`pending`, `preview`, `realBalance`) against state-changing mint/burn/update behavior.
|
|
35
|
+
- Check behavior when fee collector address changes, updates are delayed, or supply caps are hit.
|
|
36
|
+
- Fuzz with long periods of inactivity, then sudden updates to detect discontinuities.
|
|
37
|
+
|
|
38
|
+
## Examples from Audits
|
|
39
|
+
- Share transfer path that could bypass token-amount approval checks under specific conversion outcomes.
|
|
40
|
+
- Reward preview functions allocating value from uncapped or unminted fees, creating inconsistent accumulator states.
|
|
41
|
+
- Systems where stale supply updates or abrupt fee-recipient changes altered debase/reward behavior and destabilized accounting.
|
|
42
|
+
|
|
43
|
+
## Remediation
|
|
44
|
+
Adopt a single canonical accounting model and centralize conversions in audited helper functions with documented rounding policy. Enforce that view and state paths share the same cap logic and fee-mint assumptions. Add invariant tests ensuring `assets <-> shares` coherence under updates, pauses, and collector changes. When conversions can become stale, force synchronization before sensitive operations or require bounded slippage from callers. This reduces drift accumulation and makes behavior predictable for integrations.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: signature-malleability
|
|
3
|
-
description:
|
|
3
|
+
description: "Contract uses ECDSA signatures for authorization or deduplication"
|
|
4
|
+
pattern_category: signature
|
|
4
5
|
detection_rules:
|
|
5
6
|
- regex: 'ecrecover'
|
|
6
7
|
severity: Medium
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stateful-parameter-update-drift
|
|
3
|
+
description: "Changing live protocol parameters without synchronizing accrued state creates hindsight effects, unfair allocations, or broken invariants."
|
|
4
|
+
category: vulnerability-pattern
|
|
5
|
+
pattern_category: logic-error
|
|
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[A-Z][A-Za-z0-9_]*\\(.*\\)"
|
|
11
|
+
severity: "Medium"
|
|
12
|
+
description: "State-changing parameter setter that may require pre-update synchronization"
|
|
13
|
+
- regex: "(lastUpdate|pending|accrued|epoch|index|reward|supply).*(set|change|update)"
|
|
14
|
+
severity: "High"
|
|
15
|
+
description: "Potential hindsight impact when mutable parameters affect accrued accounting"
|
|
16
|
+
---
|
|
17
|
+
<!-- Source: BailSec audit reports (CC0) -->
|
|
18
|
+
|
|
19
|
+
# Stateful Parameter Update Drift Vulnerabilities
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
Protocols with time-based accrual (fees, rebases, emissions, yield drips) often expose governance or admin setters that modify core parameters while accrual windows are still open. If the contract does not settle or checkpoint state before applying the new value, the update retroactively changes historical accounting. This creates hindsight effects: users can gain or lose value for periods that should already be fixed.
|
|
23
|
+
|
|
24
|
+
The vulnerability is not just governance centralization. Even trusted governance can unintentionally trigger unfair redistribution or lockups when parameter updates are applied to stale state.
|
|
25
|
+
|
|
26
|
+
## Common Patterns
|
|
27
|
+
- Mutable fee collector or tax parameter changed without first syncing pending accrual.
|
|
28
|
+
- Unstake tax, reward rate, or epoch frequency updates affecting already elapsed time.
|
|
29
|
+
- Toggle-style parameters (`address(0)` sentinel, pause/unpause) that alter future and past calculations simultaneously.
|
|
30
|
+
- Setter functions that bypass the same accounting hooks used by normal user actions.
|
|
31
|
+
|
|
32
|
+
## Detection Heuristics
|
|
33
|
+
- For each admin setter, identify all variables that depend on elapsed time since last update.
|
|
34
|
+
- Verify setters call the same `_update*`, `_accrue*`, or checkpoint routines as user-facing flows.
|
|
35
|
+
- Test state transitions with long inactivity windows and then a single governance change.
|
|
36
|
+
- Check whether parameter changes can reorder who receives already-accrued rewards.
|
|
37
|
+
|
|
38
|
+
## Examples from Audits
|
|
39
|
+
- Fee-collector changes that prevented expected debasing in hindsight or triggered abrupt catch-up effects.
|
|
40
|
+
- Tax parameter updates that applied to previously elapsed yield windows, redistributing value unexpectedly.
|
|
41
|
+
- Configuration changes that could move protocol behavior into disruptive states immediately after activation.
|
|
42
|
+
|
|
43
|
+
## Remediation
|
|
44
|
+
Require a deterministic pre-update checkpoint in every setter that influences accrual math. Apply parameter changes only after accrued state is finalized to the current timestamp or epoch boundary. Where governance changes are sensitive, add delay and staged execution with explicit before/after snapshots. Include invariant tests asserting that total distributable value is conserved across parameter changes and that historical periods are not recomputed with new settings.
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: unbounded-return-data
|
|
3
|
-
description: - Contract makes a low-level `.call()` to an untrusted or user-specified address
|
|
3
|
+
description: '- Contract makes a low-level `.call()` to an untrusted or user-specified address'
|
|
4
|
+
pattern_category: dos
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '\.call\(.*\)'
|
|
7
|
+
severity: Low
|
|
8
|
+
confidence: Low
|
|
9
|
+
swc: SWC-110
|
|
10
|
+
description: Low-level call paths may copy attacker-controlled return data
|
|
11
|
+
- regex: 'returndatasize'
|
|
12
|
+
severity: Medium
|
|
13
|
+
confidence: Medium
|
|
14
|
+
description: Return-data handling path that warrants bounded-copy checks
|
|
4
15
|
---
|
|
5
16
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
17
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: unchecked-return-values
|
|
3
|
-
description:
|
|
3
|
+
description: "Contract uses low-level calls: .call(), .send(), or .delegatecall()"
|
|
4
|
+
pattern_category: logic-error
|
|
4
5
|
detection_rules:
|
|
5
6
|
- regex: '\.call\{'
|
|
6
7
|
severity: Medium
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: unencrypted-private-data-on-chain
|
|
3
|
-
description: - Sensitive data (passwords, secrets, private keys, game answers) is stored in contract storage
|
|
3
|
+
description: '- Sensitive data (passwords, secrets, private keys, game answers) is stored in contract storage'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '(private|internal)\s+(uint|address|bytes|string)\s+\w*(secret|password|key|pin|seed)\w*'
|
|
7
|
+
severity: Medium
|
|
8
|
+
confidence: Low
|
|
9
|
+
swc: SWC-136
|
|
10
|
+
description: Sensitive identifier names stored in contract state
|
|
4
11
|
---
|
|
5
12
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
13
|
|
|
@@ -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
|
|
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
|
|