Skip to content

Commit 547609c

Browse files
committed
fix: enhance OpenVPN image security and privacy
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 8160732 commit 547609c

File tree

4 files changed

+66
-3
lines changed

4 files changed

+66
-3
lines changed

.github/workflows/publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches: ['main']
66
tags:
77
- 'v*.*.*'
8+
schedule:
9+
# Weekly on Mondays at 00:00 UTC
10+
- cron: '0 0 * * 1'
811

912
concurrency: ${{ github.ref }}
1013

@@ -14,6 +17,7 @@ jobs:
1417
permissions:
1518
contents: read
1619
packages: write
20+
security-events: write
1721
steps:
1822
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 https://github.com/actions/checkout/releases/tag/v6.0.0
1923
- name: qemu
@@ -49,6 +53,18 @@ jobs:
4953
platforms: linux/amd64,linux/arm64
5054
tags: ${{ steps.meta.outputs.tags }}
5155
labels: ${{ steps.meta.outputs.labels }}
56+
- name: Run Trivy vulnerability scanner
57+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
58+
with:
59+
scan-type: 'image'
60+
scan-ref: 'ghcr.io/blinklabs-io/openvpn:main'
61+
format: 'sarif'
62+
output: 'trivy-results.sarif'
63+
- name: Upload Trivy scan results to GitHub Security tab
64+
uses: github/codeql-action/upload-sarif@d3ced5c96c16c4332e2a61eb6f3649d6f1b20bb8 # v3.31.5
65+
if: always()
66+
with:
67+
sarif_file: 'trivy-results.sarif'
5268
# Update Docker Hub from README
5369
- name: Docker Hub Description
5470
uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0 https://github.com/peter-evans/dockerhub-description/releases/tag/v5.0.0

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
FROM ubuntu:24.04 AS base
1+
FROM debian:bookworm-slim AS base
22

33
COPY bin/ /usr/local/bin
44

55
RUN apt-get update \
66
&& apt-get dist-upgrade -y \
7-
&& apt-get install -y openvpn iptables \
7+
# Install OpenVPN (latest 2.6.x from Debian repos; rebuild image periodically for security updates)
8+
&& apt-get install -y --no-install-recommends openvpn iptables \
9+
&& apt-get purge -y --auto-remove cron rsyslog \
10+
&& rm -rf /var/log/* \
811
&& apt-get clean \
912
&& rm -rf /var/lib/apt/lists/* \
1013
&& chmod +x /usr/local/bin/*
1114

15+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD pgrep -f openvpn || exit 1
16+
1217
EXPOSE 1194/udp
1318

1419
ENTRYPOINT ["/usr/local/bin/entrypoint"]

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# docker-openvpn
22

3-
Simple OpenVPN image with updated version
3+
Simple OpenVPN image with updated version, optimized for privacy-focused VPN services.
44

55
## Using the image
66

@@ -12,3 +12,41 @@ docker run -d -n openvpn -v /path/to/openvpn.conf:/etc/openvpn/openvpn.conf ghcr
1212

1313
The image provides for the ability to provide a custom startup script. It looks for a user script at `/usr/local/bin/entrypoint-user.sh` by default,
1414
but the location can be overridden with the `USER_STARTUP_SCRIPT` environment variable
15+
16+
## Privacy and Security Recommendations
17+
18+
For a no-log, privacy-focused setup:
19+
20+
### OpenVPN Configuration
21+
Use these options in your `openvpn.conf` for strong encryption and no logging:
22+
```conf
23+
# Disable logging
24+
log /dev/null
25+
verb 0
26+
27+
# Strong ciphers
28+
cipher AES-256-GCM
29+
auth SHA256
30+
tls-cipher TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384
31+
tls-version-min 1.2
32+
33+
# Privilege drop
34+
user nobody
35+
group nogroup
36+
37+
# Other privacy settings
38+
persist-key
39+
persist-tun
40+
```
41+
42+
### Docker Run Options
43+
- Use Docker secrets for certificates/keys: `--secret mykey=/path/to/key`
44+
- Run with necessary capabilities only: `--cap-add=NET_ADMIN` (avoid `--privileged`)
45+
- For Kubernetes (Helm), use `securityContext` to limit privileges.
46+
47+
### Maintenance
48+
- Rebuild images regularly to pull security updates from Debian repos.
49+
- Scan for vulnerabilities with tools like Trivy (automated via GitHub Actions).
50+
- Test for leaks using services like ipleak.net while connected.
51+
52+
**Warning**: Running in privileged mode increases security risks—use only when necessary.

bin/entrypoint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ fi
1818

1919
if [[ $ENABLE_NAT = 1 ]]; then
2020
iptables -t nat -A POSTROUTING -s ${NAT_SOURCE} -o ${NAT_DEVICE} -j MASQUERADE
21+
# Basic kill switch: Drop forwarded traffic by default, allow only VPN-related
22+
iptables -P FORWARD DROP
23+
iptables -A FORWARD -i tun+ -o ${NAT_DEVICE} -j ACCEPT
24+
iptables -A FORWARD -i ${NAT_DEVICE} -o tun+ -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
2125
fi
2226

2327
# Execute user startup script if it exists

0 commit comments

Comments
 (0)