Skip to content

Harden database settings, input parsing and the watch queue - #2

Merged
malken21 merged 2 commits into
mainfrom
fix/security-hardening
Nov 6, 2026
Merged

malken21 merged 2 commits into
mainfrom
fix/security-hardening

Conversation

@malken21

@malken21 malken21 commented Nov 4, 2026

Copy link
Copy Markdown
Member

Hardening of the database settings, the file parsers and the resident updater.

Changes

  • Database settings: host, port, user and password are configuration. db.user is required (no default). The password comes from DYNMAP_DB_PASSWORD, DYNMAP_DB_PASSWORD_FILE or db.password_file, never from the command line, and a password in the JSON is ignored. If a configured password file cannot be read, the store does not connect.
  • Compose example: no host networking. It joins a named external network (DB_NETWORK, default minecraft-network), uses tidb:4000, and mounts the password as a compose secret. docker/run.sh passes the password by name, so the value stays off the docker command line.
  • mem_limit: 3g, with a comment: the iGPU's buffers are charged to the cgroup as shmem.
  • Region and NBT parsers: lengths are checked against the bytes left; nesting, value count, decompressed size and region file size are bounded. Section Y, palette sizes, block and biome data lengths and biome indices are validated. A chunk that fails counts as absent.
  • GPU data: each section's palette is padded so every index the block data can hold stays inside it. More than 8 million quads in one batch is not drawn, and its existing rows stay (a blank result would delete them).
  • Block names: only safe names reach file paths, and states, names and properties are limited.
  • Jar reader: names outside the archive root are not indexed, offsets are checked, declared sizes are limited.
  • Watch queue: a mega tile is counted before drawing and cleared after. One the process dies on is retried alone and dropped after 3 attempts. Database errors do not count.
  • Live feed: wss:// only (ws:// to this machine). With another URL it never connects, which run treats as busy. Player entries need numeric coordinates.

Checks

Local, Godot 4.7.2 on Windows. The new test workflow runs the same checks on Linux.

  • tests/run_tests.gd: 134 checks, 0 failed
  • A real 26.x test world, before and after this change: same decode digest (266 chunks), same scan output, same tile hashes from GPU renders of 64 tiles in iso_SE_30_hires and iso_S_90_lowres (NVIDIA, Vulkan). NBT parse time unchanged.
  • bash -n, shellcheck -S warning, actionlint: no findings

Not checked here: the container on the iGPU, the password against a real database, and godot --import on Windows (it hung on this machine, so the checks reused an existing import cache; CI runs the import).

When deploying

Update your own copy of the compose file and maps.json: db host and user, the password file, the network, mem_limit. db.user must be present, and live must be wss://.

- Database host, user and password come from configuration: the password from an environment variable or a file, never the command line. There is no default user any more.
- The compose example joins a named external network and reaches the database as tidb:4000 instead of using host networking. run.sh passes the password by name.
- Raise mem_limit to 3g: the iGPU's buffers are charged to the container's cgroup.
- Region files, NBT and jars are treated as outside input: sizes, lengths, nesting and value counts are bounded, block and biome data are validated, block names are limited to safe names and the block palette sent to the GPU covers every index.
- A mega tile that cannot be drawn keeps its existing rows. One that keeps taking the process down is retried alone and then dropped.
- The live feed accepts wss:// only (ws:// to this machine) and validates player entries.
- Add tests that need no GPU and run them with shellcheck and the compose check in CI.
@malken21
malken21 merged commit c474963 into main Nov 6, 2026
1 check passed
@malken21
malken21 deleted the fix/security-hardening branch November 7, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant