forked from DeborahOlaboye/auditForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-report.json
More file actions
224 lines (224 loc) · 9.54 KB
/
Copy pathtest-report.json
File metadata and controls
224 lines (224 loc) · 9.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{
"id": "audit-1760820281915-6ca2z0cgp",
"timestamp": "2025-10-18T20:44:41.915Z",
"contractName": "VulnerableBank",
"sourceCode": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * Vulnerable Contract: Reentrancy Attack\n * This contract is intentionally vulnerable for testing purposes\n */\ncontract VulnerableBank {\n mapping(address => uint256) public balances;\n\n function deposit() public payable {\n balances[msg.sender] += msg.value;\n }\n\n // VULNERABLE: External call before state update\n function withdraw() public {\n uint256 balance = balances[msg.sender];\n require(balance > 0, \"Insufficient balance\");\n\n // Vulnerable to reentrancy - state changed after external call\n (bool success, ) = msg.sender.call{value: balance}(\"\");\n require(success, \"Transfer failed\");\n\n balances[msg.sender] = 0; // State update AFTER external call\n }\n\n function getBalance() public view returns (uint256) {\n return balances[msg.sender];\n }\n}\n",
"executiveSummary": {
"totalVulnerabilities": 9,
"criticalCount": 0,
"highCount": 3,
"mediumCount": 1,
"lowCount": 2,
"infoCount": 3,
"overallRiskScore": 8.3,
"deploymentRecommendation": "DO_NOT_DEPLOY",
"topConcerns": [
"Potential Integer Overflow/Underflow",
"Missing Access Control",
"Front-Running Vulnerability"
]
},
"vulnerabilities": [
{
"id": "IO-01",
"name": "Potential Integer Overflow/Underflow",
"severity": "HIGH",
"description": "Arithmetic operations may be vulnerable to overflow/underflow",
"location": {
"file": "contract.sol",
"line": 1,
"column": 0
},
"technicalExplanation": "Solidity versions prior to 0.8.0 do not automatically check for integer overflow and underflow. Unchecked arithmetic can wrap around, leading to unexpected behavior.",
"exploitScenario": "An attacker could manipulate arithmetic operations to overflow/underflow values, potentially bypassing balance checks or manipulating token supplies.",
"recommendation": "Upgrade to Solidity 0.8.0+ which has built-in overflow/underflow checking, or use SafeMath library for older versions.",
"codeSnippet": "// Vulnerable (Solidity < 0.8.0):\nuint256 balance = 0;\nbalance = balance - 1; // underflows to max uint256\n\n// Fixed (Solidity >= 0.8.0):\n// Automatically reverts on overflow/underflow\n\n// Or use SafeMath:\nusing SafeMath for uint256;\nbalance = balance.sub(1); // safely reverts",
"references": [
"SWC-101: Integer Overflow and Underflow",
"CWE-190: Integer Overflow",
"CWE-191: Integer Underflow"
],
"confidence": 0.7
},
{
"id": "AC-01",
"name": "Missing Access Control",
"severity": "HIGH",
"description": "Critical function \"withdraw\" is public without access control",
"location": {
"file": "contract.sol",
"line": 16,
"column": 4,
"functionName": "withdraw"
},
"technicalExplanation": "Functions that modify critical contract state or handle funds should be restricted to authorized addresses only.",
"exploitScenario": "Any user can call withdraw() and perform privileged operations, potentially draining funds or taking over the contract.",
"recommendation": "Add access control modifier such as \"onlyOwner\" or implement role-based access control.",
"codeSnippet": "// Vulnerable:\nfunction withdraw() public {\n // critical operation\n}\n\n// Fixed:\nfunction withdraw() public onlyOwner {\n // critical operation\n}",
"references": [
"SWC-105: Unprotected Ether Withdrawal",
"CWE-284: Improper Access Control"
],
"confidence": 0.9
},
{
"id": "FR-01",
"name": "Front-Running Vulnerability",
"severity": "HIGH",
"description": "Price or state changes visible before execution can be front-run",
"location": {
"file": "contract.sol",
"line": 11,
"column": 4
},
"technicalExplanation": "Detected usage of function deposit() public payable",
"exploitScenario": "See references for potential exploits",
"recommendation": "Use commit-reveal scheme for sensitive operations",
"codeSnippet": " mapping(address => uint256) public balances;\n\n function deposit() public payable {\n balances[msg.sender] += msg.value;\n }",
"references": [
"Front-Running",
"MEV"
],
"confidence": 0.75
},
{
"id": "FP-01",
"name": "Floating Pragma",
"severity": "MEDIUM",
"description": "Pragma version not locked to specific compiler version",
"location": {
"file": "contract.sol",
"line": 2,
"column": 0
},
"technicalExplanation": "Detected usage of pragma solidity ^",
"exploitScenario": "See references for potential exploits",
"recommendation": "Lock pragma to specific Solidity version for production contracts",
"codeSnippet": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**",
"references": [
"SWC-103"
],
"confidence": 0.75
},
{
"id": "EM-01",
"name": "Missing Event Emission",
"severity": "LOW",
"description": "Function \"deposit\" modifies state but may not emit events",
"location": {
"file": "contract.sol",
"line": 11,
"column": 4,
"functionName": "deposit"
},
"technicalExplanation": "Functions that modify state should emit events for off-chain tracking and transparency.",
"exploitScenario": "State changes without events make it difficult to track contract behavior and audit trails.",
"recommendation": "Add event emission for all significant state changes.",
"codeSnippet": "event Deposit(...);",
"references": [
"Best Practice"
],
"confidence": 0.5
},
{
"id": "EM-01",
"name": "Missing Event Emission",
"severity": "LOW",
"description": "Function \"withdraw\" modifies state but may not emit events",
"location": {
"file": "contract.sol",
"line": 16,
"column": 4,
"functionName": "withdraw"
},
"technicalExplanation": "Functions that modify state should emit events for off-chain tracking and transparency.",
"exploitScenario": "State changes without events make it difficult to track contract behavior and audit trails.",
"recommendation": "Add event emission for all significant state changes.",
"codeSnippet": "event Withdraw(...);",
"references": [
"Best Practice"
],
"confidence": 0.5
},
{
"id": "PE-01",
"name": "Public Function Could Be External",
"severity": "INFO",
"description": "Function \"deposit\" is public but could be external",
"location": {
"file": "contract.sol",
"line": 11,
"column": 4,
"functionName": "deposit"
},
"technicalExplanation": "Functions that are not called internally can be marked as external instead of public, saving gas.",
"exploitScenario": "Not a security issue, but wastes gas unnecessarily.",
"recommendation": "Change visibility from public to external if the function is not called internally.",
"codeSnippet": "// Before:\nfunction deposit() public { }\n\n// After:\nfunction deposit() external { }",
"references": [
"Gas Optimization"
],
"confidence": 0.5
},
{
"id": "PE-01",
"name": "Public Function Could Be External",
"severity": "INFO",
"description": "Function \"withdraw\" is public but could be external",
"location": {
"file": "contract.sol",
"line": 16,
"column": 4,
"functionName": "withdraw"
},
"technicalExplanation": "Functions that are not called internally can be marked as external instead of public, saving gas.",
"exploitScenario": "Not a security issue, but wastes gas unnecessarily.",
"recommendation": "Change visibility from public to external if the function is not called internally.",
"codeSnippet": "// Before:\nfunction withdraw() public { }\n\n// After:\nfunction withdraw() external { }",
"references": [
"Gas Optimization"
],
"confidence": 0.5
},
{
"id": "PE-01",
"name": "Public Function Could Be External",
"severity": "INFO",
"description": "Function \"getBalance\" is public but could be external",
"location": {
"file": "contract.sol",
"line": 27,
"column": 4,
"functionName": "getBalance"
},
"technicalExplanation": "Functions that are not called internally can be marked as external instead of public, saving gas.",
"exploitScenario": "Not a security issue, but wastes gas unnecessarily.",
"recommendation": "Change visibility from public to external if the function is not called internally.",
"codeSnippet": "// Before:\nfunction getBalance() public { }\n\n// After:\nfunction getBalance() external { }",
"references": [
"Gas Optimization"
],
"confidence": 0.5
}
],
"gasOptimizations": [],
"bestPractices": [],
"riskAssessment": {
"overallScore": 8.3,
"categoryBreakdown": {
"IO": 1,
"AC": 1,
"FR": 1,
"FP": 1,
"EM": 2,
"PE": 3
},
"historicalContext": "AI analysis disabled"
},
"metadata": {
"analysisVersion": "1.0.0",
"rulesVersion": "1.0.0",
"aiModel": "gpt-4",
"analysisTime": 1156
}
}