Skip to content

Commit 8612467

Browse files
committed
fix(runtime-services): harden native MariaDB containment
1 parent 5e682fd commit 8612467

4 files changed

Lines changed: 338 additions & 58 deletions

File tree

docs/native-mariadb-runtime-service.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
## Isolation Contract
66

7-
- The provider resolves and validates `mariadbd`, `mariadb-install-db`, and `mariadb` identities before allocation.
7+
- The provider rejects UID 0 and resolves and validates `mariadbd`, `mariadb-install-db`, `mariadb`, util-linux `prlimit`, `truncate`, `mkfs.ext4`, `fuse2fs`, and `fusermount3` identities before allocation.
88
- Every run gets a mode-`0700` `mkdtemp` root. The data directory, temporary directory, socket, PID file, and error log are children of that root.
9-
- Initialization, daemon, and client argument arrays begin with `--no-defaults`. No shell or default socket is used.
9+
- Initialization, daemon, and administrative clients run through fixed hard rlimits; each database command itself begins with `--no-defaults`. No shell or default socket is used.
1010
- Administration uses only the private Unix socket. Workloads receive a generated least-privilege `runtime` account over loopback TCP through the existing ephemeral connector-secret channel.
1111
- Cleanup signals only the retained direct `ChildProcess`; the PID file is never trusted or read. Linux captures the owned process start-time token and revalidates it before every signal to reject PID reuse. Root device/inode identity and a symlink-free tree are revalidated before recursive removal.
1212
- Failures, aborts, timeouts, startup crashes, and partial initialization all enter the same graceful-shutdown, forced-shutdown, wait, and verified-removal state machine. Cleanup failure is terminal and retained in bounded lifecycle evidence.
13+
- Address space is capped at 2 GiB, CPU at 300 seconds, individual daemon files at 128 MiB, open files at 512, and processes/threads at 512. Core files and locked memory are disabled. The datadir is a provider-owned 256 MiB ext4 image formatted with 4,096 inodes and mounted through unprivileged FUSE; device, byte, and inode geometry must be proven before initialization. Hosts without this containment fail closed.
1314
- Evidence contains service ID, engine/provider version, lifecycle state, and memory measurements only. It never contains credentials or private absolute paths.
1415

1516
## Daemon Arguments
1617

17-
The provider starts `mariadbd` directly with these fixed controls plus provider-owned absolute paths and a freshly allocated loopback port:
18+
The provider starts `mariadbd` through `prlimit` with these fixed controls plus provider-owned absolute paths and a freshly allocated loopback port:
1819

1920
```text
2021
--no-defaults
@@ -34,18 +35,29 @@ The provider starts `mariadbd` directly with these fixed controls plus provider-
3435
--performance-schema=OFF
3536
--skip-feedback
3637
--innodb-buffer-pool-size=32M
38+
--innodb-buffer-pool-size-max=32M
3739
--innodb-log-buffer-size=4M
3840
--key-buffer-size=8M
3941
--aria-pagecache-buffer-size=8M
42+
--thread-handling=pool-of-threads
43+
--thread-pool-size=1
44+
--aria-log-file-size=16M
45+
--innodb-file-per-table=OFF
46+
--innodb-data-file-path=ibdata1:32M:autoextend:max:96M
47+
--innodb-temp-data-file-path=ibtmp1:16M:autoextend:max:32M
48+
--innodb-log-file-size=32M
4049
--max-connections=10
50+
--max-prepared-stmt-count=256
51+
--max-session-mem-used=32M
52+
--open-files-limit=512
4153
--thread-cache-size=0
4254
--table-open-cache=128
4355
--table-definition-cache=128
4456
--tmp-table-size=8M
4557
--max-heap-table-size=8M
4658
```
4759

48-
The configured service budget is 128 MiB. Linux runs record the owned daemon's post-readiness RSS in evidence; the MariaDB 10.11 integration gate requires the observed value to remain within that budget.
60+
The hard address-space ceiling is 2 GiB. Linux runs record the owned daemon's post-readiness RSS in evidence; the MariaDB 10.11 integration gate additionally requires observed RSS to remain at or below 128 MiB.
4961

5062
## Integration Contract
5163

0 commit comments

Comments
 (0)