Skip to content

Commit 47030c8

Browse files
authored
Merge pull request #18 from theredguild/develop
feat: Overhaul devcontainer configurations and add experimental paranoid mode
2 parents 4225ee0 + 4f94a3f commit 47030c8

12 files changed

Lines changed: 427 additions & 127 deletions

File tree

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This is the HARDENED version of TRG's DevContainer - provides enhanced security
44
// with capability dropping, security options, and resource limits while maintaining
55
// network connectivity for development.
6-
"name": "Hardened TRG's DevContainer",
6+
"name": "Air-gapped TRG's DevContainer",
77

88
// Build configuration - uses the local Dockerfile in this directory
99
"build": {
@@ -23,23 +23,13 @@
2323
// Container environment variables
2424
"containerEnv": {
2525
"SHELL": "/bin/zsh", // Use zsh as the default shell
26-
"DEVCONTAINER_ID_LABEL": "hardened-web3-devcontainer" // Label for container identification
26+
"DEVCONTAINER_ID_LABEL": "airgapped-web3-devcontainer" // Label for container identification
2727
},
2828

2929
// Configure tool-specific properties for VS Code
3030
"customizations": {
3131
"vscode": {
3232
// Web3 security and development extensions
33-
"extensions": [
34-
"tintinweb.ethereum-security-bundle", // Comprehensive Ethereum security tools
35-
"tintinweb.vscode-ethover", // Ethereum hover information
36-
"trailofbits.weaudit", // Trail of Bits audit tools
37-
"tintinweb.vscode-inline-bookmarks", // Inline code bookmarks
38-
"tintinweb.vscode-solidity-language", // Solidity language support
39-
"tintinweb.graphviz-interactive-preview", // Graph visualization
40-
"trailofbits.contract-explorer", // Smart contract exploration
41-
"tintinweb.vscode-decompiler" // Contract decompilation
42-
],
4333
// VS Code settings for security and functionality
4434
"settings": {
4535
// Security settings - killswitch for automated tasks
@@ -69,7 +59,7 @@
6959
// If you need to extract something from within the container, you can use docker cp, but use it at your own risk.
7060
// If you want to develop your devcontainer, you should comment this things, otherwise your changes inside the live container won't persist.
7161
// Disables mounting the host workspace into the container for isolation.
72-
"workspaceMount": "type=tmpfs,destination=/workspace",
62+
"workspaceMount": "type=tmpfs,destination=/workspace,tmpfs-mode=1777",
7363
// Sets a workspace path entirely isolated within the container
7464
"workspaceFolder": "/workspace",
7565

@@ -98,15 +88,7 @@
9888
// Network security configuration
9989
// If you really want to isolate it, just disconnect it from the internet.
10090
// You should COPY your working files inside before, otherwise you'll have to mount them manually.
101-
// "--network=none",
102-
103-
// IPv6 security - disable IPv6 to reduce attack surface
104-
"--sysctl=net.ipv6.conf.all.disable_ipv6=1", // Disable IPv6 globally
105-
"--sysctl=net.ipv6.conf.default.disable_ipv6=1", // Disable IPv6 by default
106-
107-
// Network capability restrictions
108-
"--cap-drop=NET_RAW", // Disable raw packet access
109-
"--network=bridge", // Use bridge networking
91+
"--network=none",
11092

11193
// DNS configuration for security and reliability
11294
"--dns=1.1.1.1", // Primary DNS (Cloudflare)

.devcontainer/auditor/devcontainer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@
5858
}
5959
},
6060

61-
// Mount isolation configuration for security and development workflow
62-
// If you need to extract something from within the container, you can use docker cp, but use it at your own risk.
63-
// If you want to develop your devcontainer, you should comment this things, otherwise your changes inside the live container won't persist.
64-
// Disables mounting the host workspace into the container for isolation.
65-
"workspaceMount": "type=tmpfs,destination=/workspace",
61+
// Mount copying host folder into container, no isolation.
62+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
6663
// Sets a workspace path entirely isolated within the container
6764
"workspaceFolder": "/workspace",
6865

.devcontainer/eth-security-toolbox

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 78f2b0c2440709a9067ae7ca64f55d2199b03b8a

.devcontainer/isolated/Dockerfile

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# syntax=docker/dockerfile:1.8
22
# check=error=true
33
#
4-
# ISOLATED TRG DevContainer Dockerfile
5-
# This Dockerfile creates a highly isolated development environment for Web3 security research
6-
# with maximum security isolation, read-only filesystem, and network isolation.
4+
# HARDENED TRG DevContainer Dockerfile
5+
# This Dockerfile creates a security-hardened development environment for Web3 security research
6+
# with enhanced security features, capability dropping, and minimal attack surface.
77
#
88
# Key security features:
9+
# - Multi-stage build for Echidna binary
910
# - Non-root user execution
1011
# - Minimal package installation
1112
# - Security-hardened toolchain
13+
# - Reduced tool set for security focus
1214

1315
## Multi-stage build for Echidna
1416
# Pull latest prebuilt Echidna binary from Crytic's official image
@@ -17,7 +19,7 @@ FROM --platform=linux/amd64 ghcr.io/crytic/echidna/echidna:latest AS echidna
1719

1820
# Base image: Latest Debian with VS Code DevContainer support
1921
# This provides a stable, security-focused base for development
20-
FROM mcr.microsoft.com/vscode/devcontainers/base:debian
22+
FROM mcr.microsoft.com/devcontainers/base:bookworm
2123

2224
# Install essential system packages for development
2325
# These are the minimal packages needed for Web3 development tools
@@ -35,6 +37,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
3537
zsh # Advanced shell \
3638
&& rm -rf /var/lib/apt/lists/*
3739

40+
41+
3842
# Install Python development dependencies
3943
# Required for Python-based security tools and package management
4044
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -100,17 +104,6 @@ USER vscode
100104
ENV PNPM_HOME=${HOME}/.local/share/pnpm
101105
ENV PATH=${PATH}:${PNPM_HOME}
102106

103-
# Install Python-based security analysis tools (reduced set for security focus)
104-
# These tools provide essential smart contract security analysis
105-
# Focused on core tools: slither, mythril, crytic-compile, halmos, solc-select
106-
RUN uv tool install slither-analyzer && \
107-
uv tool install crytic-compile && \
108-
uv tool install slither-lsp && \
109-
uv tool install mythril && \
110-
uv tool install halmos && \
111-
uv tool install solc-select && \
112-
solc-select install 0.4.26 0.5.17 0.6.12 0.7.6 0.8.10 latest && solc-select use latest
113-
114107
# Install Foundry framework for Ethereum development
115108
# Foundry provides Forge (testing), Cast (interaction), and Anvil (local blockchain)
116109
RUN curl -fsSL https://foundry.paradigm.xyz | zsh && \
@@ -135,6 +128,17 @@ RUN git clone https://github.com/crytic/medusa $HOME/medusa && \
135128
WORKDIR $HOME
136129
RUN rm -rf medusa/
137130

131+
# Install Python-based security analysis tools (reduced set for security focus)
132+
# These tools provide essential smart contract security analysis
133+
# Focused on core tools: slither, mythril, crytic-compile, halmos, solc-select
134+
RUN uv tool install slither-analyzer && \
135+
uv tool install crytic-compile && \
136+
uv tool install slither-lsp && \
137+
uv tool install mythril && \
138+
uv tool install halmos && \
139+
uv tool install solc-select && \
140+
solc-select install 0.4.26 0.5.17 0.6.12 0.7.6 0.8.10 latest && solc-select use latest
141+
138142
# Copy Echidna binary from echidna stage to final image
139143
# This provides the prebuilt Echidna tool without rebuilding
140144
USER root
Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
// For format details, see https://aka.ms/devcontainer.json.
3-
// This is the ISOLATED version of TRG's DevContainer - provides maximum security isolation
4-
// with a read-only filesystem and network isolation for high-security Web3 development.
3+
// This is the HARDENED version of TRG's DevContainer - provides enhanced security
4+
// with capability dropping, security options, and resource limits while maintaining
5+
// network connectivity for development.
56
"name": "Isolated TRG's DevContainer",
67

78
// Build configuration - uses the local Dockerfile in this directory
@@ -29,7 +30,6 @@
2930
"customizations": {
3031
"vscode": {
3132
// Web3 security and development extensions
32-
// check out https://marketplace.visualstudio.com/items?itemName=tintinweb.ethereum-security-bundle for more information
3333
"extensions": [
3434
"tintinweb.ethereum-security-bundle", // Comprehensive Ethereum security tools
3535
"tintinweb.vscode-ethover", // Ethereum hover information
@@ -56,54 +56,70 @@
5656
"terminal.integrated.defaultProfile.linux": "zsh", // Use zsh by default
5757
"terminal.integrated.profiles.linux": { "zsh": { "path": "/usr/bin/zsh" } }
5858
// Using bash might be more safe and stable, but zsh provides better features
59-
}
59+
},
6060
}
6161
},
6262

6363
// Commands to run during container lifecycle
64-
"initializeCommand": "echo 'Initializing isolated dev container...'",
64+
"initializeCommand": "echo 'Initializing hardened dev container...'",
6565
"postStartCommand": "echo '🚀 Dev container is ready for Web3 development!'",
6666

67-
// Workspace configuration - isolated within container
68-
"workspaceFolder": "/workspace",
69-
// Mount workspace as tmpfs for complete isolation - no host file access.
70-
// This ensures that the workspace is ephemeral and does not persist data.
71-
"workspaceMount": "type=tmpfs,destination=/workspace,tmpfs-mode=1777",
72-
73-
// Docker run arguments for security and isolation
74-
"runArgs": [
75-
// Security hardening - drop all Linux capabilities to reduce attack surface
76-
"--cap-drop=ALL",
77-
78-
// Read-only filesystem for maximum security, preventing any persistent changes
79-
"--read-only",
80-
81-
// Security options for container isolation
82-
"--security-opt",
83-
"no-new-privileges:true", // Prevent privilege escalation from within the container
84-
"--security-opt",
85-
"apparmor=docker-default", // Apply Docker's default AppArmor profile for enhanced security
86-
87-
// Network isolation - completely disconnect from the internet for a secure environment
88-
"--network=none",
89-
90-
// --- Writable, EXECUTABLE Mounts for VS Code Server ---
91-
"--tmpfs", "/home/vscode/.vscode-server:rw,exec,nosuid,size=512m,uid=1000,gid=1000",
92-
"--tmpfs", "/home/vscode/.vscode-server-insiders:rw,exec,nosuid,size=256m,uid=1000,gid=1000",
9367

94-
// --- Writable, NON-EXECUTABLE Mounts for Caches, Configs, and Logs ---
95-
"--tmpfs", "/home/vscode/.cache:rw,noexec,nosuid,size=256m,uid=1000,gid=1000",
96-
"--tmpfs", "/home/vscode/.config:rw,noexec,nosuid,size=128m,uid=1000,gid=1000",
97-
"--tmpfs", "/home/vscode/.local:rw,noexec,nosuid,size=256m,uid=1000,gid=1000",
98-
"--tmpfs", "/home/vscode/.gnupg:rw,noexec,nosuid,size=32m,uid=1000,gid=1000",
99-
"--tmpfs", "/tmp:rw,noexec,nosuid,size=512m",
100-
"--tmpfs", "/var/tmp:rw,noexec,nosuid,size=512m",
101-
"--tmpfs", "/var/log:rw,noexec,nosuid,size=128m",
102-
"--tmpfs", "/run:rw,noexec,nosuid,size=128m",
103-
"--tmpfs", "/home/vscode/.devcontainer:rw,noexec,nosuid,size=32m,uid=1000,gid=1000"
68+
// Mount isolation configuration for security and development workflow
69+
// If you need to extract something from within the container, you can use docker cp, but use it at your own risk.
70+
// If you want to develop your devcontainer, you should comment this things, otherwise your changes inside the live container won't persist.
71+
// Disables mounting the host workspace into the container for isolation.
72+
"workspaceMount": "type=tmpfs,destination=/workspace,tmpfs-mode=1777",
73+
// Sets a workspace path entirely isolated within the container
74+
"workspaceFolder": "/workspace",
10475

105-
// Resource limits for container performance and stability
106-
// "--memory=1g", // Limit container memory to 1GB to prevent resource exhaustion
107-
// "--cpus=2" // Limit container to 2 CPU cores for predictable performance
108-
]
76+
// Docker run arguments for security hardening and resource management
77+
"runArgs": [
78+
79+
// Temporary filesystem mounts with security restrictions
80+
// These provide isolated, size-limited temporary storage
81+
"--tmpfs=/tmp:rw,noexec,nosuid,size=512m", // Main temporary directory
82+
"--tmpfs=/var/tmp:rw,noexec,nosuid,size=512m", // System temporary directory
83+
"--tmpfs=/dev/shm:rw,noexec,nosuid,size=64m", // Shared memory directory
84+
85+
// Security hardening - drop all Linux capabilities
86+
// This reduces the attack surface by removing unnecessary privileges
87+
"--cap-drop=ALL",
88+
89+
// Security options for container isolation
90+
// A few security additions (AppArmor & no new privileges)
91+
"--security-opt", "no-new-privileges", // Prevent privilege escalation
92+
"--security-opt", "apparmor:docker-default", // Use Docker's default AppArmor profile
93+
94+
// Use seccomp's default security profile
95+
// seccomp provides system call filtering for additional security
96+
// "--security-opt", "seccomp=default",
97+
98+
// Network security configuration
99+
// If you really want to isolate it, just disconnect it from the internet.
100+
// You should COPY your working files inside before, otherwise you'll have to mount them manually.
101+
// "--network=none",
102+
103+
// IPv6 security - disable IPv6 to reduce attack surface
104+
"--sysctl=net.ipv6.conf.all.disable_ipv6=1", // Disable IPv6 globally
105+
"--sysctl=net.ipv6.conf.default.disable_ipv6=1", // Disable IPv6 by default
106+
107+
// Network capability restrictions
108+
"--cap-drop=NET_RAW", // Disable raw packet access
109+
"--network=bridge", // Use bridge networking
110+
111+
// DNS configuration for security and reliability
112+
"--dns=1.1.1.1", // Primary DNS (Cloudflare)
113+
"--dns=1.0.0.1", // Secondary DNS (Cloudflare)
114+
115+
// Resource limits for container performance and security
116+
// Play a little bit with resources to prevent resource exhaustion
117+
// "--memory=512m", // Memory limit (commented out)
118+
// "--cpus=2" // CPU limit (commented out)
119+
],
120+
121+
// Writable mounts in case you want to set --read-only above.
122+
// Currently no additional mounts are configured
123+
"mounts": [
124+
]
109125
}

.devcontainer/minimal/devcontainer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
// }
2626
},
2727

28-
// Mount isolation configuration for security and development workflow
29-
// If you need to extract something from within the container, you can use docker cp, but use it at your own risk.
30-
// If you want to develop your devcontainer, you should comment this things, otherwise your changes inside the live container won't persist.
31-
// Disables mounting the host workspace into the container for isolation.
32-
"workspaceMount": "type=tmpfs,destination=/workspace",
33-
// Sets a workspace path entirely isolated within the container
28+
// Mount copying host folder into container, no isolation.
29+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
3430
"workspaceFolder": "/workspace",
3531

3632
// Docker run arguments for security hardening and resource management

0 commit comments

Comments
 (0)