Skip to content

Commit 5a305d4

Browse files
committed
Improving readme
1 parent 7cc5938 commit 5a305d4

1 file changed

Lines changed: 57 additions & 26 deletions

File tree

README.md

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,31 @@ below.
1212
There's also a minimized version under the `minimal` branch.
1313

1414
## Requirements
15+
1516
1. Visual Studio Code.
1617
1. DevContainer extension by MS: `ms-vscode-remote.remote-containers`.
1718
1. Must have installed on your local OS: `docker` and `docker-buildx`.
1819

1920
## Kick-off
21+
2022
1. Start the docker service, and make sure your user is in the `docker` group. Otherwise, add
21-
yourself to it but you'll have to log in back again.
23+
yourself to it but you'll have to log in back again.
2224
2. Clone this repo, if you want a minimal version checkout `minimal`.
2325
3. Open the folder with **vscode** how you like. Running `code .` works well.
2426
4. Select **Reopen in Container** and wait. This will build the container volume.
2527
5. If this is your first time, you'll be prompted to press enter on a console log that triggers the
26-
terminal.
28+
terminal.
2729
6. If not you can go to the extensions section on your side, click the **Remote Explorer** tab and
28-
select the active devcontainer.
30+
select the active devcontainer.
2931

3032
## Usage
33+
3134
If you open the **Command Palette** (Ctrl+Shift+p or whatever your shortcut is) you
32-
can access several features:
33-
- You can attach VS Code to a running container, where you can open any folder
34-
or Clone a repository.
35-
- You can open new folders or workspaces of your liking inside the current
36-
volume.
37-
- You can even clone a new repository in a new volume based on the same
38-
devcontainer.
35+
can access several features:
36+
37+
- You can attach VS Code to a running container, where you can open any folder or Clone a repository.
38+
- You can open new folders or workspaces of your liking inside the current volume.
39+
- You can even clone a new repository in a new volume based on the same devcontainer.
3940

4041
## Features Overview
4142

@@ -63,10 +64,12 @@ volume.
6364
- tintinweb.vscode-decompiler
6465

6566
### Frameworks
67+
6668
- **Foundry**: Really fast modular toolkit (forge, anvil, cast).
6769
- **Hardhat**: Dev environment to develop, deploy, test and debug.
6870

6971
### Security Tools
72+
7073
- **Fuzzing**:
7174
- **Medusa**: Parallelized, coverage-guided, mutational Solidity smart contract fuzzing, powered by go-ethereum.
7275
- **Echidna**: Fuzz testing for Ethereum contracts (prebuilt binary).
@@ -78,20 +81,22 @@ volume.
7881
- **Semgrep**: Lightweight static analysis with custom rule definitions.
7982

8083
- **Symbolic execution**:
81-
- **Mythril**: A symbolic-execution-based securty analysis tool for EVM bytecode.
84+
- **Mythril**: A symbolic-execution-based securty analysis tool for EVM bytecode.
8285
- **Halmos**: A symbolic testing tool for EVM smart contracts.
8386

8487
- **Decompilers**:
8588
- **Panoramix**: Smart contract decompiler.
86-
89+
8790
- **Other**:
8891
- **Slither-LSP**: Language server for enhanced contract analysis.
89-
- **napalm**: A project management utility for custom solidity vulnerability detectors.
92+
- **napalm**: A project management utility for custom solidity vulnerability detectors. To include
93+
some default collections you need to install napalm-core manually.
9094
- **Heimdall**: An advanced EVM smart contract toolkit specializing in bytecode analysis and
9195
extracting information from unverified contracts.
9296
- **Aderyn**: Rust-based Solidity AST analyzer.
9397

9498
### Utilities
99+
95100
- **solc-select**: Solc version manager for multiple Solidity versions.
96101
- **vyper**: Pythonic language for Ethereum smart contracts.
97102
- **Package Managers**:
@@ -102,66 +107,79 @@ volume.
102107
- **uv**: Utility manager.
103108
- **nvm**: Node.js version manager.
104109

105-
106110
### Languages
111+
107112
- **JavaScript**, **Python**, **Go**, **Rust**, **Vyper**, **Solidity**.
108113

109114
### Shell
115+
110116
**ZSH**. Configured with Oh-My-ZSH and autocompletions for: **medusa**, **anvil**, **cast**, **forge**.
111117

112118
### Additional Repositories
119+
113120
- **building-secure-contracts**: Repository with security-focused Solidity examples.
114121

115122
### Notes
123+
116124
- Remember to disable telemetry. `Ctrl+Shift+P > Open Settings (UI) >` type `telemetry` and uncheck
117125
all the boxes. Alternatively you can add them directly by going to `Open Settings (JSON)`, example:
126+
118127
```json
119128
"telemetry.telemetryLevel": "off",
120129
"gitlens.telemetry.enabled": false,
121130
"partialDiff.enableTelemetry": false,
122-
```
123-
131+
```
124132

125-
## Manual interventions & info
133+
### Manual interventions & info
126134

127135
### Hardening: Enabling SELinux
136+
128137
SELinux (Security-Enhanced Linux) is a mandatory access control (MAC) system that restricts processes and users to only the resources they are explicitly allowed to access, enhancing system security.
129138

130139
You can check if you have this already enabled by running `sudo sestatus`
131140

132141
If you don't have SELinux installed, and you really want up your game, and protect your host from
133142
container escapes go ahead and install it. Find whichever guide convinves you the most! Afterward,
134143
enable it inside `/etc/docker/daemon.json` (it should be enabled by default afaik).
144+
135145
```bash
136146
❯ cat /etc/docker/daemon.json
137147
{
138148
"selinux-enabled": true
139149
}
140150
```
141151

142-
To manually disable SELinux you can uncomment the following line:
152+
### Hardening: Enabling seccomp
153+
154+
seccomp is a Linux kernel feature that restricts the system calls that a process can make. It's a more
155+
restrictive security mechanism than SELinux.
156+
157+
To manually enable seccomp you can specify a profile like this:
158+
143159
```json
144-
// Disable SELinux.
145-
// "--security-opt", "seccomp=unconfined"
160+
"--security-opt", "seccomp=profile.json"
146161
```
147162

148163
### Hardening: Enabling AppArmor
164+
149165
AppArmor is a Linux security module that enforces file and network access restrictions for applications through profiles. It sometimes can be more straighforward than SELinux.
150166

151-
You can check it has been enabled by running `sudo apparmor_status`.
167+
You can check it has been enabled by running `sudo apparmor_status`.
152168

153169
This has been enabled via the argument:
170+
154171
```json
155172
"--security-opt", "apparmor:docker-default"`
156173
```
157174

158-
159175
### Hardening: Dropping capabilities
176+
160177
Capabilities in Linux are fine-grained permissions that allow processes to perform specific
161178
privileged operations without granting full root privileges. They break down the all-or-nothing
162179
nature of root access into smaller, specific rights, improving security.
163180

164-
We have done this by running the following argument:
181+
We have done this by running the following argument:
182+
165183
```json
166184
"--cap-drop=ALL"
167185
```
@@ -170,21 +188,24 @@ This allows us to reduce attack surface by limiting privileged operations. And a
170188
processes as full root.
171189

172190
A few examples:
191+
173192
- `CAP_NET_ADMIN`: Allows network administration (e.g., configuring interfaces).
174193
- `CAP_CHOWN`: Allows changing file ownership.
175194

176-
177195
### Hardening: No new privileges
196+
178197
There's a flag that allows you to avoid getting the user more privilages than it already has. So if
179198
you want to use **sudo** or elevate privilages, you can restart your container after commenting the
180199
following line:
200+
181201
```json
182202
"--security-opt", "no-new-privileges",
183203
```
184204

185205
### Hardening: Read-only filesystem
206+
186207
This may be one of the safest configurations out there but a hard one to use, at least for
187-
development environments.
208+
development environments.
188209

189210
It's trickier because it limits a lot what you can do. But if you want to
190211
experiment by yourself, you can start by enabling the `"--read-only"` flag and troubleshooting under
@@ -197,7 +218,7 @@ the `mount` section which volumes are mandatory needed as writable.
197218
- Lets you enforce the need for @inheritdoc in public/external functions.
198219
- Can integrate on your daily workflow, or just as a final check.
199220

200-
```
221+
```bash
201222
npx @defi-wonderland/natspec-smells --include "src/**/*.sol"
202223
```
203224

@@ -224,11 +245,13 @@ npx @defi-wonderland/natspec-smells --include "src/**/*.sol"
224245
```
225246

226247
3. Run
248+
227249
```bash
228250
yarn natspec-smells
229251
```
230252

231253
### Semgrep
254+
232255
Currently semgrep supports [Solidity](https://semgrep.dev/docs/language-support/) in `experimental` mode. Some of the rules may not work until Solidity is in `beta` at least.
233256

234257
> **Important:** Some of the rules utilize the [taint mode](https://semgrep.dev/docs/writing-rules/data-flow/taint-mode), which is restricted to the same function in the open-source version of semgrep. To take advantage of intra-procedural taint analysis, you must include the `--pro` flag with each command. Please note that this requires semgrep Pro.
@@ -278,7 +301,9 @@ and manage multiple versions of tools like Go, Python, Node.js, and more, all in
278301
especially useful for projects requiring specific tool versions.
279302

280303
#### Install Plugins
304+
281305
Add the plugin for the language or tool you need:
306+
282307
```bash
283308
asdf plugin add <language/tool>
284309
asdf plugin list all
@@ -289,25 +314,29 @@ Python: `asdf plugin add python`
289314
Node.js: `asdf plugin add nodejs`
290315

291316
#### You can list and install specific versions
317+
292318
```bash
293319
asdf install golang 1.20.5
294320
asdf install python 3.11.5
295321
asdf install nodejs 18.15.0
296322
```
297323

298324
#### Make a version be used globally
325+
299326
```bash
300327
asdf global golang 1.20.5
301328
asdf global python 3.11.5
302329
```
303330

304331
#### Make a version be used locally
332+
305333
```bash
306334
asdf local golang 1.19.2
307335
asdf local python 3.10.4
308336
```
309337

310338
### Install different node versions with nvm
339+
311340
```bash
312341
# Install the latest version
313342
nvm install --lts
@@ -320,5 +349,7 @@ nvm ls
320349
```
321350

322351
### Links
352+
323353
- Article (references this repo's branch article): [Where do you run your code?](https://blog.theredguild.org/where-do-you-run-your-code/)
354+
- Article (references this repo's branch article): [Where do you run your code II? - hardening](https://blog.theredguild.org/where-do-you-run-your-code-part-ii-2/)
324355
- Workshop: [Come and build your own devContainer!](https://eth-security-explorations.notion.site/Come-and-build-your-own-devContainer-13b3c0d74d7f448f836419281d916369) @ the-mu

0 commit comments

Comments
 (0)