Container detection misses LXC/Incus and other systemd-managed containers; host-only rules and their remediations run inside the guest
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
調査の方向性
shared/applicability/oval/installed_env_is_a_container.xml と、shared/applicability/container.yml および machine.yml の bash_conditional 定義から始めてください。現在のチェックを、Ansible の条件ですでに使われている LXC 検出と比較し、提案されている /run/systemd/container のチェックを一貫して追加してください。OVAL と Bash の両方のチェックで LXC ゲストがコンテナーとして検出され、ホスト専用ルールが適用対象外となり、その修正がゲスト内で実行されない状態になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description of problem:
The applicability check installed_env_is_a_container (and its negation installed_env_is_a_machine) only looks for /.dockerenv and /run/.containerenv. LXC/Incus system containers create neither file, so an LXC guest is classified as machine (bare metal or VM).
This contradicts the Ansible side of the same platforms. ansible_conditional in shared/applicability/container.yml and machine.yml already counts lxc (and openvz) as a container. Only the OVAL check and bash_conditional miss it.
Impact on a Debian 13 guest in an unprivileged LXC, profile cis_level1_server:
- Eight rules gated by
machine,not_containerornot_bootc_and_not_containerare evaluated and fail. None of them can be fixed inside the guest, because AppArmor,/dev/shmand the partition layout are owned by the host:
grub2_enable_apparmor,package_apparmor_installed,package_apparmor-utils_installed,sysctl_reapply_after_network,mount_option_dev_shm_nodev,mount_option_dev_shm_noexec,mount_option_dev_shm_nosuid,partition_for_tmp - The bash remediations use the same file-based conditional, so they do run inside the container and damage it:
sysctl_reapply_after_networkinstallssysctl-reapply-network.servicerunningsysctl --system. In an unprivileged container thekernel.*,fs.*andvm.*keys are read-only, so the unit always exits non-zero and the system ends updegraded.- The
/tmpmount-option remediation writes/etc/systemd/system/tmp.mount.d/mount_options.conffrom the currently active options. In an idmapped unprivileged container these includeuid=100000,gid=100000(the host-side ID of container root).tmp.mountthen fails withtmpfs: Invalid uid '100000', and/tmpis no longer mounted after the next boot.
SCAP Security Guide Version:
0.1.82 (ssg-debian13-ds.xml). The applicability sources are unchanged on master (checked at bb706dd, 2026-11-06).
Operating System Version:
Debian 13.7 (trixie), systemd 257.13, OpenSCAP 1.4.2. The guest is an unprivileged LXC on Proxmox VE (host kernel 7.0.14-22-pve).
Steps to Reproduce:
- Start any Debian 13 unprivileged LXC/Incus guest with systemd as PID 1.
- Observe:
systemd-detect-virt→lxc,cat /run/systemd/container→lxc. Neither/.dockerenvnor/run/.containerenvexists. oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_level1_server --results results.xml ssg-debian13-ds.xml- Generate and run the bash remediation for
sysctl_reapply_after_network, or for the/tmpmount options.
Actual Results:
The guest is classified as machine. The eight host-only rules above fail, and their remediations run and break the guest (failed unit, /tmp not mounted).
Expected Results:
The guest is classified as a container, as the Ansible conditionals already do. Host-only rules are notapplicable, and the bash remediations print Remediation is not applicable, nothing was done.
Additional Information/Debugging Steps:
Proposed fix: systemd's PID 1 writes /run/systemd/container whenever the container manager sets the container= environment variable (write_container_id() in src/core/main.c). LXC, Incus/LXD, systemd-nspawn and Podman all set it. One more criterion would therefore cover every systemd-based container:
- OVAL (
shared/applicability/oval/installed_env_is_a_container.xml): a thirdfile_testwithcheck_existence="all_exist"for/run/systemd/container, OR-ed with the existing two. bash_conditionalincontainer.yml:[ -f /.dockerenv ] || [ -f /run/.containerenv ] || [ -f /run/systemd/container ], and the negated form inmachine.yml.
Guests without systemd still expose container= in /proc/1/environ, which could be added later if wanted.
With LXC recognised as a container, a second gap becomes the dominant one: system_with_kernel switches off most userspace rules in system containers. I filed that separately as a proposal: #15317.
I'm happy to open a PR for the detection fix.
- 主要言語
- Shell
- スター
- 2.8k
- フォーク
- 847
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 81
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ComplianceAsCode/content のほかの issue
-
triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ComplianceAsCode/content#15241 ·
メンテナーはふだん 2 日以内に返信
-
triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ComplianceAsCode/content#15172 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Rules of audit_rules_dac_modification template are misaligned with DISA再び着手できるかも @macko1 が 46 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンproductization-issue RHEL10 STIG triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ComplianceAsCode/content#15135 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ComplianceAsCode/content#14994 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
triaged
難易度 2/5 半日 初心者へのやさしさ 62/100
ComplianceAsCode/content#12264 ·
メンテナーはふだん 2 日以内に返信
ComplianceAsCode/content の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
cloudflare/skills#279 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
package-update
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: ios S3: minor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
manaflow-ai/cmux#38748 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
marlonrichert/zsh-snap#324 ·