runc accepts duplicate RLIMIT_NOFILE entries and starts the container
Description
With an OCI 1.3.0 bundle containing two process.rlimits entries for RLIMIT_NOFILE, runc successfully completes both create and start. The container process executes and observes a resource limit matching the second entry in the conflicting-value case.
This occurs both when the duplicate entries have different soft limits and when they are identical. Removing the duplicate produces a working control. The issue was first observed in an OCI conformance test suite and then reproduced with the standalone C probe and script included below.
The tested runc commit is 6c72bfe151ee4869aa0674794a543886b715929e. This report does not claim reproduction on current upstream HEAD.
Steps to reproduce the issue
Requirements: Linux with root privileges, Python 3.10+, unshare, a native C compiler named cc, static libc development files, and a runc binary. The script builds a static probe locally and generates three OCI bundles; no container image or distribution rootfs is required.
Save the three files from the Standalone reproducer files section below into a directory named runc-duplicate-rlimits, then run:
cd runc-duplicate-rlimits
sudo unshare --mount --propagation private \
python3 reproduce.py \
--runc /absolute/path/to/runc \
--output "$PWD/replay-1"The output directory must not already exist. Use a fresh directory for each replay. The script uses randomly generated container IDs and separate runtime state directories, captures command output, and force-deletes only the containers it creates. delete --force is used solely for cleanup after observation.
The conflicting-value configuration contains:
"rlimits": [
{"type": "RLIMIT_NOFILE", "soft": 32, "hard": 64},
{"type": "RLIMIT_NOFILE", "soft": 48, "hard": 64}
]The identical-value variant uses soft: 32, hard: 64 in both entries. The control contains only the first entry. All other bundle settings are the same across these three variants.
For each bundle, the script calls runc --root <isolated-state-dir> create --bundle <bundle> <id>, queries the state, calls start, and reads a JSON observation written by the container process. The probe obtains the values through getrlimit(RLIMIT_NOFILE) and remains alive until cleanup. config.template.json, probe.c, and reproduce.py contain the complete setup.
Describe the results you received and expected
Results received
Output from the standalone replay:
{"variant": "control", "observation": {"soft": 32, "hard": 64}, "create": 0, "start": 0}
{"variant": "conflicting-values", "observation": {"soft": 48, "hard": 64}, "create": 0, "start": 0}
{"variant": "identical-values", "observation": {"soft": 32, "hard": 64}, "create": 0, "start": 0}Both duplicate configurations are accepted. create and start exit successfully with empty stderr, state queries report running after startup, and the probe's observation confirms execution of the configured program. In the conflicting-value case, the observed soft limit is 48 rather than 32.
The directly observed consequence is that an invalid duplicate configuration is accepted and, for the tested conflicting pair, the effective limit matches the second entry. No security impact or regression window has been established.
Expected results and specification basis
I would expect runc to reject a duplicate resource-limit type before executing the configured program, including when the duplicate entries contain identical values.
OCI Runtime Specification v1.3.0, config.md:278 states:
If
rlimitscontains duplicated entries with sametype, the runtime MUST generate an error.
runtime.md:83–84 leaves error exposure to the implementation and generally requires errors to preserve the environment's state. Accordingly, this report is not based solely on a particular exit-code convention: the process actually runs with the duplicate configuration.
Could you confirm whether accepting these duplicate entries is intended, or whether duplicate-type validation is missing from this path? This report does not establish an exact source-level cause.
What version of runc are you using?
Output of runc --version from the tested binary:
runc version 1.5.0-rc.1+dev
commit: v1.5.0-rc.1-208-g6c72bfe1
spec: 1.3.0
go: go1.25.0
libseccomp: 2.5.5
libpathrs: 0.2.5+dev- Source commit:
6c72bfe151ee4869aa0674794a543886b715929e.
Host OS information
Ubuntu 24.04.1 LTS, x86_64, WSL2.
Host kernel information
6.6.114.1-microsoft-standard-WSL2
Source: opencontainers/runc