File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env sh
2- # TODO: OWASP RULE#7 https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html#rule-7-limit-resources-memory-cpu-file-descriptors-processes-restarts
3- # TODO: Same OWASP rules in test.sh file
42# TODO: document security recommendations adapted to this project
53# TODO: document requirements for OWASP RULE#8 https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html#rule-7-limit-resources-memory-cpu-file-descriptors-processes-restarts
64# TODO: try OWASP RULE#8 here
7- # TODO: move at root of the project
85
96set -eu
107
@@ -19,9 +16,24 @@ echo '✅ Image built successfully.'
1916
2017echo ' ▶️ Starting the localdev PaperMC server...'
2118
19+ # Apply security best practices based on OWASP recommendations:
20+ # https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
21+ #
22+ # Simulate a production-like environment by enforcing strict security policies:
23+ # - Drop all Linux capabilities (PaperMC does not require any).
24+ # - Disable privilege escalation within the container.
25+ # - Set ulimits:
26+ # - `nofile` (open files): 16384 — sufficient for typical Java-based Minecraft servers.
27+ # - `nproc` (processes): 4096 — a safe and generous limit for JVM workloads.
28+ # - `core`: 0 — disables core dumps to preserve disk space and avoid leaking sensitive information.
2229docker run --rm -it \
2330 --cap-drop all \
2431 --security-opt no-new-privileges \
32+ --ulimit nofile=16384 \
33+ --ulimit nproc=4096 \
34+ --ulimit core=0 \
35+ --cpus=4 \
36+ --memory=8GB \
2537 -p 25565:25565/tcp -p 25565:25565/udp \
2638 -e EULA=true \
2739 ' djaytan/papermc-server:dev'
Original file line number Diff line number Diff line change @@ -70,4 +70,5 @@ echo 'File eula.txt processed'
7070
7171echo ' PaperMC server ready to start!'
7272
73+ # TODO: ensure that the server replace PID 1 instead of spawning a child process (exec command)
7374java $JVM_ARGUMENTS -jar " ${SCRIPT_DIR} " /papermc-server-* .jar $SERVER_ARGS
Original file line number Diff line number Diff line change @@ -9,9 +9,24 @@ echo '📋 Testing the Docker PaperMC server image...'
99
1010echo ' ▶️ Starting the PaperMC server in background...'
1111
12+ # Apply security best practices based on OWASP recommendations:
13+ # https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
14+ #
15+ # Simulate a production-like environment by enforcing strict security policies:
16+ # - Drop all Linux capabilities (PaperMC does not require any).
17+ # - Disable privilege escalation within the container.
18+ # - Set ulimits:
19+ # - `nofile` (open files): 16384 — sufficient for typical Java-based Minecraft servers.
20+ # - `nproc` (processes): 4096 — a safe and generous limit for JVM workloads.
21+ # - `core`: 0 — disables core dumps to preserve disk space and avoid leaking sensitive information.
1222docker run --rm -d --name " $CONTAINER_NAME " \
1323 --cap-drop all \
1424 --security-opt no-new-privileges \
25+ --ulimit nofile=16384 \
26+ --ulimit nproc=4096 \
27+ --ulimit core=0 \
28+ --cpus=4 \
29+ --memory=8GB \
1530 -p 25565:25565/tcp -p 25565:25565/udp \
1631 -e EULA=true \
1732 ' djaytan/papermc-server:dev'
You can’t perform that action at this time.
0 commit comments