You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+175-1Lines changed: 175 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,11 +29,42 @@ cp .env-template .env
29
29
30
30
```
31
31
32
+
### Firewall Mode
33
+
34
+
The application supports two operational modes for the transaction firewall, which can be configured according to security requirements and operational needs:
35
+
36
+
#### Interactive Mode
37
+
38
+
In interactive mode, the application requires active user participation in the transaction decision-making process. Key features of this mode:
39
+
40
+
- Each incoming transaction is presented to the user through the interface
41
+
- The user can review transaction details (destination address, value, data, etc.)
42
+
- The system awaits an explicit user decision (approve or reject) before continuing processing
43
+
- Provides the highest level of control, ideal for critical operations or environments requiring human supervision
44
+
- Uses UI frontend via websocket protocol for real-time communication with the user interface
45
+
46
+
#### Non-Interactive Mode
47
+
48
+
Non-interactive mode automates the transaction validation process based on predefined rules, eliminating the need for manual intervention. Key features:
49
+
50
+
- Transactions are automatically verified against a predefined set of validation rules
51
+
- Rules may include checking address allow/deny, value limits, gas fee restrictions, contract type verification, etc.
52
+
- Validation occurs instantly without delays related to waiting for user response
53
+
- Ideal for environments requiring high throughput or automation
54
+
55
+
The choice of mode depends on the specific use case, security level, and operational requirements. Interactive mode offers the highest level of control at the expense of performance, while non-interactive mode provides better scalability and automation at the cost of less flexibility in ad-hoc decision making.
56
+
57
+
The mode can be configured in the application configuration file using the `FIREWALL_MODE` parameter.
58
+
32
59
#### Environment
33
60
34
61
The `.env` file allows you to configure various settings required for the Ethereum Transactions Firewall. Below is a
35
62
description of the available variables that you can set:
36
63
64
+
-`FIREWALL_MODE`: Operational mode of the firewall. Can be set to either `interactive` for manual transaction approval
65
+
or `non-interactive` for automated rule-based validation.
66
+
**Default:**`interactive`
67
+
37
68
-`SERVER_PORT`: Port number where the main server will listen for incoming connections.
38
69
**Default:**`8454`
39
70
@@ -51,11 +82,22 @@ description of the available variables that you can set:
51
82
52
83
-`KNOWN_CONTRACTS_PATH`: Path to the file containing information about known contracts mapped to their labels and abi.
53
84
**Default:**`known_contracts.json`
85
+
-
54
86
-`INTERACTIVE_MODE_TIMEOUT_SEC`: Timeout duration for user decision in interactive mode (in seconds).
55
87
**Default:**`60`
56
88
89
+
-`ADDRESS_RULES_PATH`: Path to file containing rules for allowed/denied address combinations.
90
+
**Default:**`address_rules.json`
91
+
92
+
-`VALUE_RULES_PATH`: Path to file containing rules for value and gas price limits.
93
+
**Default:**`value_rules.json`
94
+
95
+
-`CONTRACT_RULES_PATH`: Path to file containing rules for contract function calls.
96
+
**Default:**`contract_rules.json`
97
+
57
98
Be sure to restart the application after making changes to the `.env` file for them to take effect.
58
99
100
+
### Interactive Mode Configuration
59
101
60
102
#### Authorized addresses
61
103
@@ -121,6 +163,138 @@ If a contract address is not matched with any entries in the `known_contracts.js
121
163
122
164
All these interfaces are imported from the [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts) library, which provides secure and community-vetted implementations of common smart contract standards. This automatic detection allows the firewall to properly parse and display transaction data, enhancing security even when interacting with previously undefined contracts.
123
165
166
+
### Non-Interactive Mode Configuration
167
+
168
+
In non-interactive mode, the application uses three types of rules to validate transactions automatically without user intervention. Each rule type is configured in a separate JSON file, and the paths to these files are specified in the application configuration.
169
+
170
+
#### Address Rules
171
+
172
+
Address rules define policies for interactions between specific Ethereum addresses. Each rule specifies whether transactions between particular source and destination addresses should be allowed or denied.
173
+
174
+
To set this up, edit the `address_rules.json` file and add the rules. For example:
"comment": "Deny specific wallet from interacting with DAI contract"
195
+
}
196
+
]
197
+
```
198
+
**Key features:**
199
+
-`action`: Either "allow" or "deny" to permit or block transactions
200
+
-`from`: Source address, use "*" as a wildcard to match any address
201
+
-`to`: Destination address, use "*" as a wildcard to match any address
202
+
-`comment`: Optional description of the rule purpose (recommended for maintenance)
203
+
204
+
Transactions are evaluated against each rule sequentially until a match is found. If a transaction matches a "deny" rule, it is rejected. If no matching rule is found, the transaction is rejected by default.
205
+
206
+
#### Value Rules
207
+
208
+
Value rules define constraints for transaction values and gas prices. These rules help prevent unwanted high-value transfers or excessive gas fees.
209
+
210
+
To set this up, edit the `value_rules.json` file and add the rules. For example:
211
+
212
+
```json
213
+
[
214
+
{
215
+
"minValue": 0,
216
+
"maxValue": 1000000000000000000,
217
+
"minGasPrice": 1000000000,
218
+
"maxGasPrice": 50000000000,
219
+
"comment": "Allow transactions up to 1 ETH with reasonable gas prices"
220
+
},
221
+
{
222
+
"minValue": 0,
223
+
"maxValue": 10000000000000000000,
224
+
"minGasPrice": 1000000000,
225
+
"maxGasPrice": 100000000000,
226
+
"comment": "Allow transactions up to 10 ETH with higher gas price allowance"
227
+
},
228
+
{
229
+
"minValue": null,
230
+
"maxValue": null,
231
+
"minGasPrice": 1000000000,
232
+
"maxGasPrice": 30000000000,
233
+
"comment": "Allow any value transaction with standard gas prices"
234
+
}
235
+
]
236
+
```
237
+
**Key features:**
238
+
-`minValue`: Minimum transaction value in wei (use null for no lower limit)
239
+
-`maxValue`: Maximum transaction value in wei (use null for no upper limit)
240
+
-`minGasPrice`: Minimum gas price in wei (use null for no lower limit)
241
+
-`maxGasPrice`: Maximum gas price in wei (use null for no upper limit)
242
+
-`comment`: Optional description of the rule purpose
243
+
244
+
For EIP-1559 transactions, the system uses `maxFeePerGas` as the equivalent of `gasPrice` when evaluating these rules.
245
+
246
+
#### Contract Rules
247
+
248
+
Contract rules allow or deny interactions with specific smart contract functions. These rules provide fine-grained control over which contract functions can be called.
249
+
250
+
To set this up, edit the `contract_rules.json` file and add the rules. For example:
-`action`: Either "allow" or "deny" to permit or block transactions
293
+
-`functionName`: Name of the contract function to match
294
+
-`args`: Object mapping parameter names to expected values (empty object matches any arguments)
295
+
-`comment`: Optional description of the rule purpose
296
+
297
+
- Contract rules are only applied to transactions that interact with smart contracts. Transactions that don't involve contract interactions automatically pass contract rule validation. **Important:** Contract rules require that the ABI for the target contract is pre-defined in the system's known contracts configuration file (specified by `KNOWN_CONTRACTS_PATH` in the environment configuration). Without the appropriate ABI, the contract's function calls cannot be decoded, and as a result, contract rules will not be matched, causing the transaction to be rejected by default.
124
298
125
299
## Running
126
300
@@ -136,7 +310,7 @@ On successful startup, the application will print the following (or similar) out
136
310
```
137
311
INFO: WebSocket server listening on port 18501
138
312
INFO: Transaction Firewall HTTP Server (to accept/reject transactions): http://eop-1.local:8454
139
-
INFO: Validating Proxy is running
313
+
INFO: Validating Proxy is running in interactive mode
140
314
Proxy address (endpoint to be used in a wallet): "http://eop-1.local:18500"
141
315
Ethereum RPC endpoint used by the firewall: "http://eop-1.local:8545"
"Firewall is set to non-interactive mode. This means all transactions will be automatically accepted or rejected based on predefined rules without user intervention."
0 commit comments