Container detection misses LXC/Incus and other systemd-managed containers; host-only rules and their remediations run inside the guest
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
Línea de trabajo
Empieza por shared/applicability/oval/installed_env_is_a_container.xml y las definiciones de bash_conditional en shared/applicability/container.yml y machine.yml. Compara sus comprobaciones actuales con la detección de LXC que ya utilizan las condiciones de Ansible y, después, añade de forma coherente la comprobación propuesta de /run/systemd/container. El objetivo se cumple cuando tanto OVAL como las comprobaciones de Bash detectan los huéspedes LXC como contenedores, de modo que las reglas exclusivas del host no sean aplicables y sus correcciones no se ejecuten dentro del huésped.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Shell
- Estrellas
- 2.8k
- Forks
- 847
- Merge medio
- 3 d 10 h
- PR fusionados (30 d)
- 81
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ComplianceAsCode/content
-
triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ComplianceAsCode/content#15241 ·
Los mantenedores suelen responder en 2 días
-
triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ComplianceAsCode/content#15172 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Rules of audit_rules_dac_modification template are misaligned with DISAQuizá libre de nuevo @macko1 la tomó hace 46 días y no hay ningún pull request abierto. Abiertoproductization-issue RHEL10 STIG triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ComplianceAsCode/content#15135 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ComplianceAsCode/content#14994 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
triaged
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
ComplianceAsCode/content#12264 ·
Los mantenedores suelen responder en 2 días
Todos los issues de ComplianceAsCode/content
Issues similares
-
agents-sdk: webhooks-push.md handler reads the request body twice, so verified webhooks failAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
cloudflare/skills#279 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Update lemonade-server to 3930Abiertopackage-update
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
area: ios S3: minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
manaflow-ai/cmux#38748 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
marlonrichert/zsh-snap#324 ·