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.
- package/AGENTS.md +3 -3
- package/README.md +229 -13
- package/package.json +37 -8
- package/skills/INVENTORY.md +88 -57
- package/skills/README.md +72 -6
- 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/checklists/cyfrin-defi-core/SKILL.md +3 -0
- package/skills/manifests/cyfrin.json +16 -0
- package/skills/manifests/defifofum.json +25 -0
- package/skills/manifests/kadenzipfel.json +48 -0
- package/skills/manifests/scvd.json +9 -0
- package/skills/manifests/smartbugs.json +9 -0
- package/skills/manifests/solodit.json +9 -0
- package/skills/manifests/sunweb3sec.json +9 -0
- package/skills/manifests/trailofbits.json +9 -0
- package/skills/methodology/audit-workflow/SKILL.md +3 -0
- package/skills/protocol-patterns/amm-dex/SKILL.md +3 -0
- package/skills/references/exploit-reference/SKILL.md +3 -0
- package/skills/vulnerability-patterns/access-control/SKILL.md +27 -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 +8 -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 +8 -1
- package/skills/vulnerability-patterns/dos-gas-limit/SKILL.md +8 -1
- package/skills/vulnerability-patterns/dos-revert/SKILL.md +14 -1
- 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 +13 -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 +22 -0
- package/skills/vulnerability-patterns/outdated-compiler-version/SKILL.md +8 -1
- package/skills/vulnerability-patterns/overflow-underflow/SKILL.md +11 -1
- package/skills/vulnerability-patterns/proxy-vulnerabilities/SKILL.md +209 -0
- package/skills/vulnerability-patterns/reentrancy/SKILL.md +22 -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 +11 -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 +13 -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 +27 -10
- package/src/agents/pythia-prompt.ts +7 -8
- package/src/agents/scribe-prompt.ts +10 -5
- package/src/agents/sentinel-prompt.ts +36 -7
- package/src/cli/cli-output.ts +16 -0
- package/src/cli/cli-program.ts +29 -22
- package/src/cli/commands/check-skills.ts +135 -0
- package/src/cli/commands/doctor.ts +303 -23
- package/src/cli/commands/init.ts +8 -6
- package/src/cli/commands/install.ts +10 -8
- package/src/cli/commands/lint-skills.ts +118 -0
- package/src/cli/index.ts +5 -5
- package/src/cli/tui-prompts.ts +4 -2
- 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 +6 -5
- package/src/config/types.ts +2 -2
- package/src/constants/defaults.ts +2 -0
- package/src/create-hooks.ts +225 -29
- package/src/create-managers.ts +10 -8
- package/src/create-tools.ts +14 -8
- 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 +79 -19
- package/src/features/index.ts +5 -5
- package/src/features/persistent-state/audit-state-manager.ts +158 -52
- 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/agent-tracker.ts +53 -0
- package/src/hooks/compaction-hook.ts +46 -37
- package/src/hooks/config-handler.ts +31 -11
- package/src/hooks/context-budget.ts +42 -0
- package/src/hooks/event-hook.ts +48 -23
- package/src/hooks/hook-system.ts +4 -4
- package/src/hooks/index.ts +5 -5
- package/src/hooks/knowledge-sync-hook.ts +19 -21
- package/src/hooks/recon-context-builder.ts +66 -0
- package/src/hooks/safe-create-hook.ts +9 -11
- package/src/hooks/system-prompt-hook.ts +128 -0
- package/src/hooks/tool-tracking-hook.ts +162 -29
- package/src/hooks/types.ts +2 -1
- package/src/index.ts +23 -13
- package/src/knowledge/retry.ts +53 -0
- package/src/knowledge/scvd-client.ts +103 -83
- package/src/knowledge/scvd-errors.ts +89 -0
- package/src/knowledge/scvd-index.ts +110 -62
- package/src/knowledge/scvd-sync.ts +223 -47
- package/src/knowledge/source-manifest.ts +102 -0
- package/src/managers/index.ts +1 -1
- package/src/managers/types.ts +19 -14
- package/src/plugin-interface.ts +19 -8
- package/src/shared/binary-utils.ts +44 -34
- 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 +91 -17
- 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 +237 -0
- package/src/skills/skill-schema.ts +99 -0
- package/src/solodit-lifecycle.ts +202 -0
- package/src/state/audit-state.ts +10 -8
- package/src/state/finding-store.ts +68 -55
- package/src/state/types.ts +96 -44
- package/src/tools/argus-skill-load-tool.ts +78 -0
- 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 +206 -167
- package/src/tools/pattern-loader.ts +77 -0
- package/src/tools/pattern-schema.ts +51 -0
- package/src/tools/proxy-detection-tool.ts +224 -0
- package/src/tools/report-generator-tool.ts +333 -142
- package/src/tools/slither-tool.ts +300 -210
- package/src/tools/solodit-search-tool.ts +255 -80
- package/src/tools/sync-knowledge-tool.ts +7 -11
- package/src/utils/audit-artifact-detector.ts +118 -0
- package/src/utils/dependency-scanner.ts +93 -0
- package/src/utils/project-detector.ts +175 -86
- package/src/utils/solidity-parser.ts +112 -67
- package/src/utils/solodit-health.ts +29 -0
- package/src/hooks/event-hook-v2.ts +0 -99
- package/src/state/plugin-state.ts +0 -14
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: incorrect-inheritance-order
|
|
3
|
-
description: - Contract uses multiple inheritance (`is ContractA, ContractB, ...`)
|
|
3
|
+
description: '- Contract uses multiple inheritance (`is ContractA, ContractB, ...`)'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'is\s+\w+\s*,\s*\w+'
|
|
7
|
+
severity: Informational
|
|
8
|
+
confidence: Low
|
|
9
|
+
swc: SWC-125
|
|
10
|
+
description: Multiple inheritance declaration needing linearization review
|
|
4
11
|
---
|
|
5
12
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
13
|
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: insufficient-gas-griefing
|
|
3
|
-
description: - Contract relays or forwards calls on behalf of users (meta-transactions, multisig execution, relayer patterns)
|
|
3
|
+
description: '- Contract relays or forwards calls on behalf of users (meta-transactions, multisig execution, relayer patterns)'
|
|
4
|
+
pattern_category: dos
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '\.call\{gas:'
|
|
7
|
+
severity: Medium
|
|
8
|
+
confidence: Medium
|
|
9
|
+
swc: SWC-126
|
|
10
|
+
description: Caller-controlled gas forwarding can censor relayed execution
|
|
11
|
+
- regex: 'gasleft\(\)'
|
|
12
|
+
severity: Low
|
|
13
|
+
confidence: Low
|
|
14
|
+
description: Gas accounting logic should be checked for griefing resilience
|
|
4
15
|
---
|
|
5
16
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
17
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lack-of-precision
|
|
3
|
-
description: - Contract performs integer arithmetic (division, fee calculations, reward distributions)
|
|
3
|
+
description: '- Contract performs integer arithmetic (division, fee calculations, reward distributions)'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '/\s*\d+\s*\*'
|
|
7
|
+
severity: Low
|
|
8
|
+
confidence: Low
|
|
9
|
+
description: Division-before-multiplication pattern that can truncate precision
|
|
4
10
|
---
|
|
5
11
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
12
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: logic-errors
|
|
3
3
|
description: Protocol logic bug patterns, exploit examples, and invariant-driven review strategies.
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'if\s*\([^)]*&&[^)]*\|\|'
|
|
7
|
+
severity: Informational
|
|
8
|
+
confidence: Low
|
|
9
|
+
description: Mixed boolean operators in one condition warrant logic review
|
|
10
|
+
- regex: 'require\(.*,\s*"'
|
|
11
|
+
severity: Informational
|
|
12
|
+
confidence: Low
|
|
13
|
+
description: Guard clauses can reveal critical business-logic invariants
|
|
4
14
|
---
|
|
5
15
|
|
|
6
16
|
<!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: missing-parameter-bounds
|
|
3
|
+
description: "Protocol parameters are accepted without min/max constraints, allowing invalid or unsafe runtime states."
|
|
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: "function\\s+(set|update|configure|initialize|constructor).*\\{[\\s\\S]{0,400}?(bps|fee|ratio|range|cap|threshold)"
|
|
11
|
+
severity: "Medium"
|
|
12
|
+
description: "Configurable economic parameter likely missing explicit bounds"
|
|
13
|
+
- regex: "require\\(.*<=\\s*(MAX|1e4|10000)"
|
|
14
|
+
severity: "Low"
|
|
15
|
+
description: "Use as a companion check to find setters lacking equivalent guardrails"
|
|
16
|
+
---
|
|
17
|
+
<!-- Source: BailSec audit reports (CC0) -->
|
|
18
|
+
|
|
19
|
+
# Missing Parameter Bounds Vulnerabilities
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
Missing parameter bounds is a recurring configuration-class vulnerability where contracts accept values that violate economic assumptions, arithmetic safety, or protocol UX constraints. Typical examples include BPS percentages above 100%, negative-style behavior encoded in signed ranges, or credit and share thresholds that can be bypassed in one path but enforced in another. The issue is often not immediate code execution risk, but delayed protocol failure, broken accounting, or user-loss scenarios after governance changes.
|
|
23
|
+
|
|
24
|
+
A high-risk variant is validation drift: constructor and setter logic differ, so initial deployment can inject invalid values that runtime mutation would reject (or vice versa). This creates non-obvious states auditors miss when they only inspect one code path.
|
|
25
|
+
|
|
26
|
+
## Common Patterns
|
|
27
|
+
- Constructor omits upper bound checks that exist in a later setter.
|
|
28
|
+
- Setter enforces one invariant but related functions do not re-check post-action states.
|
|
29
|
+
- Signed range parameters increase complexity and permit invalid semantics.
|
|
30
|
+
- Optional token interfaces or assumptions are accepted without compatibility gating.
|
|
31
|
+
|
|
32
|
+
## Detection Heuristics
|
|
33
|
+
- Build a matrix of each mutable parameter: constructor checks, setter checks, and all usage-site assumptions.
|
|
34
|
+
- Flag any economic parameter lacking explicit min/max and unit documentation.
|
|
35
|
+
- Compare pre-state vs post-state constraints on mutating flows (supply/withdraw/rebalance).
|
|
36
|
+
- Review all checks for consistency in BPS, decimals, and scaling conventions.
|
|
37
|
+
|
|
38
|
+
## Examples from Audits
|
|
39
|
+
- Bridge bonus percentage accepted in initialization without enforcing BPS cap, allowing values above 10,000.
|
|
40
|
+
- Fee parameter validated in setter but not in constructor, enabling out-of-range deployment state.
|
|
41
|
+
- Credit and liquidity-related validation logic that was difficult to reason about and left bypass opportunities in adjacent paths.
|
|
42
|
+
|
|
43
|
+
## Remediation
|
|
44
|
+
Define parameter invariants once and reuse them through internal validator functions called by constructor, initializer, setters, and upgrade hooks. Prefer explicit constants (`MIN_*`, `MAX_*`) with unit comments. For safety-critical parameters, add two-step governance updates plus simulation checks before activation. Back this with property tests that fuzz all bounded values and assert protocol invariants remain true after each update. This makes future maintenance safer and prevents silent drift between code paths.
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: missing-protection-signature-replay
|
|
3
|
-
description: - Contract verifies ECDSA signatures for authorization
|
|
3
|
+
description: '- Contract verifies ECDSA signatures for authorization'
|
|
4
|
+
pattern_category: signature
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'ecrecover\('
|
|
7
|
+
severity: Medium
|
|
8
|
+
confidence: High
|
|
9
|
+
swc: SWC-121
|
|
10
|
+
description: Signature recovery path requires nonce, chain, and domain separation checks
|
|
11
|
+
- regex: 'ECDSA\.recover\('
|
|
12
|
+
severity: Medium
|
|
13
|
+
confidence: High
|
|
14
|
+
swc: SWC-121
|
|
15
|
+
description: Library-based signature recovery still needs replay protection fields
|
|
16
|
+
- regex: 'permit\(|signTypedData'
|
|
17
|
+
severity: High
|
|
18
|
+
confidence: Medium
|
|
19
|
+
description: Permit or typed data signing — missing nonce allows signature replay
|
|
4
20
|
---
|
|
5
21
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
22
|
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: msgvalue-loop
|
|
3
|
-
description: - `msg.value` is referenced inside a loop (`for`, `while`) or in a function called multiple times within a single external call
|
|
3
|
+
description: '- `msg.value` is referenced inside a loop (`for`, `while`) or in a function called multiple times within a single external call'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'msg\.value'
|
|
7
|
+
severity: Low
|
|
8
|
+
confidence: Low
|
|
9
|
+
swc: SWC-134
|
|
10
|
+
description: msg.value usage that may be reused across loop iterations
|
|
11
|
+
- regex: '(for|while)\s*\('
|
|
12
|
+
severity: Informational
|
|
13
|
+
confidence: Low
|
|
14
|
+
description: Loop context signal for msg.value reuse review
|
|
4
15
|
---
|
|
5
16
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
17
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: off-by-one
|
|
3
|
-
description: - Contract uses loops with boundary conditions, comparison operators at thresholds, or array index calculations
|
|
3
|
+
description: '- Contract uses loops with boundary conditions, comparison operators at thresholds, or array index calculations'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '\.length\s*-\s*1'
|
|
7
|
+
severity: Low
|
|
8
|
+
confidence: Low
|
|
9
|
+
description: Boundary arithmetic near array length that can hide fence-post mistakes
|
|
4
10
|
---
|
|
5
11
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
12
|
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: oracle-manipulation
|
|
3
3
|
description: Oracle manipulation techniques, case studies, and secure pricing integration controls for DeFi.
|
|
4
|
+
pattern_category: oracle-manipulation
|
|
5
|
+
source_url: https://github.com/kadenzipfel/smart-contract-vulnerabilities
|
|
6
|
+
source_license: MIT
|
|
7
|
+
imported_at: "2025-01-15T00:00:00Z"
|
|
8
|
+
detection_rules:
|
|
9
|
+
- regex: 'latestRoundData'
|
|
10
|
+
severity: Medium
|
|
11
|
+
confidence: High
|
|
12
|
+
swc: SWC-116
|
|
13
|
+
description: Chainlink price reads requiring freshness and sanity checks
|
|
14
|
+
- regex: 'getReserves\('
|
|
15
|
+
severity: High
|
|
16
|
+
confidence: High
|
|
17
|
+
description: AMM reserve spot-price usage vulnerable to manipulation
|
|
18
|
+
- regex: 'observe\(|consult\('
|
|
19
|
+
severity: Medium
|
|
20
|
+
confidence: Medium
|
|
21
|
+
description: TWAP oracle usage — time-weighted average prices can be manipulated via sustained trading pressure
|
|
22
|
+
- regex: 'priceFeed|oracle.*decimals'
|
|
23
|
+
severity: Medium
|
|
24
|
+
confidence: Medium
|
|
25
|
+
description: Oracle price feed with decimal handling — potential decimal mismatch between oracle and token
|
|
4
26
|
---
|
|
5
27
|
|
|
6
28
|
<!-- Source: DeFiFoFum/fofum-solidity-skills (MIT) -->
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: outdated-compiler-version
|
|
3
|
-
description: - Contract is compiled with a Solidity version significantly behind the latest stable release
|
|
3
|
+
description: '- Contract is compiled with a Solidity version significantly behind the latest stable release'
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'pragma solidity 0\.[0-7]\.'
|
|
7
|
+
severity: Informational
|
|
8
|
+
confidence: High
|
|
9
|
+
swc: SWC-102
|
|
10
|
+
description: Solidity pragma pins to an outdated major/minor compiler line
|
|
4
11
|
---
|
|
5
12
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
13
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: overflow-underflow
|
|
3
|
-
description:
|
|
3
|
+
description: Integer overflow and underflow vulnerabilities in Solidity contracts
|
|
4
|
+
pattern_category: logic-error
|
|
5
|
+
source_url: https://github.com/kadenzipfel/smart-contract-vulnerabilities
|
|
6
|
+
source_license: MIT
|
|
7
|
+
imported_at: "2025-01-15T00:00:00Z"
|
|
8
|
+
detection_rules:
|
|
9
|
+
- regex: 'unchecked\s*\{'
|
|
10
|
+
severity: Medium
|
|
11
|
+
confidence: High
|
|
12
|
+
swc: SWC-101
|
|
13
|
+
description: Unchecked arithmetic block requiring manual overflow review
|
|
4
14
|
---
|
|
5
15
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
16
|
|
|
@@ -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,28 @@
|
|
|
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
|
|
5
|
+
source_url: https://github.com/kadenzipfel/smart-contract-vulnerabilities
|
|
6
|
+
source_license: MIT
|
|
7
|
+
imported_at: "2025-01-15T00:00:00Z"
|
|
8
|
+
detection_rules:
|
|
9
|
+
- regex: '\.call\{value:'
|
|
10
|
+
severity: High
|
|
11
|
+
confidence: High
|
|
12
|
+
swc: SWC-107
|
|
13
|
+
description: External value transfer via low-level call before effects
|
|
14
|
+
- regex: '\.call\{.*\}\('
|
|
15
|
+
severity: Medium
|
|
16
|
+
confidence: Medium
|
|
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
|
|
4
26
|
---
|
|
5
27
|
|
|
6
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,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: signature-malleability
|
|
3
|
-
description:
|
|
3
|
+
description: "Contract uses ECDSA signatures for authorization or deduplication"
|
|
4
|
+
pattern_category: signature
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: 'ecrecover'
|
|
7
|
+
severity: Medium
|
|
8
|
+
confidence: High
|
|
9
|
+
description: Raw ecrecover usage needs strict signature normalization checks
|
|
10
|
+
- regex: 'ECDSA'
|
|
11
|
+
severity: Low
|
|
12
|
+
confidence: Medium
|
|
13
|
+
description: Signature verification path to inspect for nonce and domain separation
|
|
4
14
|
---
|
|
5
15
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
16
|
|
|
@@ -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,18 @@
|
|
|
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
|
|
5
|
+
detection_rules:
|
|
6
|
+
- regex: '\.call\{'
|
|
7
|
+
severity: Medium
|
|
8
|
+
confidence: Medium
|
|
9
|
+
swc: SWC-104
|
|
10
|
+
description: Low-level call usage requires explicit success handling
|
|
11
|
+
- regex: '\.send\('
|
|
12
|
+
severity: Medium
|
|
13
|
+
confidence: High
|
|
14
|
+
swc: SWC-104
|
|
15
|
+
description: send return value can fail silently if unchecked
|
|
4
16
|
---
|
|
5
17
|
<!-- Source: kadenzipfel/smart-contract-vulnerabilities (MIT) -->
|
|
6
18
|
|
|
@@ -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
|
|