From c6ff76749315f7909fecc3d447a05ae236976f11 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:09:21 +0900 Subject: [PATCH 1/6] feat: stig-ubuntu2204: 27 controls of the DISA STIG for Ubuntu 22.04, and the generic checks they need --- README.ko.md | 2 +- README.md | 3 +- docs/README.ko.md | 1 + docs/README.md | 1 + docs/rules.ko.md | 258 +++++++++++++++++++++++++++++++ docs/rules.md | 258 +++++++++++++++++++++++++++++++ docs/stig.ko.md | 44 ++++++ docs/stig.md | 43 ++++++ internal/engine/pack_test.go | 5 +- profiles/stig-ubuntu2204.yaml | 184 ++++++++++++++++++++++ rules/accounts/root-locked.yaml | 48 ++++++ rules/firewall/ufw-active.yaml | 44 ++++++ rules/packages/absent.yaml | 50 ++++++ rules/packages/installed.yaml | 50 ++++++ rules/services/unit-enabled.yaml | 60 +++++++ rules/services/unit-masked.yaml | 52 +++++++ 16 files changed, 1099 insertions(+), 4 deletions(-) create mode 100644 docs/stig.ko.md create mode 100644 docs/stig.md create mode 100644 profiles/stig-ubuntu2204.yaml create mode 100644 rules/accounts/root-locked.yaml create mode 100644 rules/firewall/ufw-active.yaml create mode 100644 rules/packages/absent.yaml create mode 100644 rules/packages/installed.yaml create mode 100644 rules/services/unit-enabled.yaml create mode 100644 rules/services/unit-masked.yaml diff --git a/README.ko.md b/README.ko.md index 8dc8d13..58c40a6 100644 --- a/README.ko.md +++ b/README.ko.md @@ -195,7 +195,7 @@ sudo vmsctl scan --config vmsctl.yaml ## 무엇을 점검하나 -`kisa-2026` 프로파일은 KISA 가이드(2026년판)의 Unix 점검 항목 67개를 모두 담았습니다. 점검 항목별 점검 내용, 매개변수, +`kisa-2026` 프로파일은 KISA 가이드(2026년판)의 Unix 점검 항목 67개를 모두 담았고, `stig-ubuntu2204`는 미국 DISA의 Ubuntu 22.04 STIG 중 vmsctl이 판정할 수 있는 27개를 담았습니다([점검 범위](docs/stig.ko.md)). 점검 항목별 점검 내용, 매개변수, 조치 방법은 [규칙 참조](docs/rules.ko.md)에 한국어로 있고, KISA 점검 항목만 모은 [웹 페이지](https://with-developer.github.io/vmsctl/ko/kisa/)도 있습니다. - **계정 관리 (U-01–U-13):** root 원격 접속, 비밀번호 길이·복잡도·사용 기간, 계정 잠금, 비밀번호 diff --git a/README.md b/README.md index 66471f3..3079b1d 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,8 @@ or a scan that could not run, 130 when interrupted. ## What it checks -The `kisa-2026` profile maps all 67 Unix controls of the KISA guide (2026 edition); the +The `kisa-2026` profile maps all 67 Unix controls of the KISA guide (2026 edition), and `stig-ubuntu2204` the 27 controls +of the US DISA STIG for Ubuntu 22.04 that vmsctl can decide ([what it covers](docs/stig.md)); the [rule reference](docs/rules.md) lists every control with the checks, parameters and fixes behind it: - **Accounts (U-01–U-13):** remote root login, password length, complexity and aging, lockout, diff --git a/docs/README.ko.md b/docs/README.ko.md index 6897220..b3fef50 100644 --- a/docs/README.ko.md +++ b/docs/README.ko.md @@ -12,6 +12,7 @@ | [vmsctl을 컨테이너로 실행하기](container.ko.md) | 릴리스 이미지, 점검할 수 있는 것, 이미지 검증 | | [서버와 대시보드](fleet.ko.md) | 결과 보내기, 요청 시 스캔용 에이전트, 토큰, 서명된 결과, API, 서버 운영 | | [설정](configuration.ko.md) | `vmsctl.yaml`: 매개변수, 예외, 증명 | +| [DISA STIG 프로파일](stig.ko.md) | `stig-ubuntu2204`: Ubuntu 22.04용 미국 기준, 어디까지 점검하고 무엇은 점검하지 않는지 | | [정책 팩](packs.ko.md) | 직접 만드는 점검과 프로파일 | | [hostlint에서 옮기기](migrating-from-hostlint.ko.md) | v0.27의 이름 변경 | | [다른 도구와 비교](comparison.ko.md) | Lynis, OpenSCAP, Wazuh와 비교하고, 어떤 경우에 그쪽을 고를지 | diff --git a/docs/README.md b/docs/README.md index 3d8a020..f26b725 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,6 +11,7 @@ | [Running vmsctl as a container](container.md) | the release image, what it can scan, verifying it | | [The fleet server and dashboard](fleet.md) | pushing results, the agent for on-demand scans, tokens, signed results, the API, running the server | | [Configuration](configuration.md) | `vmsctl.yaml`: parameters, waivers, attestations | +| [The DISA STIG profile](stig.md) | `stig-ubuntu2204`: the US baseline for Ubuntu 22.04, what it covers and what it does not | | [Policy packs](packs.md) | your own checks and profiles | | [Moving from hostlint](migrating-from-hostlint.md) | the rename in v0.27 | | [How vmsctl compares](comparison.md) | with Lynis, OpenSCAP and Wazuh, and when to pick them | diff --git a/docs/rules.ko.md b/docs/rules.ko.md index c75fcf2..5cbf248 100644 --- a/docs/rules.ko.md +++ b/docs/rules.ko.md @@ -1849,3 +1849,261 @@ OpenSSH 서버의 전역 PermitRootLogin 설정을 확인합니다. 실행 중 **이유.** root로 직접 로그인하면 누가 접속했는지 추적할 수 없고, 가장 강한 권한을 가진 계정이 비밀번호 추측과 키 유출에 그대로 노출됩니다. **조치 방법.** /etc/ssh/sshd_config(또는 그 파일이 포함하는 파일)에 `PermitRootLogin no`를 설정하고 sshd를 다시 불러오세요. 관리자는 각자의 계정으로 로그인한 뒤 sudo나 su를 사용합니다. + +## stig-ubuntu2204 (리비전 1) + +Canonical Ubuntu 22.04 LTS STIG(V2R8) 중 vmsctl이 점검하는 항목 + +| 점검 항목 | 심각도 | 제목 | 점검 | +|---|---|---|---| +| UBTU-22-211015 | 높음 | Ctrl-Alt-Delete로 호스트가 재부팅되지 않음 | [`services.unit-masked`](#servicesunit-masked) | +| UBTU-22-213010 | 낮음 | 커널 메시지를 권한 있는 사용자만 볼 수 있음 | [`sysctl.dmesg-restrict`](#sysctldmesg-restrict) | +| UBTU-22-213020 | 중간 | 주소 공간 배치 무작위화가 켜져 있음 | [`sysctl.aslr`](#sysctlaslr) | +| UBTU-22-215010 | 중간 | 비밀번호 품질 라이브러리가 설치되어 있음 | [`packages.installed`](#packagesinstalled) | +| UBTU-22-215015 | 낮음 | chrony가 설치되어 있음 | [`packages.installed`](#packagesinstalled) | +| UBTU-22-215020 | 낮음 | systemd-timesyncd가 설치되어 있지 않음 | [`packages.absent`](#packagesabsent) | +| UBTU-22-215025 | 낮음 | ntp가 설치되어 있지 않음 | [`packages.absent`](#packagesabsent) | +| UBTU-22-215030 | 높음 | rsh 서버가 설치되어 있지 않음 | [`packages.absent`](#packagesabsent) | +| UBTU-22-215035 | 높음 | telnet 서버가 설치되어 있지 않음 | [`packages.absent`](#packagesabsent) | +| UBTU-22-215040 | 중간 | NFS 서버가 설치되어 있지 않음 | [`packages.absent`](#packagesabsent) | +| UBTU-22-251010 | 중간 | ufw가 설치되어 있음 | [`packages.installed`](#packagesinstalled) | +| UBTU-22-251015 | 중간 | ufw가 켜져 있음 | [`firewall.ufw-active`](#firewallufw-active) | +| UBTU-22-251020 | 중간 | ufw 서비스가 부팅할 때 시작함 | [`services.unit-enabled`](#servicesunit-enabled) | +| UBTU-22-253010 | 중간 | TCP SYN 쿠키가 켜져 있음 | [`sysctl.syncookies`](#sysctlsyncookies) | +| UBTU-22-255010 | 높음 | SSH 서버가 설치되어 있음 | [`packages.installed`](#packagesinstalled) | +| UBTU-22-255015 | 높음 | SSH 서비스가 부팅할 때 시작함 | [`services.unit-enabled`](#servicesunit-enabled) | +| UBTU-22-255025 | 높음 | SSH가 빈 비밀번호와 사용자 환경 변수를 허용하지 않음 | [`ssh.permit-empty-passwords`](#sshpermit-empty-passwords), [`ssh.permit-user-environment`](#sshpermit-user-environment) | +| UBTU-22-255040 | 높음 | SSH가 X11을 전달하지 않음 | [`ssh.x11-forwarding`](#sshx11-forwarding) | +| UBTU-22-411010 | 중간 | root 계정이 잠겨 있음 | [`accounts.root-locked`](#accountsroot-locked) | +| UBTU-22-411015 | 중간 | 계정마다 고유한 UID를 가짐 | [`accounts.unique-uids`](#accountsunique-uids) | +| UBTU-22-411025 | 중간 | 비밀번호를 하루 안에 다시 바꿀 수 없음 | [`accounts.password-min-age`](#accountspassword-min-age) | +| UBTU-22-411030 | 중간 | 비밀번호가 60일 뒤에 만료됨 | [`accounts.password-max-age`](#accountspassword-max-age) | +| UBTU-22-412030 | 중간 | 유휴 셸 세션이 15분 뒤에 끝남 | [`accounts.session-timeout-set`](#accountssession-timeout-set), [`accounts.session-timeout-value`](#accountssession-timeout-value) | +| UBTU-22-431010 | 중간 | AppArmor가 설치되어 있음 | [`packages.installed`](#packagesinstalled) | +| UBTU-22-611035 | 중간 | 비밀번호가 15자 이상임 | [`accounts.password-min-length`](#accountspassword-min-length) | +| UBTU-22-611065 | 높음 | 비밀번호가 비어 있는 계정이 없음 | [`accounts.no-empty-passwords`](#accountsno-empty-passwords) | +| UBTU-22-653010 | 중간 | 감사 데몬(auditd)이 설치되어 있음 | [`packages.installed`](#packagesinstalled) | + +### 점검 + +#### `accounts.no-empty-passwords` + +비밀번호가 비어 있는 계정이 없음 — 심각도 높음, 위반하는 것을 나열합니다. + +/etc/shadow에서 비밀번호 필드가 비어 있는 계정을 나열합니다. PAM이 허용하는 곳(pam_unix의 nullok 옵션이며, 일부 기본 설정에 아직 들어 있습니다)에서는 비밀번호 없이 그 계정을 쓸 수 있다는 뜻입니다. 잠긴 계정("!"나 "*")은 나열하지 않습니다. /etc/shadow가 없으면 확인할 것이 없으므로 이 점검은 통과할 수 없습니다. + +**이유.** 비밀번호가 없는 계정은 로그인 화면, 콘솔, su에 닿을 수 있는 누구나 쓸 수 있습니다. + +**조치 방법.** 나열된 계정마다 비밀번호를 정하거나(`passwd 사용자`) 잠그세요(`passwd -l 사용자`). PAM 설정의 pam_unix 줄에서 `nullok`을 지우면 빈 비밀번호를 거부합니다. + +#### `accounts.password-max-age` + +비밀번호가 만료됨 — 심각도 중간, 설정 하나를 비교합니다. + +/etc/login.defs의 PASS_MAX_DAYS, 즉 새 계정에 주는 비밀번호 최대 사용 기간을 확인합니다. 이 값이 없으면 shadow-utils는 -1을 쓰는데, 비밀번호가 만료되지 않는다는 뜻입니다. + +**이유.** 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다. + +**조치 방법.** /etc/login.defs에 `PASS_MAX_DAYS 90`(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요. + +**매개변수** (설명은 영어). + +- `max_days` (int, 기본값 `90`, 더 낮을수록 엄격): Maximum password age in days + +#### `accounts.password-min-age` + +비밀번호를 바로 되돌려 바꿀 수 없음 — 심각도 낮음, 설정 하나를 비교합니다. + +/etc/login.defs의 PASS_MIN_DAYS, 즉 비밀번호를 바꾸는 간격의 최소 일수를 확인합니다. + +**이유.** 최소 사용 기간이 없으면 사용자가 몇 분 만에 비밀번호를 여러 번 바꿔 예전 비밀번호로 돌아갈 수 있어서 비밀번호 이력이 무력해집니다. + +**조치 방법.** /etc/login.defs에 `PASS_MIN_DAYS 1`(또는 그 이상)을 설정하세요. + +**매개변수** (설명은 영어). + +- `min_days` (int, 기본값 `1`, 더 높을수록 엄격): Minimum password age in days + +#### `accounts.password-min-length` + +비밀번호에 최소 길이가 있음 — 심각도 높음, 식을 평가합니다. + +passwd 서비스의 PAM 스택이 경고만 하는 모드가 아닌 상태로 비밀번호 품질 검사(pam_pwquality 또는 pam_cracklib)를 하고, 최소 길이를 `min_length`자 이상으로 요구하는지 확인합니다. 양수 크레딧은 합계만큼 비밀번호를 더 짧게 만들 수 있으므로 minlen에서 뺍니다. + +**이유.** 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다. + +**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 `minlen = 8` 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요. + +**매개변수** (설명은 영어). + +- `min_length` (int, 기본값 `8`, 더 높을수록 엄격): Minimum password length + +#### `accounts.root-locked` + +root 계정에 로그인할 수 있는 비밀번호가 없음 — 심각도 중간, 위반하는 것을 나열합니다. + +/etc/shadow에서 root 계정이 잠겨 있는지(비밀번호 필드가 "!"로 시작하거나 "*") 확인합니다. 잠겨 있으면 비밀번호로 root에 로그인할 수 없고, 관리자는 자기 계정과 sudo를 씁니다. /etc/shadow가 없으면 확인할 것이 없으므로 이 점검은 통과할 수 없습니다. + +**이유.** root 비밀번호는 가장 강한 권한의 계정을 하나의 공유 비밀로 지키는 것이라 누구나 추측하거나 유출할 수 있고, 누가 썼는지도 남지 않습니다. + +**조치 방법.** 관리자가 sudo 그룹의 자기 계정을 갖춘 뒤에 root 비밀번호를 잠그세요(`passwd -l root`). + +#### `accounts.session-timeout-set` + +유휴 셸이 자동으로 끝남 — 심각도 낮음, 설정 하나를 비교합니다. + +시스템 전체 시작 파일(/etc/environment, /etc/profile과 그 파일이 읽는 /etc/profile.d 등)이 TMOUT을 양수 초로 설정해 두어서 모든 사용자의 로그인 셸에 적용되는지 확인합니다. root 자신의 파일에만 설정한 값은 인정하지 않고, if나 case 블록 안의 대입도 인정하지 않으며, 나중에 unset하면 설정이 사라집니다. + +**이유.** 로그인한 채 방치된 터미널은 그 앞에 접근한 누구나 쓸 수 있습니다. + +**조치 방법.** /etc/profile.d의 파일에 `TMOUT=600`, `readonly TMOUT`, `export TMOUT`을 추가하세요. + +#### `accounts.session-timeout-value` + +유휴 시간 제한이 충분히 짧음 — 심각도 낮음, 위반하는 것을 나열합니다. + +비어 있거나 0이거나 `max_seconds`보다 긴 TMOUT 대입과, TMOUT을 unset하는 명령을 나열합니다. 일부 세션에만 적용될 수 있는 if나 case 블록 안의 것도 포함합니다. + +**이유.** 제한 시간이 길거나 꺼져 있으면 유휴 세션이 열린 채 남습니다. + +**조치 방법.** `TMOUT=600`(또는 그보다 짧은 값)을 설정하고, 더 큰 값의 대입과 unset 명령은 지우세요. + +**매개변수** (설명은 영어). + +- `max_seconds` (int, 기본값 `600`, 더 낮을수록 엄격): Longest acceptable idle timeout in seconds + +#### `accounts.unique-uids` + +계정마다 UID가 다름 — 심각도 중간, 위반하는 것을 나열합니다. + +다른 계정과 UID가 같은 계정을 나열합니다. + +**이유.** UID가 같은 계정은 커널에게 같은 사용자이므로, 접근 권한과 감사 기록으로는 서로 구분할 수 없습니다. + +**조치 방법.** 계정마다 고유한 UID를 주고(`usermod -u`), 그 계정의 파일 소유자를 바로잡으세요. + +#### `firewall.ufw-active` + +ufw가 켜져 있음 — 심각도 중간, 식을 평가합니다. + +/etc/ufw/ufw.conf에 ENABLED=yes가 있는지 확인합니다. 이 값이 있어야 ufw가 부팅할 때 필터링을 시작합니다(패키지를 설치하면 유닛이 켜지므로 유닛만으로는 알 수 없습니다). ufw가 없으면 켤 것이 없으므로 실패합니다. Ubuntu STIG처럼 ufw 자체를 요구하는 프로파일을 위한 점검이며, firewall.enabled는 어떤 호스트 방화벽이든 받아들입니다. + +**이유.** 방화벽이 없으면 주소에서 대기 중인 모든 서비스가 접근할 수 있는 모든 사람에게 열립니다. + +**조치 방법.** 호스트가 제공하는 서비스를 허용한 뒤 ufw를 켜세요. `ufw allow 22/tcp` 후 `ufw enable`입니다. 지금 쓰고 있는 SSH 접속을 먼저 허용하세요. + +#### `packages.absent` + +점검 항목이 금지하는 패키지가 설치되어 있지 않음 — 심각도 중간, 식을 평가합니다. + +매개변수 `package`가 가리키는 패키지가 설치되어 있지 않은지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 정합니다. 매개변수는 프로파일만 정합니다. + +**이유.** 필요하지 않은 패키지는 계속 패치해야 하고 공격받을 수 있는 코드와, 대개는 대기 중인 서비스를 더합니다. + +**조치 방법.** 패키지 관리자로 제거하세요(예: `apt remove 패키지`). + +**매개변수** (설명은 영어). + +- `package` (string, 기본값 ``): The name of the package that must not be installed + +#### `packages.installed` + +점검 항목이 요구하는 패키지가 설치되어 있음 — 심각도 중간, 식을 평가합니다. + +매개변수 `package`가 가리키는 패키지가 설치되어 있는지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 정합니다. 제거했지만 설정 파일이 남은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. + +**이유.** 보안 도구나 서비스가 있어야 하는 점검 항목은 그 패키지가 없으면 충족할 수 없습니다. + +**조치 방법.** 패키지 관리자로 설치하세요(예: `apt install 패키지`). + +**매개변수** (설명은 영어). + +- `package` (string, 기본값 ``): The name of the package that must be installed + +#### `services.unit-enabled` + +점검 항목이 요구하는 systemd 유닛이 활성화되어 있음 — 심각도 중간, 식을 평가합니다. + +매개변수 `unit`이 가리키는 systemd 유닛(예: ssh.service)이 활성화되어 있어 부팅할 때 시작하고, 마스크되어 있지 않은지 확인합니다. 어느 유닛인지는 이 점검을 쓰는 프로파일이 정합니다. 매개변수는 프로파일만 정합니다. + +**이유.** 서비스가 실행되어야 하는 점검 항목은 서비스가 저절로 시작하지 않으면 충족할 수 없습니다. + +**조치 방법.** 유닛을 활성화하세요(`systemctl enable --now 유닛`). 마스크되어 있다면 먼저 풀어야 합니다(`systemctl unmask 유닛`). + +**매개변수** (설명은 영어). + +- `unit` (string, 기본값 ``): The systemd unit that must be enabled, for example ssh.service + +#### `services.unit-masked` + +점검 항목이 금지하는 systemd 유닛이 마스크되어 있음 — 심각도 중간, 식을 평가합니다. + +매개변수 `unit`이 가리키는 systemd 유닛(예: ctrl-alt-del.target)이 마스크되어 있는지, 즉 /dev/null에 연결되어 아무것도 그 유닛을 시작할 수 없는지 확인합니다. 어느 유닛인지는 이 점검을 쓰는 프로파일이 정합니다. 매개변수는 프로파일만 정합니다. + +**이유.** 서버에서 절대 실행되면 안 되는 유닛(키 입력으로 재부팅하는 것, 있을 곳이 없는 서비스)이 있습니다. 마스크해야 다른 유닛이나 사람이 시작하는 것까지 막을 수 있습니다. + +**조치 방법.** 유닛을 마스크하세요(`systemctl mask 유닛`). + +**매개변수** (설명은 영어). + +- `unit` (string, 기본값 ``): The systemd unit that must be masked, for example ctrl-alt-del.target + +#### `ssh.permit-empty-passwords` + +SSH가 빈 비밀번호를 받지 않음 — 심각도 높음, 설정 하나를 비교합니다. + +OpenSSH 서버의 전역 PermitEmptyPasswords 설정을 확인합니다. 실행 중인 호스트에서는 `sshd -T`가 알려 주는 실제 적용값을 쓰므로, 설치된 버전의 기본값도 함께 반영됩니다. + +**이유.** 비밀번호가 없는 계정이 있으면 누구든 네트워크를 통해 그 계정으로 로그인할 수 있습니다. + +**조치 방법.** /etc/ssh/sshd_config(또는 그 파일이 포함하는 파일)에 `PermitEmptyPasswords no`를 설정하고 sshd를 다시 불러오세요. + +#### `ssh.permit-user-environment` + +SSH가 사용자의 환경 변수 설정을 허용하지 않음 — 심각도 중간, 설정 하나를 비교합니다. + +OpenSSH 서버의 전역 PermitUserEnvironment 설정을 확인합니다. 실행 중인 호스트에서는 `sshd -T`가 알려 주는 실제 적용값을 쓰므로, 설치된 버전의 기본값도 함께 반영됩니다. + +**이유.** 사용자가 자기 파일로 지정하는 환경 변수는 로그인 셸과 PAM 모듈의 동작을 바꿀 수 있어서, 그 계정에 걸어 둔 제한을 무력화합니다. + +**조치 방법.** /etc/ssh/sshd_config(또는 그 파일이 포함하는 파일)에 `PermitUserEnvironment no`를 설정하고 sshd를 다시 불러오세요. + +#### `ssh.x11-forwarding` + +SSH가 X11을 전달하지 않음 — 심각도 낮음, 설정 하나를 비교합니다. + +OpenSSH 서버의 전역 X11Forwarding 설정을 확인합니다. 실행 중인 호스트에서는 `sshd -T`가 알려 주는 실제 적용값을 쓰므로, 설치된 버전의 기본값도 함께 반영됩니다. + +**이유.** X11 전달은 클라이언트의 화면을 서버에 노출합니다. 서버를 장악한 쪽은 그 화면을 몰래 보거나 조작할 수 있습니다. + +**조치 방법.** /etc/ssh/sshd_config(또는 그 파일이 포함하는 파일)에 `X11Forwarding no`를 설정하고 sshd를 다시 불러오세요. + +#### `sysctl.aslr` + +주소 공간 배치 무작위화가 완전히 켜져 있음 — 심각도 중간, 설정 하나를 비교합니다. + +커널 매개변수 kernel.randomize_va_space를 확인합니다(스택, 라이브러리, 힙을 모두 무작위로 배치하는 2여야 합니다). 실행 중인 호스트에서는 커널이 알려 주는 값을 쓰고, 마운트한 루트에서는 부팅할 때 sysctl.d(5)의 파일이 정하는 값을 씁니다. 그 파일이 정하지 않은 매개변수는 판단할 수 없습니다. + +**이유.** 주소를 무작위로 배치하면 메모리 손상 취약점을 실제로 동작하는 공격으로 바꾸기가 훨씬 어려워집니다. + +**조치 방법.** /etc/sysctl.d의 파일에 `kernel.randomize_va_space = 2`를 설정하고 `sysctl --system`으로 적용하세요. + +#### `sysctl.dmesg-restrict` + +커널 로그는 권한 있는 사용자만 읽을 수 있음 — 심각도 낮음, 설정 하나를 비교합니다. + +커널 매개변수 kernel.dmesg_restrict를 확인합니다(1이면 dmesg를 권한 있는 사용자만 볼 수 있습니다). 실행 중인 호스트에서는 커널이 알려 주는 값을 쓰고, 마운트한 루트에서는 부팅할 때 sysctl.d(5)의 파일이 정하는 값을 씁니다. 그 파일이 정하지 않은 매개변수는 판단할 수 없습니다. + +**이유.** 커널 로그에는 주소, 장치 정보, 실패한 공격의 흔적이 나타날 수 있습니다. + +**조치 방법.** /etc/sysctl.d의 파일에 `kernel.dmesg_restrict = 1`을 설정하고 `sysctl --system`으로 적용하세요. + +#### `sysctl.syncookies` + +TCP SYN 쿠키가 켜져 있음 — 심각도 중간, 설정 하나를 비교합니다. + +커널 매개변수 net.ipv4.tcp_syncookies를 확인합니다(1이면 연결 대기열이 가득 찼을 때 쏟아지는 연결 시도에 쿠키로 응답합니다). 실행 중인 호스트에서는 커널이 알려 주는 값을 쓰고, 마운트한 루트에서는 부팅할 때 sysctl.d(5)의 파일이 정하는 값을 씁니다. 그 파일이 정하지 않은 매개변수는 판단할 수 없습니다. + +**이유.** SYN 쿠키는 반쯤 열린 연결이 쏟아져도 연결 대기열의 메모리가 바닥나지 않게 막아 줍니다. + +**조치 방법.** /etc/sysctl.d의 파일에 `net.ipv4.tcp_syncookies = 1`을 설정하고 `sysctl --system`으로 적용하세요. diff --git a/docs/rules.md b/docs/rules.md index 66ae421..3487a3f 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -1850,3 +1850,261 @@ Checks the global PermitRootLogin setting of the OpenSSH server. On a live host **Why.** Direct root logins remove accountability and expose the most privileged account to password guessing and stolen keys. **Fix.** Set `PermitRootLogin no` in /etc/ssh/sshd_config (or a file it includes) and reload sshd. Administrators log in with their own accounts and use sudo or su. + +## stig-ubuntu2204 (revision 1) + +Canonical Ubuntu 22.04 LTS STIG (V2R8), the controls vmsctl checks + +| Control | Severity | Title | Checks | +|---|---|---|---| +| UBTU-22-211015 | high | Ctrl-Alt-Delete does not reboot the host (Ctrl-Alt-Delete로 호스트가 재부팅되지 않음) | [`services.unit-masked`](#servicesunit-masked) | +| UBTU-22-213010 | low | Kernel messages are restricted to privileged users (커널 메시지를 권한 있는 사용자만 볼 수 있음) | [`sysctl.dmesg-restrict`](#sysctldmesg-restrict) | +| UBTU-22-213020 | medium | Address space layout randomization is on (주소 공간 배치 무작위화가 켜져 있음) | [`sysctl.aslr`](#sysctlaslr) | +| UBTU-22-215010 | medium | The password quality library is installed (비밀번호 품질 라이브러리가 설치되어 있음) | [`packages.installed`](#packagesinstalled) | +| UBTU-22-215015 | low | chrony is installed (chrony가 설치되어 있음) | [`packages.installed`](#packagesinstalled) | +| UBTU-22-215020 | low | systemd-timesyncd is not installed (systemd-timesyncd가 설치되어 있지 않음) | [`packages.absent`](#packagesabsent) | +| UBTU-22-215025 | low | ntp is not installed (ntp가 설치되어 있지 않음) | [`packages.absent`](#packagesabsent) | +| UBTU-22-215030 | high | The rsh server is not installed (rsh 서버가 설치되어 있지 않음) | [`packages.absent`](#packagesabsent) | +| UBTU-22-215035 | high | The telnet server is not installed (telnet 서버가 설치되어 있지 않음) | [`packages.absent`](#packagesabsent) | +| UBTU-22-215040 | medium | The NFS server is not installed (NFS 서버가 설치되어 있지 않음) | [`packages.absent`](#packagesabsent) | +| UBTU-22-251010 | medium | ufw is installed (ufw가 설치되어 있음) | [`packages.installed`](#packagesinstalled) | +| UBTU-22-251015 | medium | ufw is turned on (ufw가 켜져 있음) | [`firewall.ufw-active`](#firewallufw-active) | +| UBTU-22-251020 | medium | The ufw service starts at boot (ufw 서비스가 부팅할 때 시작함) | [`services.unit-enabled`](#servicesunit-enabled) | +| UBTU-22-253010 | medium | TCP SYN cookies are on (TCP SYN 쿠키가 켜져 있음) | [`sysctl.syncookies`](#sysctlsyncookies) | +| UBTU-22-255010 | high | The SSH server is installed (SSH 서버가 설치되어 있음) | [`packages.installed`](#packagesinstalled) | +| UBTU-22-255015 | high | The SSH service starts at boot (SSH 서비스가 부팅할 때 시작함) | [`services.unit-enabled`](#servicesunit-enabled) | +| UBTU-22-255025 | high | SSH allows no empty passwords and no user environment (SSH가 빈 비밀번호와 사용자 환경 변수를 허용하지 않음) | [`ssh.permit-empty-passwords`](#sshpermit-empty-passwords), [`ssh.permit-user-environment`](#sshpermit-user-environment) | +| UBTU-22-255040 | high | SSH does not forward X11 (SSH가 X11을 전달하지 않음) | [`ssh.x11-forwarding`](#sshx11-forwarding) | +| UBTU-22-411010 | medium | The root account is locked (root 계정이 잠겨 있음) | [`accounts.root-locked`](#accountsroot-locked) | +| UBTU-22-411015 | medium | Every account has its own UID (계정마다 고유한 UID를 가짐) | [`accounts.unique-uids`](#accountsunique-uids) | +| UBTU-22-411025 | medium | A password cannot be changed again within a day (비밀번호를 하루 안에 다시 바꿀 수 없음) | [`accounts.password-min-age`](#accountspassword-min-age) | +| UBTU-22-411030 | medium | A password expires after 60 days (비밀번호가 60일 뒤에 만료됨) | [`accounts.password-max-age`](#accountspassword-max-age) | +| UBTU-22-412030 | medium | An idle shell session ends after 15 minutes (유휴 셸 세션이 15분 뒤에 끝남) | [`accounts.session-timeout-set`](#accountssession-timeout-set), [`accounts.session-timeout-value`](#accountssession-timeout-value) | +| UBTU-22-431010 | medium | AppArmor is installed (AppArmor가 설치되어 있음) | [`packages.installed`](#packagesinstalled) | +| UBTU-22-611035 | medium | A password has at least 15 characters (비밀번호가 15자 이상임) | [`accounts.password-min-length`](#accountspassword-min-length) | +| UBTU-22-611065 | high | No account has an empty password (비밀번호가 비어 있는 계정이 없음) | [`accounts.no-empty-passwords`](#accountsno-empty-passwords) | +| UBTU-22-653010 | medium | The audit daemon is installed (감사 데몬(auditd)이 설치되어 있음) | [`packages.installed`](#packagesinstalled) | + +### Checks + +#### `accounts.no-empty-passwords` + +No account has an empty password (비밀번호가 비어 있는 계정이 없음) — severity high, lists what violates it. + +Lists the accounts whose password field in /etc/shadow is empty, which means no password is needed to use them wherever PAM accepts it (the nullok option of pam_unix, which some default configurations still carry). Locked accounts ("!" or "*") are not listed. Without /etc/shadow there is nothing to check, so the check cannot pass. + +**Why.** An account without a password lets anyone who can reach a login prompt, a console or su use it. + +**Fix.** Set a password for each listed account (`passwd user`), or lock it (`passwd -l user`). Remove `nullok` from the pam_unix lines in the PAM configuration so an empty password is refused. + +#### `accounts.password-max-age` + +Passwords expire (비밀번호가 만료됨) — severity medium, compares one setting. + +Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new accounts. Without it, shadow-utils uses -1, which means passwords never expire. + +**Why.** A password that never changes stays useful to whoever obtained it. + +**Fix.** Set `PASS_MAX_DAYS 90` (or less) in /etc/login.defs; apply it to existing accounts with chage. + +**Parameters.** + +- `max_days` (int, default `90`, lower is stricter): Maximum password age in days + +#### `accounts.password-min-age` + +Passwords cannot be changed back at once (비밀번호를 바로 되돌려 바꿀 수 없음) — severity low, compares one setting. + +Checks PASS_MIN_DAYS in /etc/login.defs, the minimum days between password changes. + +**Why.** Without a minimum age, a user can cycle through passwords in minutes to get back to the old one and defeat the password history. + +**Fix.** Set `PASS_MIN_DAYS 1` (or more) in /etc/login.defs. + +**Parameters.** + +- `min_days` (int, default `1`, higher is stricter): Minimum password age in days + +#### `accounts.password-min-length` + +Passwords have a minimum length (비밀번호에 최소 길이가 있음) — severity high, evaluates an expression. + +Checks that the passwd service's PAM stack enforces password quality (pam_pwquality or pam_cracklib, not in warning-only mode) with a minimum length of at least `min_length` characters. Positive credits let a password be shorter by up to their sum, so they count against minlen. + +**Why.** Short passwords fall quickly to guessing and offline cracking. + +**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen = 8` or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits. + +**Parameters.** + +- `min_length` (int, default `8`, higher is stricter): Minimum password length + +#### `accounts.root-locked` + +The root account has no password that can log in (root 계정에 로그인할 수 있는 비밀번호가 없음) — severity medium, lists what violates it. + +Checks in /etc/shadow that the root account is locked (its password field starts with "!" or is "*"), so no password logs in as root. Administrators use their own accounts and sudo. Without /etc/shadow there is nothing to check, so the check cannot pass. + +**Why.** A root password is a shared secret for the most powerful account, which anyone can guess or leak and which says nothing about who used it. + +**Fix.** Lock the root password (`passwd -l root`) after an administrator has an account in the sudo group. + +#### `accounts.session-timeout-set` + +Idle shells time out (유휴 셸이 자동으로 끝남) — severity low, compares one setting. + +Checks that the system-wide startup files (/etc/environment, /etc/profile and the files it reads, such as /etc/profile.d) leave TMOUT set to a positive number of seconds, so that it applies to every user's login shell: a value set only in root's own files does not count, assignments inside if or case blocks do not count, and a later unset removes it. + +**Why.** An unattended logged-in terminal can be used by anyone who reaches it. + +**Fix.** Add `TMOUT=600` and `readonly TMOUT` and `export TMOUT` to a file in /etc/profile.d. + +#### `accounts.session-timeout-value` + +The idle timeout is short enough (유휴 시간 제한이 충분히 짧음) — severity low, lists what violates it. + +Lists TMOUT assignments that are empty, zero or longer than `max_seconds`, and unset TMOUT commands, including those inside if or case blocks, which can apply to some sessions. + +**Why.** A long or disabled timeout leaves idle sessions open. + +**Fix.** Set `TMOUT=600` (or less) and remove larger assignments and unset commands. + +**Parameters.** + +- `max_seconds` (int, default `600`, lower is stricter): Longest acceptable idle timeout in seconds + +#### `accounts.unique-uids` + +Every account has its own UID (계정마다 UID가 다름) — severity medium, lists what violates it. + +Lists accounts that share a UID with another account. + +**Why.** Accounts sharing a UID are the same user to the kernel, so access and audit trails cannot tell them apart. + +**Fix.** Give each account a unique UID (usermod -u) and fix the ownership of its files. + +#### `firewall.ufw-active` + +ufw is turned on (ufw가 켜져 있음) — severity medium, evaluates an expression. + +Checks that /etc/ufw/ufw.conf sets ENABLED=yes, which is what makes ufw filter at boot (installing the package enables its unit, so the unit alone says nothing). Without ufw there is nothing to turn on, and the check fails: it is for profiles that require ufw itself, such as the Ubuntu STIG; firewall.enabled accepts any host firewall. + +**Why.** Without a firewall, every service that listens on an address is open to everyone who can reach it. + +**Fix.** Allow what the host serves and turn ufw on: `ufw allow 22/tcp`, then `ufw enable`. Allow your own SSH connection first. + +#### `packages.absent` + +A package that the control forbids is not installed (점검 항목이 금지하는 패키지가 설치되어 있지 않음) — severity medium, evaluates an expression. + +Checks that the package named by the parameter `package` is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter. + +**Why.** A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked. + +**Fix.** Remove the package with the package manager (for example `apt remove `). + +**Parameters.** + +- `package` (string, default ``): The name of the package that must not be installed + +#### `packages.installed` + +A package that the control requires is installed (점검 항목이 요구하는 패키지가 설치되어 있음) — severity medium, evaluates an expression. + +Checks that the package named by the parameter `package` is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter. + +**Why.** A control that needs a security tool or a service on the host cannot be met without its package. + +**Fix.** Install the package with the package manager (for example `apt install `). + +**Parameters.** + +- `package` (string, default ``): The name of the package that must be installed + +#### `services.unit-enabled` + +A systemd unit that the control requires is enabled (점검 항목이 요구하는 systemd 유닛이 활성화되어 있음) — severity medium, evaluates an expression. + +Checks that the systemd unit named by the parameter `unit` (such as ssh.service) is enabled, so it starts at boot, and not masked. The profile that uses this check says which unit. Only a profile sets the parameter. + +**Why.** A control that needs a service to run cannot be met if the service does not start by itself. + +**Fix.** Enable the unit (`systemctl enable --now `) and unmask it if it is masked (`systemctl unmask `). + +**Parameters.** + +- `unit` (string, default ``): The systemd unit that must be enabled, for example ssh.service + +#### `services.unit-masked` + +A systemd unit that the control forbids is masked (점검 항목이 금지하는 systemd 유닛이 마스크되어 있음) — severity medium, evaluates an expression. + +Checks that the systemd unit named by the parameter `unit` (such as ctrl-alt-del.target) is masked: linked to /dev/null, so nothing can start it. The profile that uses this check says which unit. Only a profile sets the parameter. + +**Why.** Some units must never run on a server (a key press that reboots it, a service that has no place there); only masking keeps another unit or a person from starting them. + +**Fix.** Mask the unit (`systemctl mask `). + +**Parameters.** + +- `unit` (string, default ``): The systemd unit that must be masked, for example ctrl-alt-del.target + +#### `ssh.permit-empty-passwords` + +SSH does not accept empty passwords (SSH가 빈 비밀번호를 받지 않음) — severity high, compares one setting. + +Checks the global PermitEmptyPasswords setting of the OpenSSH server. On a live host the effective value comes from `sshd -T`, so the default of the installed version counts. + +**Why.** An account without a password would let anyone log in over the network. + +**Fix.** Set `PermitEmptyPasswords no` in /etc/ssh/sshd_config (or a file it includes) and reload sshd. + +#### `ssh.permit-user-environment` + +SSH does not let users set the environment (SSH가 사용자의 환경 변수 설정을 허용하지 않음) — severity medium, compares one setting. + +Checks the global PermitUserEnvironment setting of the OpenSSH server. On a live host the effective value comes from `sshd -T`, so the default of the installed version counts. + +**Why.** Environment settings from a user's own files can change how the login shell and PAM modules behave, which defeats restrictions set for the account. + +**Fix.** Set `PermitUserEnvironment no` in /etc/ssh/sshd_config (or a file it includes) and reload sshd. + +#### `ssh.x11-forwarding` + +SSH does not forward X11 (SSH가 X11을 전달하지 않음) — severity low, compares one setting. + +Checks the global X11Forwarding setting of the OpenSSH server. On a live host the effective value comes from `sshd -T`, so the default of the installed version counts. + +**Why.** X11 forwarding exposes the client's display to the server, and anything that controls the server can then watch or drive it. + +**Fix.** Set `X11Forwarding no` in /etc/ssh/sshd_config (or a file it includes) and reload sshd. + +#### `sysctl.aslr` + +Address space layout randomization is fully on (주소 공간 배치 무작위화가 완전히 켜져 있음) — severity medium, compares one setting. + +Checks the kernel parameter kernel.randomize_va_space (it must be 2: randomize the stack, libraries and the heap). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged. + +**Why.** Randomized addresses make memory-corruption bugs much harder to turn into working exploits. + +**Fix.** Set `kernel.randomize_va_space = 2` in a file of /etc/sysctl.d and apply it with `sysctl --system`. + +#### `sysctl.dmesg-restrict` + +Only privileged users can read the kernel log (커널 로그는 권한 있는 사용자만 읽을 수 있음) — severity low, compares one setting. + +Checks the kernel parameter kernel.dmesg_restrict (1 limits dmesg to privileged users). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged. + +**Why.** The kernel log can show addresses, device details and the traces of failed exploits. + +**Fix.** Set `kernel.dmesg_restrict = 1` in a file of /etc/sysctl.d and apply it with `sysctl --system`. + +#### `sysctl.syncookies` + +TCP SYN cookies are on (TCP SYN 쿠키가 켜져 있음) — severity medium, compares one setting. + +Checks the kernel parameter net.ipv4.tcp_syncookies (1: answer a flood of connection attempts with cookies once the queue is full). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged. + +**Why.** SYN cookies keep a flood of half-open connections from using up the memory of the connection queue. + +**Fix.** Set `net.ipv4.tcp_syncookies = 1` in a file of /etc/sysctl.d and apply it with `sysctl --system`. diff --git a/docs/stig.ko.md b/docs/stig.ko.md new file mode 100644 index 0000000..a8c1eba --- /dev/null +++ b/docs/stig.ko.md @@ -0,0 +1,44 @@ + +# DISA STIG 프로파일 (Ubuntu 22.04) + +`stig-ubuntu2204`는 미 국방부가 DISA를 통해 공개하는 +[Canonical Ubuntu 22.04 LTS Security Technical Implementation Guide](https://public.cyber.mil/stigs/)(STIG) V2R8의 점검 항목으로 +호스트를 점검합니다. 미국 기준을 다루는 첫 프로파일이고, 다음은 RHEL 9용 프로파일입니다. + +```sh +sudo vmsctl scan --profile stig-ubuntu2204 +vmsctl explain UBTU-22-255040 # 점검 항목이 무엇을 보고, 왜 중요하고, 어떻게 고치는지 +``` + +## 어디까지 점검하고, 무엇은 점검하지 않나 + +**STIG 전체를 평가하는 것이 아닙니다.** V2R8의 점검 항목 188개 중 vmsctl이 판정할 수 있는 27개만 담았고, 나머지 161개는 +아무것도 말하지 않습니다. 감사 규칙, 시스템 명령과 라이브러리의 소유자·권한, 스마트 카드와 PKI, FIPS, 부트로더 비밀번호, 그래픽 세션, +`sudo` 정책의 세부 사항, 대부분의 PAM 설정은 아직 점검하지 않습니다. 이 프로파일을 통과했다는 것은 그 27개가 통과했다는 +뜻이지, 호스트가 STIG를 충족한다는 뜻이 아닙니다. 평가에는 STIG의 SCAP 콘텐츠나 체크리스트를 쓰고, 이 프로파일은 점검하는 범위에 +대해 항목마다 근거와 함께 결과를 보는 데 쓰세요. + +| 영역 | 점검 항목 | +|---|---| +| 부팅과 커널 | `UBTU-22-211015`(Ctrl-Alt-Delete 마스크), `UBTU-22-213010`(커널 로그), `UBTU-22-213020`(ASLR), `UBTU-22-253010`(SYN 쿠키) | +| 패키지 | 설치되어 있어야 함: `215010`(libpam-pwquality), `215015`(chrony), `251010`(ufw), `255010`(openssh-server), `431010`(apparmor), `653010`(auditd). 설치되어 있지 않아야 함: `215020`(systemd-timesyncd), `215025`(ntp), `215030`(rsh-server), `215035`(telnetd), `215040`(nfs-kernel-server) | +| 방화벽 | `251015`(ufw가 켜져 있음), `251020`(ufw 서비스가 부팅할 때 시작) | +| SSH | `255015`(서비스가 부팅할 때 시작), `255025`(빈 비밀번호와 사용자 환경 변수 금지), `255040`(X11 전달 금지) | +| 계정과 비밀번호 | `411010`(root 잠금), `411015`(고유한 UID), `411025`(최소 사용 기간 1일), `411030`(최대 사용 기간 60일), `412030`(유휴 셸 15분), `611035`(15자), `611065`(빈 비밀번호 금지) | + +(점검 항목 ID는 `UBTU-22-` 뒤에 번호가 붙은 것입니다.) + +## 점검 항목을 어떻게 연결하나 + +점검은 STIG가 요구하는 것을 정확히 판정할 때만 점검 항목에 연결하고, STIG가 숫자를 정해 둔 곳(60일, 15자, 900초)에는 그 숫자를 +매개변수로 넣습니다. 더 느슨한 점검을 연결하면 호스트가 실제로는 실패하는 항목을 통과할 수 있는데, vmsctl은 그렇게 하지 않습니다. +예를 들어 STIG는 `SHA512` 비밀번호 해시를 요구하는데 `accounts.password-hash-method`는 yescrypt도 받아들이므로, 그 STIG 점검 항목은 +연결하지 않았습니다. 패키지, 유닛, 숫자가 필요한 항목에는 그 값을 매개변수로 받는 작은 범용 점검(`packages.installed`, +`packages.absent`, `services.unit-enabled`, `services.unit-masked`)을 쓰고, 어느 값인지는 프로파일이 정합니다. + +점검 항목 ID와 중요도(CAT I은 `high`, CAT II는 `medium`, CAT III은 `low`)는 STIG의 것이며 STIG는 미국 정부 저작물입니다. 제목은 +vmsctl이 직접 짧게 쓴 것입니다. 연결은 [ComplianceAsCode](https://github.com/ComplianceAsCode/content)가 이 STIG에 대해 공개한 +점검 항목 목록을 기준으로, 항목마다 요구 사항과 대조해서 만들었습니다. 어떤 배포판의 호스트든 점검 결과는 나오지만, 이 프로파일이 +대상으로 하는 것은 Ubuntu 22.04 호스트뿐입니다. + +점검이 갖춰지는 대로 항목을 늘립니다(가장 큰 묶음은 감사 규칙입니다). diff --git a/docs/stig.md b/docs/stig.md new file mode 100644 index 0000000..9e31119 --- /dev/null +++ b/docs/stig.md @@ -0,0 +1,43 @@ +# The DISA STIG profile (Ubuntu 22.04) + +`stig-ubuntu2204` checks a host against the controls of the +[Canonical Ubuntu 22.04 LTS Security Technical Implementation Guide](https://public.cyber.mil/stigs/) (STIG), version V2R8, that +the US Department of Defense publishes through DISA. It is the first profile for a US baseline; the profile for RHEL 9 is next. + +```sh +sudo vmsctl scan --profile stig-ubuntu2204 +vmsctl explain UBTU-22-255040 # what a control looks at, why, how to fix it +``` + +## What it covers, and what it does not + +**This is not a complete STIG assessment.** The profile has the 27 controls (of the 188 of V2R8) that vmsctl can decide, and says +nothing about the other 161: the audit rules, the ownership and mode of system commands and libraries, smart cards and PKI, FIPS, the +boot loader password, the graphical session, `sudo` policy details and most of the PAM settings are not checked yet. A scan that passes +the profile means those 27 controls pass; it does not mean the host meets the STIG. Use the STIG's own SCAP content or checklist for an +assessment, and this profile for what it checks, with the evidence behind each result. + +| Area | Controls | +|---|---| +| Boot and kernel | `UBTU-22-211015` (Ctrl-Alt-Delete masked), `UBTU-22-213010` (kernel log), `UBTU-22-213020` (ASLR), `UBTU-22-253010` (SYN cookies) | +| Packages | installed: `215010` (libpam-pwquality), `215015` (chrony), `251010` (ufw), `255010` (openssh-server), `431010` (apparmor), `653010` (auditd); not installed: `215020` (systemd-timesyncd), `215025` (ntp), `215030` (rsh-server), `215035` (telnetd), `215040` (nfs-kernel-server) | +| Firewall | `251015` (ufw turned on), `251020` (the ufw service starts at boot) | +| SSH | `255015` (the service starts at boot), `255025` (no empty passwords, no user environment), `255040` (no X11 forwarding) | +| Accounts and passwords | `411010` (root locked), `411015` (unique UIDs), `411025` (minimum age 1 day), `411030` (maximum age 60 days), `412030` (idle shell timeout 15 minutes), `611035` (15 characters), `611065` (no empty passwords) | + +(Control IDs are `UBTU-22-` followed by the number.) + +## How a control is mapped + +A check is mapped to a control only when it decides exactly what the STIG requires, with the STIG's own number as a parameter where it +fixes one (60 days, 15 characters, 900 seconds). A looser check would let a host pass a control that it fails, which vmsctl does not do: +for example the STIG asks for `SHA512` password hashing, and `accounts.password-hash-method` also accepts yescrypt, so that STIG control is +not mapped. Where a control needs a package, a unit or a number, a small generic check takes it as a parameter (`packages.installed`, +`packages.absent`, `services.unit-enabled`, `services.unit-masked`), and the profile says which. + +The control IDs and their importance (CAT I is `high`, CAT II `medium`, CAT III `low`) are the STIG's; the STIG is a US government work. +The titles are vmsctl's own short wording. The mapping was made against the control list that +[ComplianceAsCode](https://github.com/ComplianceAsCode/content) publishes for this STIG and checked against each control's requirement. +The scan reports what it finds on a host of any distribution, but only an Ubuntu 22.04 host is what the profile is for. + +More controls come as the checks they need exist (the audit rules are the largest group). diff --git a/internal/engine/pack_test.go b/internal/engine/pack_test.go index b74ea23..e45ce9d 100644 --- a/internal/engine/pack_test.go +++ b/internal/engine/pack_test.go @@ -134,12 +134,13 @@ controls: } { t.Run(name, func(t *testing.T) { c := builtin(t) + before := len(c.Profiles) if _, err := c.Extend(source(tc.checks, tc.profs)); err == nil || !strings.Contains(err.Error(), tc.want) { t.Errorf("err = %v, want %q", err, tc.want) } // A refused pack adds nothing. - if len(c.Profiles) != 2 { - t.Errorf("%d profiles", len(c.Profiles)) + if len(c.Profiles) != before { + t.Errorf("%d profiles, were %d", len(c.Profiles), before) } }) } diff --git a/profiles/stig-ubuntu2204.yaml b/profiles/stig-ubuntu2204.yaml new file mode 100644 index 0000000..f375791 --- /dev/null +++ b/profiles/stig-ubuntu2204.yaml @@ -0,0 +1,184 @@ +# Canonical Ubuntu 22.04 LTS Security Technical Implementation Guide (STIG), V2R8, published by DISA (the US Department of Defense): +# the controls that vmsctl checks. The control IDs and importance (CAT I = high, CAT II = medium, CAT III = low) are the STIG's, and the +# STIG is a US government work; the titles are vmsctl's own short wording. +# +# A check is mapped to a control only when it decides exactly what the STIG requires (or, where the STIG fixes a number, with that +# number as the parameter): a looser check would let a host pass a control it fails. The rest of the STIG (audit rules, file +# ownership of system commands, smart cards, FIPS, a boot loader password, ...) is not checked yet, so this profile says nothing about it: +# it is not a complete STIG assessment. See docs/stig.md. +id: stig-ubuntu2204 +revision: 1 +title: Canonical Ubuntu 22.04 LTS STIG (V2R8), the controls vmsctl checks +title_ko: Canonical Ubuntu 22.04 LTS STIG(V2R8) 중 vmsctl이 점검하는 항목 +controls: + - id: UBTU-22-211015 + title: Ctrl-Alt-Delete does not reboot the host + title_ko: Ctrl-Alt-Delete로 호스트가 재부팅되지 않음 + severity: high + checks: [services.unit-masked] + params: + services.unit-masked: {unit: ctrl-alt-del.target} + - id: UBTU-22-213010 + title: Kernel messages are restricted to privileged users + title_ko: 커널 메시지를 권한 있는 사용자만 볼 수 있음 + severity: low + checks: [sysctl.dmesg-restrict] + - id: UBTU-22-213020 + title: Address space layout randomization is on + title_ko: 주소 공간 배치 무작위화가 켜져 있음 + severity: medium + checks: [sysctl.aslr] + - id: UBTU-22-215010 + title: The password quality library is installed + title_ko: 비밀번호 품질 라이브러리가 설치되어 있음 + severity: medium + checks: [packages.installed] + params: + packages.installed: {package: libpam-pwquality} + - id: UBTU-22-215015 + title: chrony is installed + title_ko: chrony가 설치되어 있음 + severity: low + checks: [packages.installed] + params: + packages.installed: {package: chrony} + - id: UBTU-22-215020 + title: systemd-timesyncd is not installed + title_ko: systemd-timesyncd가 설치되어 있지 않음 + severity: low + checks: [packages.absent] + params: + packages.absent: {package: systemd-timesyncd} + - id: UBTU-22-215025 + title: ntp is not installed + title_ko: ntp가 설치되어 있지 않음 + severity: low + checks: [packages.absent] + params: + packages.absent: {package: ntp} + - id: UBTU-22-215030 + title: The rsh server is not installed + title_ko: rsh 서버가 설치되어 있지 않음 + severity: high + checks: [packages.absent] + params: + packages.absent: {package: rsh-server} + - id: UBTU-22-215035 + title: The telnet server is not installed + title_ko: telnet 서버가 설치되어 있지 않음 + severity: high + checks: [packages.absent] + params: + packages.absent: {package: telnetd} + - id: UBTU-22-215040 + title: The NFS server is not installed + title_ko: NFS 서버가 설치되어 있지 않음 + severity: medium + checks: [packages.absent] + params: + packages.absent: {package: nfs-kernel-server} + - id: UBTU-22-251010 + title: ufw is installed + title_ko: ufw가 설치되어 있음 + severity: medium + checks: [packages.installed] + params: + packages.installed: {package: ufw} + - id: UBTU-22-251015 + title: ufw is turned on + title_ko: ufw가 켜져 있음 + severity: medium + checks: [firewall.ufw-active] + - id: UBTU-22-251020 + title: The ufw service starts at boot + title_ko: ufw 서비스가 부팅할 때 시작함 + severity: medium + checks: [services.unit-enabled] + params: + services.unit-enabled: {unit: ufw.service} + - id: UBTU-22-253010 + title: TCP SYN cookies are on + title_ko: TCP SYN 쿠키가 켜져 있음 + severity: medium + checks: [sysctl.syncookies] + - id: UBTU-22-255010 + title: The SSH server is installed + title_ko: SSH 서버가 설치되어 있음 + severity: high + checks: [packages.installed] + params: + packages.installed: {package: openssh-server} + - id: UBTU-22-255015 + title: The SSH service starts at boot + title_ko: SSH 서비스가 부팅할 때 시작함 + severity: high + checks: [services.unit-enabled] + params: + services.unit-enabled: {unit: ssh.service} + - id: UBTU-22-255025 + title: SSH allows no empty passwords and no user environment + title_ko: SSH가 빈 비밀번호와 사용자 환경 변수를 허용하지 않음 + severity: high + checks: [ssh.permit-empty-passwords, ssh.permit-user-environment] + - id: UBTU-22-255040 + title: SSH does not forward X11 + title_ko: SSH가 X11을 전달하지 않음 + severity: high + checks: [ssh.x11-forwarding] + - id: UBTU-22-411010 + title: The root account is locked + title_ko: root 계정이 잠겨 있음 + severity: medium + checks: [accounts.root-locked] + - id: UBTU-22-411015 + title: Every account has its own UID + title_ko: 계정마다 고유한 UID를 가짐 + severity: medium + checks: [accounts.unique-uids] + - id: UBTU-22-411025 + title: A password cannot be changed again within a day + title_ko: 비밀번호를 하루 안에 다시 바꿀 수 없음 + severity: medium + checks: [accounts.password-min-age] + params: + accounts.password-min-age: {min_days: 1} + - id: UBTU-22-411030 + title: A password expires after 60 days + title_ko: 비밀번호가 60일 뒤에 만료됨 + severity: medium + checks: [accounts.password-max-age] + params: + accounts.password-max-age: {max_days: 60} + - id: UBTU-22-412030 + title: An idle shell session ends after 15 minutes + title_ko: 유휴 셸 세션이 15분 뒤에 끝남 + severity: medium + checks: [accounts.session-timeout-set, accounts.session-timeout-value] + params: + accounts.session-timeout-value: {max_seconds: 900} + - id: UBTU-22-431010 + title: AppArmor is installed + title_ko: AppArmor가 설치되어 있음 + severity: medium + checks: [packages.installed] + params: + packages.installed: {package: apparmor} + - id: UBTU-22-611035 + title: A password has at least 15 characters + title_ko: 비밀번호가 15자 이상임 + severity: medium + checks: [accounts.password-min-length] + params: + accounts.password-min-length: {min_length: 15} + - id: UBTU-22-611065 + title: No account has an empty password + title_ko: 비밀번호가 비어 있는 계정이 없음 + severity: high + checks: [accounts.no-empty-passwords] + - id: UBTU-22-653010 + title: The audit daemon is installed + title_ko: 감사 데몬(auditd)이 설치되어 있음 + severity: medium + checks: [packages.installed] + params: + packages.installed: {package: auditd} diff --git a/rules/accounts/root-locked.yaml b/rules/accounts/root-locked.yaml new file mode 100644 index 0000000..73509a7 --- /dev/null +++ b/rules/accounts/root-locked.yaml @@ -0,0 +1,48 @@ +id: accounts.root-locked +version: 1 +title: The root account has no password that can log in +title_ko: root 계정에 로그인할 수 있는 비밀번호가 없음 +severity: medium +description: >- + Checks in /etc/shadow that the root account is locked (its password field starts with "!" or is "*"), so no password logs in as root. + Administrators use their own accounts and sudo. Without /etc/shadow there is nothing to check, so the check cannot pass. +description_ko: >- + /etc/shadow에서 root 계정이 잠겨 있는지(비밀번호 필드가 "!"로 시작하거나 "*") 확인합니다. 잠겨 있으면 비밀번호로 root에 + 로그인할 수 없고, 관리자는 자기 계정과 sudo를 씁니다. /etc/shadow가 없으면 확인할 것이 없으므로 이 점검은 통과할 수 없습니다. +rationale: >- + A root password is a shared secret for the most powerful account, which anyone can guess or leak and which says nothing about who used it. +rationale_ko: >- + root 비밀번호는 가장 강한 권한의 계정을 하나의 공유 비밀로 지키는 것이라 누구나 추측하거나 유출할 수 있고, 누가 썼는지도 남지 않습니다. +remediation: >- + Lock the root password (`passwd -l root`) after an administrator has an account in the sudo group. +remediation_ko: >- + 관리자가 sudo 그룹의 자기 계정을 갖춘 뒤에 root 비밀번호를 잠그세요(`passwd -l root`). +violations: + over: shadow.entries + as: e + where: e.name == "root" && e.state != "locked" + key: e.name + text: >- + e.name + " has a password that can log in (" + e.state + ")" +tests: + - name: root is locked + facts: + shadow: {present: true, entries: [{name: root, state: locked, algorithm: ""}, {name: alice, state: set, algorithm: sha512}]} + want: PASS + - name: root has a password + facts: + shadow: {present: true, entries: [{name: root, state: set, algorithm: sha512}]} + want: FAIL + - name: root has an empty password + facts: + shadow: {present: true, entries: [{name: root, state: empty, algorithm: ""}]} + want: FAIL + - name: no shadow file + input: absent + facts: + shadow: {present: false, entries: []} + want: ERROR + - name: shadow unreadable without root + input: unavailable + unavailable: [shadow] + want: ERROR diff --git a/rules/firewall/ufw-active.yaml b/rules/firewall/ufw-active.yaml new file mode 100644 index 0000000..02edb8d --- /dev/null +++ b/rules/firewall/ufw-active.yaml @@ -0,0 +1,44 @@ +id: firewall.ufw-active +version: 1 +title: ufw is turned on +title_ko: ufw가 켜져 있음 +severity: medium +description: >- + Checks that /etc/ufw/ufw.conf sets ENABLED=yes, which is what makes ufw filter at boot (installing the package enables its unit, so + the unit alone says nothing). Without ufw there is nothing to turn on, and the check fails: it is for profiles that require ufw + itself, such as the Ubuntu STIG; firewall.enabled accepts any host firewall. +description_ko: >- + /etc/ufw/ufw.conf에 ENABLED=yes가 있는지 확인합니다. 이 값이 있어야 ufw가 부팅할 때 필터링을 시작합니다(패키지를 설치하면 + 유닛이 켜지므로 유닛만으로는 알 수 없습니다). ufw가 없으면 켤 것이 없으므로 실패합니다. Ubuntu STIG처럼 ufw 자체를 요구하는 + 프로파일을 위한 점검이며, firewall.enabled는 어떤 호스트 방화벽이든 받아들입니다. +rationale: >- + Without a firewall, every service that listens on an address is open to everyone who can reach it. +rationale_ko: >- + 방화벽이 없으면 주소에서 대기 중인 모든 서비스가 접근할 수 있는 모든 사람에게 열립니다. +remediation: >- + Allow what the host serves and turn ufw on: `ufw allow 22/tcp`, then `ufw enable`. Allow your own SSH connection first. +remediation_ko: >- + 호스트가 제공하는 서비스를 허용한 뒤 ufw를 켜세요. `ufw allow 22/tcp` 후 `ufw enable`입니다. 지금 쓰고 있는 SSH 접속을 먼저 허용하세요. +failure: >- + ufw is not turned on: /etc/ufw/ufw.conf is missing or does not set ENABLED=yes. +expect: >- + firewall.ufw.present && "enabled" in firewall.ufw.settings && firewall.ufw.settings.enabled.value == "yes" +tests: + - name: on + facts: + firewall: {ufw: {present: true, settings: {enabled: {value: "yes", explicit: true, source: "/etc/ufw/ufw.conf:6"}}}} + want: PASS + - name: installed but off + facts: + firewall: {ufw: {present: true, settings: {enabled: {value: "no", explicit: true, source: "/etc/ufw/ufw.conf:6"}}}} + want: FAIL + - name: not installed + facts: + firewall: {ufw: {present: false, settings: {}}} + want: FAIL + - name: the file cannot be read + input: unavailable + unavailable: [firewall] + facts: + firewall: {ufw: {present: false, settings: {}}} + want: ERROR diff --git a/rules/packages/absent.yaml b/rules/packages/absent.yaml new file mode 100644 index 0000000..edc01d3 --- /dev/null +++ b/rules/packages/absent.yaml @@ -0,0 +1,50 @@ +id: packages.absent +version: 1 +title: A package that the control forbids is not installed +title_ko: 점검 항목이 금지하는 패키지가 설치되어 있지 않음 +severity: medium +description: >- + Checks that the package named by the parameter `package` is not installed (dpkg or rpm). The profile that uses this check says which + package. Only a profile sets the parameter. +description_ko: >- + 매개변수 `package`가 가리키는 패키지가 설치되어 있지 않은지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 + 정합니다. 매개변수는 프로파일만 정합니다. +rationale: >- + A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked. +rationale_ko: >- + 필요하지 않은 패키지는 계속 패치해야 하고 공격받을 수 있는 코드와, 대개는 대기 중인 서비스를 더합니다. +remediation: >- + Remove the package with the package manager (for example `apt remove `). +remediation_ko: >- + 패키지 관리자로 제거하세요(예: `apt remove 패키지`). +applies: >- + params.package != "" && (packages.manager == "dpkg" || packages.manager == "rpm") +params: + package: {type: string, default: "", description: The name of the package that must not be installed} +failure: >- + The package that the profile forbids is installed. +expect: >- + !(params.package in packages.installed) +tests: + - name: not installed + params: {package: telnetd} + facts: + packages: {manager: dpkg, installed: {openssh-server: [{version: "1:8.9p1-3", arch: amd64, state: installed}]}} + want: PASS + - name: installed + params: {package: telnetd} + facts: + packages: {manager: dpkg, installed: {telnetd: [{version: "0.17-44", arch: amd64, state: installed}]}} + want: FAIL + - name: the package list cannot be read + params: {package: telnetd} + input: unavailable + unavailable: [packages] + facts: + packages: {manager: dpkg, installed: {}} + want: ERROR + - name: no package manager known + params: {package: telnetd} + facts: + packages: {manager: "", installed: {}} + want: NOT_APPLICABLE diff --git a/rules/packages/installed.yaml b/rules/packages/installed.yaml new file mode 100644 index 0000000..c563c7a --- /dev/null +++ b/rules/packages/installed.yaml @@ -0,0 +1,50 @@ +id: packages.installed +version: 1 +title: A package that the control requires is installed +title_ko: 점검 항목이 요구하는 패키지가 설치되어 있음 +severity: medium +description: >- + Checks that the package named by the parameter `package` is installed (dpkg or rpm). The profile that uses this check says which + package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter. +description_ko: >- + 매개변수 `package`가 가리키는 패키지가 설치되어 있는지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 + 정합니다. 제거했지만 설정 파일이 남은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. +rationale: >- + A control that needs a security tool or a service on the host cannot be met without its package. +rationale_ko: >- + 보안 도구나 서비스가 있어야 하는 점검 항목은 그 패키지가 없으면 충족할 수 없습니다. +remediation: >- + Install the package with the package manager (for example `apt install `). +remediation_ko: >- + 패키지 관리자로 설치하세요(예: `apt install 패키지`). +applies: >- + params.package != "" && (packages.manager == "dpkg" || packages.manager == "rpm") +params: + package: {type: string, default: "", description: The name of the package that must be installed} +failure: >- + The package named by the profile is not installed. +expect: >- + params.package in packages.installed +tests: + - name: installed + params: {package: chrony} + facts: + packages: {manager: dpkg, installed: {chrony: [{version: "4.2-2ubuntu2", arch: amd64, state: installed}]}} + want: PASS + - name: not installed + params: {package: chrony} + facts: + packages: {manager: dpkg, installed: {openssh-server: [{version: "1:8.9p1-3", arch: amd64, state: installed}]}} + want: FAIL + - name: the package list cannot be read + params: {package: chrony} + input: unavailable + unavailable: [packages] + facts: + packages: {manager: dpkg, installed: {}} + want: ERROR + - name: no package manager known + params: {package: chrony} + facts: + packages: {manager: "", installed: {}} + want: NOT_APPLICABLE diff --git a/rules/services/unit-enabled.yaml b/rules/services/unit-enabled.yaml new file mode 100644 index 0000000..da288ed --- /dev/null +++ b/rules/services/unit-enabled.yaml @@ -0,0 +1,60 @@ +id: services.unit-enabled +version: 1 +title: A systemd unit that the control requires is enabled +title_ko: 점검 항목이 요구하는 systemd 유닛이 활성화되어 있음 +severity: medium +description: >- + Checks that the systemd unit named by the parameter `unit` (such as ssh.service) is enabled, so it starts at boot, and not masked. + The profile that uses this check says which unit. Only a profile sets the parameter. +description_ko: >- + 매개변수 `unit`이 가리키는 systemd 유닛(예: ssh.service)이 활성화되어 있어 부팅할 때 시작하고, 마스크되어 있지 않은지 + 확인합니다. 어느 유닛인지는 이 점검을 쓰는 프로파일이 정합니다. 매개변수는 프로파일만 정합니다. +rationale: >- + A control that needs a service to run cannot be met if the service does not start by itself. +rationale_ko: >- + 서비스가 실행되어야 하는 점검 항목은 서비스가 저절로 시작하지 않으면 충족할 수 없습니다. +remediation: >- + Enable the unit (`systemctl enable --now `) and unmask it if it is masked (`systemctl unmask `). +remediation_ko: >- + 유닛을 활성화하세요(`systemctl enable --now 유닛`). 마스크되어 있다면 먼저 풀어야 합니다(`systemctl unmask 유닛`). +applies: >- + params.unit != "" && services.systemd +params: + unit: {type: string, default: "", description: "The systemd unit that must be enabled, for example ssh.service"} +failure: >- + The unit that the profile requires is not enabled, or is masked, or does not exist. +expect: >- + params.unit in services.units && services.units[params.unit].enabled && !services.units[params.unit].masked +tests: + - name: enabled + params: {unit: ssh.service} + facts: + services: {systemd: true, units: {ssh.service: {enabled: true, file: /lib/systemd/system/ssh.service}}} + want: PASS + - name: installed but not enabled + params: {unit: ssh.service} + facts: + services: {systemd: true, units: {ssh.service: {enabled: false, file: /lib/systemd/system/ssh.service}}} + want: FAIL + - name: masked + params: {unit: ssh.service} + facts: + services: {systemd: true, units: {ssh.service: {enabled: true, masked: true}}} + want: FAIL + - name: no such unit + params: {unit: ssh.service} + facts: + services: {systemd: true, units: {}} + want: FAIL + - name: the units cannot be read + params: {unit: ssh.service} + input: unavailable + unavailable: [services] + facts: + services: {systemd: true, units: {}} + want: ERROR + - name: no systemd + params: {unit: ssh.service} + facts: + services: {systemd: false, units: {}} + want: NOT_APPLICABLE diff --git a/rules/services/unit-masked.yaml b/rules/services/unit-masked.yaml new file mode 100644 index 0000000..4c557fc --- /dev/null +++ b/rules/services/unit-masked.yaml @@ -0,0 +1,52 @@ +id: services.unit-masked +version: 1 +title: A systemd unit that the control forbids is masked +title_ko: 점검 항목이 금지하는 systemd 유닛이 마스크되어 있음 +severity: medium +description: >- + Checks that the systemd unit named by the parameter `unit` (such as ctrl-alt-del.target) is masked: linked to /dev/null, so nothing can + start it. The profile that uses this check says which unit. Only a profile sets the parameter. +description_ko: >- + 매개변수 `unit`이 가리키는 systemd 유닛(예: ctrl-alt-del.target)이 마스크되어 있는지, 즉 /dev/null에 연결되어 아무것도 그 유닛을 + 시작할 수 없는지 확인합니다. 어느 유닛인지는 이 점검을 쓰는 프로파일이 정합니다. 매개변수는 프로파일만 정합니다. +rationale: >- + Some units must never run on a server (a key press that reboots it, a service that has no place there); only masking keeps another + unit or a person from starting them. +rationale_ko: >- + 서버에서 절대 실행되면 안 되는 유닛(키 입력으로 재부팅하는 것, 있을 곳이 없는 서비스)이 있습니다. 마스크해야 다른 유닛이나 + 사람이 시작하는 것까지 막을 수 있습니다. +remediation: >- + Mask the unit (`systemctl mask `). +remediation_ko: >- + 유닛을 마스크하세요(`systemctl mask 유닛`). +applies: >- + params.unit != "" && services.systemd +params: + unit: {type: string, default: "", description: "The systemd unit that must be masked, for example ctrl-alt-del.target"} +failure: >- + The unit that the profile forbids is not masked. +expect: >- + params.unit in services.units && services.units[params.unit].masked +tests: + - name: masked + params: {unit: ctrl-alt-del.target} + facts: + services: {systemd: true, units: {ctrl-alt-del.target: {enabled: false, masked: true}}} + want: PASS + - name: not masked + params: {unit: ctrl-alt-del.target} + facts: + services: {systemd: true, units: {ctrl-alt-del.target: {enabled: false, masked: false, file: /lib/systemd/system/ctrl-alt-del.target}}} + want: FAIL + - name: the units cannot be read + params: {unit: ctrl-alt-del.target} + input: unavailable + unavailable: [services] + facts: + services: {systemd: true, units: {}} + want: ERROR + - name: no systemd + params: {unit: ctrl-alt-del.target} + facts: + services: {systemd: false, units: {}} + want: NOT_APPLICABLE From 4c221015e1e551ac77e6cf7178312cd1ec90e1e3 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:10:13 +0900 Subject: [PATCH 2/6] docs: stig markers --- README.ko.md | 2 +- docs/README.ko.md | 2 +- docs/stig.ko.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.ko.md b/README.ko.md index 58c40a6..3341592 100644 --- a/README.ko.md +++ b/README.ko.md @@ -1,4 +1,4 @@ - + # vmsctl [![CI](https://github.com/with-developer/vmsctl/actions/workflows/ci.yml/badge.svg)](https://github.com/with-developer/vmsctl/actions/workflows/ci.yml) diff --git a/docs/README.ko.md b/docs/README.ko.md index b3fef50..d0f40a4 100644 --- a/docs/README.ko.md +++ b/docs/README.ko.md @@ -1,4 +1,4 @@ - + # vmsctl 문서 [English](README.md) diff --git a/docs/stig.ko.md b/docs/stig.ko.md index a8c1eba..23e414b 100644 --- a/docs/stig.ko.md +++ b/docs/stig.ko.md @@ -1,4 +1,4 @@ - + # DISA STIG 프로파일 (Ubuntu 22.04) `stig-ubuntu2204`는 미 국방부가 DISA를 통해 공개하는 From 74f414d3c9cf9c62f38ca9ffb9913268f74f8f65 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:11:42 +0900 Subject: [PATCH 3/6] feat: an English page for the Ubuntu STIG controls (site/stig/ubuntu2204), generated by make docs; a sitemap entry --- Makefile | 2 +- internal/rulesdoc/rulesdoc_test.go | 38 +++ internal/rulesdoc/site.go | 167 +++++++++++++ internal/rulesdoc/site_ko.go | 106 -------- site/index.html | 1 + site/sitemap.xml | 1 + site/stig/ubuntu2204/index.html | 376 +++++++++++++++++++++++++++++ 7 files changed, 584 insertions(+), 107 deletions(-) create mode 100644 internal/rulesdoc/site.go delete mode 100644 internal/rulesdoc/site_ko.go create mode 100644 site/stig/ubuntu2204/index.html diff --git a/Makefile b/Makefile index c383791..935d979 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ snapshot: $(GORELEASER) ## Build the release artifacts into dist/ without publis $(GORELEASER) release --snapshot --clean --skip=$(SNAPSHOT_SKIP) docs: ## Regenerate docs/rules.md and docs/facts.md from rules/, profiles/ and the collectors - go test ./internal/rulesdoc -run 'TestRulesDocIsUpToDate|TestRulesKoDocIsUpToDate|TestKISASiteKoIsUpToDate|TestFactsDocIsUpToDate' -update + go test ./internal/rulesdoc -run 'TestRulesDocIsUpToDate|TestRulesKoDocIsUpToDate|TestKISASiteKoIsUpToDate|TestStigSiteIsUpToDate|TestFactsDocIsUpToDate' -update # E2E_RUN selects distributions (e.g. debian-12); E2E_UPDATE=1 rewrites their goldens. E2E_RUN ?= diff --git a/internal/rulesdoc/rulesdoc_test.go b/internal/rulesdoc/rulesdoc_test.go index d47c182..8f60265 100644 --- a/internal/rulesdoc/rulesdoc_test.go +++ b/internal/rulesdoc/rulesdoc_test.go @@ -101,6 +101,44 @@ func TestKISASiteKoIsUpToDate(t *testing.T) { } } +// site/stig/ubuntu2204/index.html is what RenderStigSiteEn makes of the STIG profile. +func TestStigSiteIsUpToDate(t *testing.T) { + content, err := engine.Load(rules.FS, profiles.FS) + if err != nil { + t.Fatal(err) + } + got, err := RenderStigSiteEn(content, "stig-ubuntu2204") + if err != nil { + t.Fatal(err) + } + path := filepath.Join("..", "..", "site", "stig", "ubuntu2204", "index.html") + if *update { + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte(got), 0o644); err != nil { + t.Fatal(err) + } + return + } + want, err := os.ReadFile(path) + if err != nil { + t.Fatalf("%v; run `make docs`", err) + } + if string(want) != got { + t.Error("site/stig/ubuntu2204/index.html is out of date; run `make docs`") + } + for _, c := range content.Profiles["stig-ubuntu2204"].Controls { + if !strings.Contains(got, `id="`+anchorID(c.ID)+`"`) { + t.Errorf("no section for %s", c.ID) + } + } + // The page names what it does not cover, and the numbers it states are the profile's. + if !strings.Contains(got, "not a complete STIG assessment") || !strings.Contains(got, "package = chrony") || strings.Contains(got, "vmsctl이 서버에서 읽기만 하며 자동으로 점검하고, 사람이 판단해야 하는 항목은 근거를 모아 보여 줍니다.", len(p.Controls)), + cmd: "curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh\nsudo vmsctl scan --profile kisa-2026 --lang ko", + hint: "결과마다 값과 파일, 줄 번호가 근거로 붙고, 조치 방법은 vmsctl explain 점검ID --lang ko로도 볼 수 있습니다. 설치와 사용법은 vmsctl 소개와 README를 보세요.", + tocLabel: "점검 항목 목록", why: "왜 중요한가.", fix: "조치 방법.", human: "사람이 판단합니다.", importance: "중요도", handOnly: "이 항목은 자동 점검이 없고 사람이 직접 검토합니다.", params: "이 항목에서 쓰는 값", + severity: sev, + pick: ko, + footer: "Apache-2.0 라이선스 · github.com/with-developer/vmsctl\n 전체 규칙 참조 · vmsctl 소개", + }) +} + +var severityEn = map[engine.Severity]string{"high": "high (CAT I)", "medium": "medium (CAT II)", "low": "low (CAT III)"} + +// RenderStigSiteEn returns the English page of the DISA STIG profile for Ubuntu 22.04 (site/stig/ubuntu2204/index.html). +func RenderStigSiteEn(content *engine.Content, profileID string) (string, error) { + p := content.Profiles[profileID] + if p == nil { + return "", fmt.Errorf("no profile %q", profileID) + } + return renderProfilePage(content, p, pageText{ + lang: "en", locale: "en_US", url: "https://with-developer.github.io/vmsctl/stig/ubuntu2204/", home: "../../", homeLabel: "Home", cssPath: "../../style.css", + title: fmt.Sprintf("Ubuntu 22.04 STIG: the %d controls vmsctl checks, and how to fix them — vmsctl", len(p.Controls)), + desc: fmt.Sprintf("The %d controls of the DISA STIG for Canonical Ubuntu 22.04 LTS (V2R8) that vmsctl checks on a server: what each one looks at, why it matters and how to fix it. Not a complete STIG assessment.", len(p.Controls)), + h1: fmt.Sprintf("Ubuntu 22.04 STIG: the %d controls vmsctl checks", len(p.Controls)), + lead: fmt.Sprintf("These are %d of the 188 controls of the DISA Security Technical Implementation Guide for Canonical Ubuntu 22.04 LTS (V2R8) that vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires.", len(p.Controls)), + cmd: "curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh\nsudo vmsctl scan --profile stig-ubuntu2204", + hint: "Every result carries its evidence (the value, the file and the line); vmsctl explain UBTU-22-255040 prints a control in the terminal. What the profile covers: docs/stig.md. About the tool: vmsctl.", + tocLabel: "Controls", why: "Why it matters.", fix: "How to fix it.", human: "A person decides.", importance: "Importance", handOnly: "This control has no automatic check: a person reviews it.", params: "Values used for this control", + severity: func(s engine.Severity) string { + if v, ok := severityEn[s]; ok { + return v + } + return string(s) + }, + pick: func(_, en string) string { return oneLine(en) }, + footer: "Apache-2.0 license · github.com/with-developer/vmsctl\n Rule reference · About vmsctl", + }) +} + +func renderProfilePage(content *engine.Content, p *engine.Profile, t pageText) (string, error) { + var b strings.Builder + w := func(format string, a ...any) { fmt.Fprintf(&b, format, a...) } + // the text of an English page is the English one, and of a Korean page the Korean one where there is one + title := func(c engine.Control) string { return t.pick(c.TitleKo, c.Title) } + + w("\n\n") + w("\n\n\n\n", t.lang) + w("%s\n", html.EscapeString(t.title)) + w("\n", html.EscapeString(t.desc)) + w("\n") + w("\n", t.url) + w("\n\n\n", t.locale) + w("\n\n\n", html.EscapeString(t.title), html.EscapeString(t.desc), t.url) + w("\n\n\n", t.cssPath) + w("
\n
\n vmsctl\n \n
\n
\n", t.home, t.home, t.homeLabel) + w("
\n
\n") + w("

%s

\n", html.EscapeString(t.h1)) + w("

%s

\n", t.lead) + w("
%s
\n", t.cmd) + w("

%s

\n", t.hint) + + w("\n") + + for _, c := range p.Controls { + w("
\n

%s %s

\n", anchorID(c.ID), html.EscapeString(c.ID), html.EscapeString(title(c))) + w("

%s %s

\n", t.importance, html.EscapeString(string(c.Severity)), html.EscapeString(t.severity(c.Severity))) + if len(c.Checks) == 0 { + w("

%s %s

\n", t.handOnly, html.EscapeString(t.pick(c.ManualKo, c.Manual))) + } + for _, ref := range c.Checks { + ck := content.Checks[ref] + if ck == nil { + continue + } + w("
\n

%s %s

\n", html.EscapeString(ck.ID), html.EscapeString(t.pick(ck.TitleKo, ck.Title))) + w("

%s

\n", inline(t.pick(ck.DescriptionKo, ck.Description))) + if ck.Rationale != "" || ck.RationaleKo != "" { + w("

%s %s

\n", t.why, inline(t.pick(ck.RationaleKo, ck.Rationale))) + } + if ck.Remediation != "" || ck.RemediationKo != "" { + w("

%s %s

\n", t.fix, inline(t.pick(ck.RemediationKo, ck.Remediation))) + } + if ck.Manual != nil && (ck.Manual.Guidance != "" || ck.Manual.GuidanceKo != "") { + w("

%s %s

\n", t.human, inline(t.pick(ck.Manual.GuidanceKo, ck.Manual.Guidance))) + } + if ps := c.Params[ref]; len(ps) > 0 { + names := make([]string, 0, len(ps)) + for n := range ps { + names = append(names, n) + } + slices.Sort(names) + var parts []string + for _, n := range names { + parts = append(parts, fmt.Sprintf("%s = %s", html.EscapeString(n), html.EscapeString(fmt.Sprint(ps[n])))) + } + w("

%s: %s

\n", t.params, strings.Join(parts, ", ")) + } + w("
\n") + } + w("
\n") + } + w("
\n
\n") + w("
\n
\n %s\n
\n
\n\n\n", t.footer) + return b.String(), nil +} + +// anchorID is the fragment of a control: u-01. +func anchorID(id string) string { return strings.ToLower(strings.ReplaceAll(id, " ", "-")) } + +// inline escapes text and makes `code` spans of what is in backticks. +func inline(s string) string { + parts := strings.Split(s, "`") + var b strings.Builder + for i, p := range parts { + switch { + case i%2 == 1 && i < len(parts)-1: + b.WriteString("" + html.EscapeString(p) + "") + case i%2 == 1: // an unpaired backtick at the end: keep it as text + b.WriteString("`" + html.EscapeString(p)) + default: + b.WriteString(html.EscapeString(p)) + } + } + return b.String() +} diff --git a/internal/rulesdoc/site_ko.go b/internal/rulesdoc/site_ko.go deleted file mode 100644 index 80591d3..0000000 --- a/internal/rulesdoc/site_ko.go +++ /dev/null @@ -1,106 +0,0 @@ -package rulesdoc - -import ( - "fmt" - "html" - "strings" - - "github.com/with-developer/vmsctl/internal/engine" -) - -// RenderKISASiteKo returns the Korean project page of the KISA profile (site/ko/kisa/index.html): every control with the -// checks behind it, in Korean, as a static page that a search engine can read. It is made from the same rules as the rule -// reference, so it cannot drift from them. The control IDs come from the guide; the titles and texts are vmsctl's own. -func RenderKISASiteKo(content *engine.Content, profileID string) (string, error) { - p := content.Profiles[profileID] - if p == nil { - return "", fmt.Errorf("no profile %q", profileID) - } - var b strings.Builder - w := func(format string, a ...any) { fmt.Fprintf(&b, format, a...) } - - first, last := p.Controls[0].ID, p.Controls[len(p.Controls)-1].ID - title := fmt.Sprintf("KISA 2026 Unix 서버 점검 항목 %s~%s: 점검 내용과 조치 방법 — vmsctl", first, last) - desc := fmt.Sprintf("주요정보통신기반시설 기술적 취약점 분석·평가 상세가이드(2026) Unix 서버 점검 항목 %d개가 무엇을 보고, 왜 중요하고, 어떻게 고치는지 한국어로 정리했습니다. vmsctl이 각 항목을 자동으로 점검합니다.", len(p.Controls)) - const url = "https://with-developer.github.io/vmsctl/ko/kisa/" - - w("\n\n") - w("\n\n\n\n") - w("%s\n", html.EscapeString(title)) - w("\n", html.EscapeString(desc)) - w("\n") - w("\n", url) - w("\n\n\n") - w("\n\n\n", html.EscapeString(title), html.EscapeString(desc), url) - w("\n\n\n") - w("
\n
\n vmsctl\n \n
\n
\n") - w("
\n
\n") - w("

KISA 2026 Unix 서버 점검 항목 %s~%s

\n", first, last) - w("

주요정보통신기반시설 기술적 취약점 분석·평가 상세가이드(2026)의 Unix 서버 점검 항목 %d개가 각각 무엇을 보고, 왜 중요하고, 어떻게 고치는지 정리했습니다. 점검 항목 번호는 가이드의 것이고, 제목과 설명은 vmsctl이 직접 쓴 것입니다. 아래 항목은 모두 vmsctl이 서버에서 읽기만 하며 자동으로 점검하고, 사람이 판단해야 하는 항목은 근거를 모아 보여 줍니다.

\n", len(p.Controls)) - w("
curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh\nsudo vmsctl scan --profile kisa-2026 --lang ko
\n") - w("

결과마다 값과 파일, 줄 번호가 근거로 붙고, 조치 방법은 vmsctl explain 점검ID --lang ko로도 볼 수 있습니다. 설치와 사용법은 vmsctl 소개와 README를 보세요.

\n") - - w("\n") - - for _, c := range p.Controls { - w("
\n

%s %s

\n", anchorID(c.ID), html.EscapeString(c.ID), html.EscapeString(ko(c.TitleKo, c.Title))) - w("

중요도 %s

\n", html.EscapeString(string(c.Severity)), html.EscapeString(sev(c.Severity))) - if len(c.Checks) == 0 { - w("

이 항목은 자동 점검이 없고 사람이 직접 검토합니다.%s

\n", manualKo(c)) - } - for _, ref := range c.Checks { - ck := content.Checks[ref] - if ck == nil { - continue - } - w("
\n

%s %s

\n", html.EscapeString(ck.ID), html.EscapeString(ko(ck.TitleKo, ck.Title))) - w("

%s

\n", inline(ko(ck.DescriptionKo, ck.Description))) - if ck.Rationale != "" || ck.RationaleKo != "" { - w("

왜 중요한가. %s

\n", inline(ko(ck.RationaleKo, ck.Rationale))) - } - if ck.Remediation != "" || ck.RemediationKo != "" { - w("

조치 방법. %s

\n", inline(ko(ck.RemediationKo, ck.Remediation))) - } - if ck.Manual != nil && (ck.Manual.Guidance != "" || ck.Manual.GuidanceKo != "") { - w("

사람이 판단합니다. %s

\n", inline(ko(ck.Manual.GuidanceKo, ck.Manual.Guidance))) - } - w("
\n") - } - w("
\n") - } - w("
\n
\n") - w("\n\n\n") - return b.String(), nil -} - -// anchorID is the fragment of a control: u-01. -func anchorID(id string) string { return strings.ToLower(strings.ReplaceAll(id, " ", "-")) } - -// manualKo is the Korean text of a control that is reviewed by hand, when the profile has one. -func manualKo(c engine.Control) string { - if t := ko(c.ManualKo, c.Manual); t != "" { - return " " + html.EscapeString(t) - } - return "" -} - -// inline escapes text and makes `code` spans of what is in backticks. -func inline(s string) string { - parts := strings.Split(s, "`") - var b strings.Builder - for i, p := range parts { - switch { - case i%2 == 1 && i < len(parts)-1: - b.WriteString("" + html.EscapeString(p) + "") - case i%2 == 1: // an unpaired backtick at the end: keep it as text - b.WriteString("`" + html.EscapeString(p)) - default: - b.WriteString(html.EscapeString(p)) - } - } - return b.String() -} diff --git a/site/index.html b/site/index.html index f248edc..ca0e7bf 100644 --- a/site/index.html +++ b/site/index.html @@ -252,6 +252,7 @@

See the whole fleet

vmsctl.yaml · All documentation · How it compares · + Ubuntu 22.04 STIG controls · Rule reference · Security diff --git a/site/sitemap.xml b/site/sitemap.xml index 74b6a9c..ec83699 100644 --- a/site/sitemap.xml +++ b/site/sitemap.xml @@ -3,4 +3,5 @@ https://with-developer.github.io/vmsctl/ https://with-developer.github.io/vmsctl/ko/ https://with-developer.github.io/vmsctl/ko/kisa/ + https://with-developer.github.io/vmsctl/stig/ubuntu2204/ diff --git a/site/stig/ubuntu2204/index.html b/site/stig/ubuntu2204/index.html new file mode 100644 index 0000000..3967f22 --- /dev/null +++ b/site/stig/ubuntu2204/index.html @@ -0,0 +1,376 @@ + + + + + + +Ubuntu 22.04 STIG: the 27 controls vmsctl checks, and how to fix them — vmsctl + + + + + + + + + + + + +
+
+ vmsctl + +
+
+
+
+

Ubuntu 22.04 STIG: the 27 controls vmsctl checks

+

These are 27 of the 188 controls of the DISA Security Technical Implementation Guide for Canonical Ubuntu 22.04 LTS (V2R8) that vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires.

+
curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh
+sudo vmsctl scan --profile stig-ubuntu2204
+

Every result carries its evidence (the value, the file and the line); vmsctl explain UBTU-22-255040 prints a control in the terminal. What the profile covers: docs/stig.md. About the tool: vmsctl.

+ +
+

UBTU-22-211015 Ctrl-Alt-Delete does not reboot the host

+

Importance high (CAT I)

+
+

services.unit-masked A systemd unit that the control forbids is masked

+

Checks that the systemd unit named by the parameter unit (such as ctrl-alt-del.target) is masked: linked to /dev/null, so nothing can start it. The profile that uses this check says which unit. Only a profile sets the parameter.

+

Why it matters. Some units must never run on a server (a key press that reboots it, a service that has no place there); only masking keeps another unit or a person from starting them.

+

How to fix it. Mask the unit (systemctl mask <unit>).

+

Values used for this control: unit = ctrl-alt-del.target

+
+
+
+

UBTU-22-213010 Kernel messages are restricted to privileged users

+

Importance low (CAT III)

+
+

sysctl.dmesg-restrict Only privileged users can read the kernel log

+

Checks the kernel parameter kernel.dmesg_restrict (1 limits dmesg to privileged users). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged.

+

Why it matters. The kernel log can show addresses, device details and the traces of failed exploits.

+

How to fix it. Set kernel.dmesg_restrict = 1 in a file of /etc/sysctl.d and apply it with sysctl --system.

+
+
+
+

UBTU-22-213020 Address space layout randomization is on

+

Importance medium (CAT II)

+
+

sysctl.aslr Address space layout randomization is fully on

+

Checks the kernel parameter kernel.randomize_va_space (it must be 2: randomize the stack, libraries and the heap). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged.

+

Why it matters. Randomized addresses make memory-corruption bugs much harder to turn into working exploits.

+

How to fix it. Set kernel.randomize_va_space = 2 in a file of /etc/sysctl.d and apply it with sysctl --system.

+
+
+
+

UBTU-22-215010 The password quality library is installed

+

Importance medium (CAT II)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = libpam-pwquality

+
+
+
+

UBTU-22-215015 chrony is installed

+

Importance low (CAT III)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = chrony

+
+
+
+

UBTU-22-215020 systemd-timesyncd is not installed

+

Importance low (CAT III)

+
+

packages.absent A package that the control forbids is not installed

+

Checks that the package named by the parameter package is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter.

+

Why it matters. A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked.

+

How to fix it. Remove the package with the package manager (for example apt remove <package>).

+

Values used for this control: package = systemd-timesyncd

+
+
+
+

UBTU-22-215025 ntp is not installed

+

Importance low (CAT III)

+
+

packages.absent A package that the control forbids is not installed

+

Checks that the package named by the parameter package is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter.

+

Why it matters. A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked.

+

How to fix it. Remove the package with the package manager (for example apt remove <package>).

+

Values used for this control: package = ntp

+
+
+
+

UBTU-22-215030 The rsh server is not installed

+

Importance high (CAT I)

+
+

packages.absent A package that the control forbids is not installed

+

Checks that the package named by the parameter package is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter.

+

Why it matters. A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked.

+

How to fix it. Remove the package with the package manager (for example apt remove <package>).

+

Values used for this control: package = rsh-server

+
+
+
+

UBTU-22-215035 The telnet server is not installed

+

Importance high (CAT I)

+
+

packages.absent A package that the control forbids is not installed

+

Checks that the package named by the parameter package is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter.

+

Why it matters. A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked.

+

How to fix it. Remove the package with the package manager (for example apt remove <package>).

+

Values used for this control: package = telnetd

+
+
+
+

UBTU-22-215040 The NFS server is not installed

+

Importance medium (CAT II)

+
+

packages.absent A package that the control forbids is not installed

+

Checks that the package named by the parameter package is not installed (dpkg or rpm). The profile that uses this check says which package. Only a profile sets the parameter.

+

Why it matters. A package that is not needed adds code, and often a listening service, that has to be kept patched and can be attacked.

+

How to fix it. Remove the package with the package manager (for example apt remove <package>).

+

Values used for this control: package = nfs-kernel-server

+
+
+
+

UBTU-22-251010 ufw is installed

+

Importance medium (CAT II)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = ufw

+
+
+
+

UBTU-22-251015 ufw is turned on

+

Importance medium (CAT II)

+
+

firewall.ufw-active ufw is turned on

+

Checks that /etc/ufw/ufw.conf sets ENABLED=yes, which is what makes ufw filter at boot (installing the package enables its unit, so the unit alone says nothing). Without ufw there is nothing to turn on, and the check fails: it is for profiles that require ufw itself, such as the Ubuntu STIG; firewall.enabled accepts any host firewall.

+

Why it matters. Without a firewall, every service that listens on an address is open to everyone who can reach it.

+

How to fix it. Allow what the host serves and turn ufw on: ufw allow 22/tcp, then ufw enable. Allow your own SSH connection first.

+
+
+
+

UBTU-22-251020 The ufw service starts at boot

+

Importance medium (CAT II)

+
+

services.unit-enabled A systemd unit that the control requires is enabled

+

Checks that the systemd unit named by the parameter unit (such as ssh.service) is enabled, so it starts at boot, and not masked. The profile that uses this check says which unit. Only a profile sets the parameter.

+

Why it matters. A control that needs a service to run cannot be met if the service does not start by itself.

+

How to fix it. Enable the unit (systemctl enable --now <unit>) and unmask it if it is masked (systemctl unmask <unit>).

+

Values used for this control: unit = ufw.service

+
+
+
+

UBTU-22-253010 TCP SYN cookies are on

+

Importance medium (CAT II)

+
+

sysctl.syncookies TCP SYN cookies are on

+

Checks the kernel parameter net.ipv4.tcp_syncookies (1: answer a flood of connection attempts with cookies once the queue is full). On a running host the value is what the kernel reports; for a mounted root it is what the files of sysctl.d(5) set at boot, and a parameter they do not set cannot be judged.

+

Why it matters. SYN cookies keep a flood of half-open connections from using up the memory of the connection queue.

+

How to fix it. Set net.ipv4.tcp_syncookies = 1 in a file of /etc/sysctl.d and apply it with sysctl --system.

+
+
+
+

UBTU-22-255010 The SSH server is installed

+

Importance high (CAT I)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = openssh-server

+
+
+
+

UBTU-22-255015 The SSH service starts at boot

+

Importance high (CAT I)

+
+

services.unit-enabled A systemd unit that the control requires is enabled

+

Checks that the systemd unit named by the parameter unit (such as ssh.service) is enabled, so it starts at boot, and not masked. The profile that uses this check says which unit. Only a profile sets the parameter.

+

Why it matters. A control that needs a service to run cannot be met if the service does not start by itself.

+

How to fix it. Enable the unit (systemctl enable --now <unit>) and unmask it if it is masked (systemctl unmask <unit>).

+

Values used for this control: unit = ssh.service

+
+
+
+

UBTU-22-255025 SSH allows no empty passwords and no user environment

+

Importance high (CAT I)

+
+

ssh.permit-empty-passwords SSH does not accept empty passwords

+

Checks the global PermitEmptyPasswords setting of the OpenSSH server. On a live host the effective value comes from sshd -T, so the default of the installed version counts.

+

Why it matters. An account without a password would let anyone log in over the network.

+

How to fix it. Set PermitEmptyPasswords no in /etc/ssh/sshd_config (or a file it includes) and reload sshd.

+
+
+

ssh.permit-user-environment SSH does not let users set the environment

+

Checks the global PermitUserEnvironment setting of the OpenSSH server. On a live host the effective value comes from sshd -T, so the default of the installed version counts.

+

Why it matters. Environment settings from a user's own files can change how the login shell and PAM modules behave, which defeats restrictions set for the account.

+

How to fix it. Set PermitUserEnvironment no in /etc/ssh/sshd_config (or a file it includes) and reload sshd.

+
+
+
+

UBTU-22-255040 SSH does not forward X11

+

Importance high (CAT I)

+
+

ssh.x11-forwarding SSH does not forward X11

+

Checks the global X11Forwarding setting of the OpenSSH server. On a live host the effective value comes from sshd -T, so the default of the installed version counts.

+

Why it matters. X11 forwarding exposes the client's display to the server, and anything that controls the server can then watch or drive it.

+

How to fix it. Set X11Forwarding no in /etc/ssh/sshd_config (or a file it includes) and reload sshd.

+
+
+
+

UBTU-22-411010 The root account is locked

+

Importance medium (CAT II)

+
+

accounts.root-locked The root account has no password that can log in

+

Checks in /etc/shadow that the root account is locked (its password field starts with "!" or is "*"), so no password logs in as root. Administrators use their own accounts and sudo. Without /etc/shadow there is nothing to check, so the check cannot pass.

+

Why it matters. A root password is a shared secret for the most powerful account, which anyone can guess or leak and which says nothing about who used it.

+

How to fix it. Lock the root password (passwd -l root) after an administrator has an account in the sudo group.

+
+
+
+

UBTU-22-411015 Every account has its own UID

+

Importance medium (CAT II)

+
+

accounts.unique-uids Every account has its own UID

+

Lists accounts that share a UID with another account.

+

Why it matters. Accounts sharing a UID are the same user to the kernel, so access and audit trails cannot tell them apart.

+

How to fix it. Give each account a unique UID (usermod -u) and fix the ownership of its files.

+
+
+
+

UBTU-22-411025 A password cannot be changed again within a day

+

Importance medium (CAT II)

+
+

accounts.password-min-age Passwords cannot be changed back at once

+

Checks PASS_MIN_DAYS in /etc/login.defs, the minimum days between password changes.

+

Why it matters. Without a minimum age, a user can cycle through passwords in minutes to get back to the old one and defeat the password history.

+

How to fix it. Set PASS_MIN_DAYS 1 (or more) in /etc/login.defs.

+

Values used for this control: min_days = 1

+
+
+
+

UBTU-22-411030 A password expires after 60 days

+

Importance medium (CAT II)

+
+

accounts.password-max-age Passwords expire

+

Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new accounts. Without it, shadow-utils uses -1, which means passwords never expire.

+

Why it matters. A password that never changes stays useful to whoever obtained it.

+

How to fix it. Set PASS_MAX_DAYS 90 (or less) in /etc/login.defs; apply it to existing accounts with chage.

+

Values used for this control: max_days = 60

+
+
+
+

UBTU-22-412030 An idle shell session ends after 15 minutes

+

Importance medium (CAT II)

+
+

accounts.session-timeout-set Idle shells time out

+

Checks that the system-wide startup files (/etc/environment, /etc/profile and the files it reads, such as /etc/profile.d) leave TMOUT set to a positive number of seconds, so that it applies to every user's login shell: a value set only in root's own files does not count, assignments inside if or case blocks do not count, and a later unset removes it.

+

Why it matters. An unattended logged-in terminal can be used by anyone who reaches it.

+

How to fix it. Add TMOUT=600 and readonly TMOUT and export TMOUT to a file in /etc/profile.d.

+
+
+

accounts.session-timeout-value The idle timeout is short enough

+

Lists TMOUT assignments that are empty, zero or longer than max_seconds, and unset TMOUT commands, including those inside if or case blocks, which can apply to some sessions.

+

Why it matters. A long or disabled timeout leaves idle sessions open.

+

How to fix it. Set TMOUT=600 (or less) and remove larger assignments and unset commands.

+

Values used for this control: max_seconds = 900

+
+
+
+

UBTU-22-431010 AppArmor is installed

+

Importance medium (CAT II)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = apparmor

+
+
+
+

UBTU-22-611035 A password has at least 15 characters

+

Importance medium (CAT II)

+
+

accounts.password-min-length Passwords have a minimum length

+

Checks that the passwd service's PAM stack enforces password quality (pam_pwquality or pam_cracklib, not in warning-only mode) with a minimum length of at least min_length characters. Positive credits let a password be shorter by up to their sum, so they count against minlen.

+

Why it matters. Short passwords fall quickly to guessing and offline cracking.

+

How to fix it. Enable pam_pwquality in the password stack (authselect, pam-auth-update), set minlen = 8 or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits.

+

Values used for this control: min_length = 15

+
+
+
+

UBTU-22-611065 No account has an empty password

+

Importance high (CAT I)

+
+

accounts.no-empty-passwords No account has an empty password

+

Lists the accounts whose password field in /etc/shadow is empty, which means no password is needed to use them wherever PAM accepts it (the nullok option of pam_unix, which some default configurations still carry). Locked accounts ("!" or "*") are not listed. Without /etc/shadow there is nothing to check, so the check cannot pass.

+

Why it matters. An account without a password lets anyone who can reach a login prompt, a console or su use it.

+

How to fix it. Set a password for each listed account (passwd user), or lock it (passwd -l user). Remove nullok from the pam_unix lines in the PAM configuration so an empty password is refused.

+
+
+
+

UBTU-22-653010 The audit daemon is installed

+

Importance medium (CAT II)

+
+

packages.installed A package that the control requires is installed

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

+

How to fix it. Install the package with the package manager (for example apt install <package>).

+

Values used for this control: package = auditd

+
+
+
+
+ + + From 9d41982f0433ac66a2b54827843221e598059faa Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:18:41 +0900 Subject: [PATCH 4/6] fix: STIG profile: review fixes (a profile can name its OS and is NOT_APPLICABLE elsewhere; partly installed packages are not installed; root without a shadow entry is not locked; fix text that matches the parameter; page numbers checked; the fix pointer needs a failed control) --- CLAUDE.md | 4 +- docs/rules.ko.md | 18 +++---- docs/rules.md | 18 +++---- docs/stig.ko.md | 10 ++-- docs/stig.md | 10 ++-- internal/engine/content.go | 17 +++++-- internal/engine/scan.go | 26 +++++++++- internal/engine/waiver_test.go | 58 +++++++++++++++++++++++ internal/output/output_test.go | 25 ++++++++++ internal/output/table.go | 21 +++++--- internal/rulesdoc/rulesdoc_test.go | 15 ++++++ internal/rulesdoc/site.go | 12 +++-- profiles/stig-ubuntu2204.yaml | 1 + rules/accounts/password-max-age.yaml | 7 ++- rules/accounts/password-min-length.yaml | 9 ++-- rules/accounts/root-locked.yaml | 10 +++- rules/accounts/session-timeout-value.yaml | 7 ++- rules/packages/installed.yaml | 11 +++-- site/ko/kisa/index.html | 8 ++-- site/stig/ubuntu2204/index.html | 22 ++++----- 20 files changed, 240 insertions(+), 69 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 532a50c..c0c70a6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,7 +58,7 @@ required check on `main`. | `internal/rulesdoc/` | Renders the rule reference `docs/rules.md` and the fact reference `docs/facts.md` from the built-in rules, profiles and collectors | | `internal/output/` | Terminal, JSON, SARIF, JUnit and HTML output | | `rules/` | Built-in checks (YAML), embedded in the binary | -| `profiles/` | Versioned control mappings per standard edition (e.g. `kisa-2026`), embedded | +| `profiles/` | Versioned control mappings per standard edition (e.g. `kisa-2026`; `stig-ubuntu2204` names its OS with `os:`), embedded | | `schema/` | JSON Schema of the result document (ADR 0006), with a valid example | | `testdata/` | Fixture root filesystems per distro (hardened and default) | | `e2e/` | Docker-based scans of every supported distribution (stock and hardened), image scans, and the golden results | @@ -67,7 +67,7 @@ required check on `main`. | `packaging/container/` | The Dockerfile of the release image on ghcr.io (`.github/workflows/container.yml`) | | `install.sh` | The installer: downloads a release, verifies it, installs the binary | | `scripts/` | Release checks, the translation check, lint guards and the live demo build (`check-release.sh`, `check-translations.sh`, `lint-guards.sh`, `build-demo.sh`) | -| `site/` | The project page for GitHub Pages (English, and `ko/`, with the generated KISA page `ko/kisa/`) and the live demo `demo/` (built, not committed); published by `.github/workflows/pages.yml` | +| `site/` | The project page for GitHub Pages (English, and `ko/`, with the generated pages `ko/kisa/` and `stig/ubuntu2204/`, both from `internal/rulesdoc/site.go` by `make docs`) and the live demo `demo/` (built, not committed); published by `.github/workflows/pages.yml` | | `.goreleaser.yaml` | Release build: archives, packages, SBOMs, checksums and signing (docs/RELEASING.md) | ## Security invariants — never violate diff --git a/docs/rules.ko.md b/docs/rules.ko.md index 5cbf248..5c50751 100644 --- a/docs/rules.ko.md +++ b/docs/rules.ko.md @@ -106,7 +106,7 @@ login과 (SSH 서버가 있으면) sshd의 PAM 스택이 pam_faillock이나 pam_ **이유.** 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다. -**조치 방법.** /etc/login.defs에 `PASS_MAX_DAYS 90`(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요. +**조치 방법.** /etc/login.defs의 `PASS_MAX_DAYS`를 요구하는 일수로 설정하고(기본값은 90일 이하이며, 더 엄격한 프로파일이나 설정은 60일처럼 더 짧게 요구합니다), 이미 있는 계정에는 chage로 적용하세요. **매개변수** (설명은 영어). @@ -134,7 +134,7 @@ passwd 서비스의 PAM 스택이 경고만 하는 모드가 아닌 상태로 **이유.** 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다. -**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 `minlen = 8` 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요. +**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf의 `minlen`을 요구하는 길이로 설정하세요(기본값은 8 이상이며, 더 엄격한 프로파일이나 설정은 15처럼 더 길게 요구합니다). enforcing = 0이나 양수 크레딧은 설정하지 마세요. **매개변수** (설명은 영어). @@ -934,7 +934,7 @@ passwd 서비스가 최근 `remember`개의 비밀번호를 거부하는지, roo **이유.** 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다. -**조치 방법.** /etc/login.defs에 `PASS_MAX_DAYS 90`(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요. +**조치 방법.** /etc/login.defs의 `PASS_MAX_DAYS`를 요구하는 일수로 설정하고(기본값은 90일 이하이며, 더 엄격한 프로파일이나 설정은 60일처럼 더 짧게 요구합니다), 이미 있는 계정에는 chage로 적용하세요. **매개변수** (설명은 영어). @@ -976,7 +976,7 @@ passwd 서비스의 PAM 스택이 경고만 하는 모드가 아닌 상태로 **이유.** 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다. -**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 `minlen = 8` 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요. +**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf의 `minlen`을 요구하는 길이로 설정하세요(기본값은 8 이상이며, 더 엄격한 프로파일이나 설정은 15처럼 더 길게 요구합니다). enforcing = 0이나 양수 크레딧은 설정하지 마세요. **매개변수** (설명은 영어). @@ -1040,7 +1040,7 @@ root(GID 0), wheel, sudo, admin 그룹의 구성원을 나열합니다. 해당 **이유.** 제한 시간이 길거나 꺼져 있으면 유휴 세션이 열린 채 남습니다. -**조치 방법.** `TMOUT=600`(또는 그보다 짧은 값)을 설정하고, 더 큰 값의 대입과 unset 명령은 지우세요. +**조치 방법.** `TMOUT`을 요구하는 초 단위 값으로 설정하고(기본값은 600초 이하이며, 더 엄격한 프로파일이나 설정은 더 짧게 요구합니다), 더 큰 값의 대입과 unset 명령은 지우세요. **매개변수** (설명은 영어). @@ -1904,7 +1904,7 @@ Canonical Ubuntu 22.04 LTS STIG(V2R8) 중 vmsctl이 점검하는 항목 **이유.** 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다. -**조치 방법.** /etc/login.defs에 `PASS_MAX_DAYS 90`(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요. +**조치 방법.** /etc/login.defs의 `PASS_MAX_DAYS`를 요구하는 일수로 설정하고(기본값은 90일 이하이며, 더 엄격한 프로파일이나 설정은 60일처럼 더 짧게 요구합니다), 이미 있는 계정에는 chage로 적용하세요. **매개변수** (설명은 영어). @@ -1932,7 +1932,7 @@ passwd 서비스의 PAM 스택이 경고만 하는 모드가 아닌 상태로 **이유.** 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다. -**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 `minlen = 8` 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요. +**조치 방법.** password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf의 `minlen`을 요구하는 길이로 설정하세요(기본값은 8 이상이며, 더 엄격한 프로파일이나 설정은 15처럼 더 길게 요구합니다). enforcing = 0이나 양수 크레딧은 설정하지 마세요. **매개변수** (설명은 영어). @@ -1966,7 +1966,7 @@ root 계정에 로그인할 수 있는 비밀번호가 없음 — 심각도 중 **이유.** 제한 시간이 길거나 꺼져 있으면 유휴 세션이 열린 채 남습니다. -**조치 방법.** `TMOUT=600`(또는 그보다 짧은 값)을 설정하고, 더 큰 값의 대입과 unset 명령은 지우세요. +**조치 방법.** `TMOUT`을 요구하는 초 단위 값으로 설정하고(기본값은 600초 이하이며, 더 엄격한 프로파일이나 설정은 더 짧게 요구합니다), 더 큰 값의 대입과 unset 명령은 지우세요. **매개변수** (설명은 영어). @@ -2010,7 +2010,7 @@ ufw가 켜져 있음 — 심각도 중간, 식을 평가합니다. 점검 항목이 요구하는 패키지가 설치되어 있음 — 심각도 중간, 식을 평가합니다. -매개변수 `package`가 가리키는 패키지가 설치되어 있는지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 정합니다. 제거했지만 설정 파일이 남은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. +매개변수 `package`가 가리키는 패키지가 설치되어 있는지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 정합니다. 제거했지만 설정 파일이 남은 패키지나, 풀기만 했거나 설정이 끝나지 않은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. **이유.** 보안 도구나 서비스가 있어야 하는 점검 항목은 그 패키지가 없으면 충족할 수 없습니다. diff --git a/docs/rules.md b/docs/rules.md index 3487a3f..398fba6 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -107,7 +107,7 @@ Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new a **Why.** A password that never changes stays useful to whoever obtained it. -**Fix.** Set `PASS_MAX_DAYS 90` (or less) in /etc/login.defs; apply it to existing accounts with chage. +**Fix.** Set `PASS_MAX_DAYS` in /etc/login.defs to the required number of days (90 or less by default; a stricter profile or configuration asks for fewer, such as 60); apply it to existing accounts with chage. **Parameters.** @@ -135,7 +135,7 @@ Checks that the passwd service's PAM stack enforces password quality (pam_pwqual **Why.** Short passwords fall quickly to guessing and offline cracking. -**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen = 8` or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits. +**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen` in /etc/security/pwquality.conf to the required length (8 or more by default; a stricter profile or configuration asks for more, such as 15), and do not set enforcing = 0 or positive credits. **Parameters.** @@ -935,7 +935,7 @@ Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new a **Why.** A password that never changes stays useful to whoever obtained it. -**Fix.** Set `PASS_MAX_DAYS 90` (or less) in /etc/login.defs; apply it to existing accounts with chage. +**Fix.** Set `PASS_MAX_DAYS` in /etc/login.defs to the required number of days (90 or less by default; a stricter profile or configuration asks for fewer, such as 60); apply it to existing accounts with chage. **Parameters.** @@ -977,7 +977,7 @@ Checks that the passwd service's PAM stack enforces password quality (pam_pwqual **Why.** Short passwords fall quickly to guessing and offline cracking. -**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen = 8` or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits. +**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen` in /etc/security/pwquality.conf to the required length (8 or more by default; a stricter profile or configuration asks for more, such as 15), and do not set enforcing = 0 or positive credits. **Parameters.** @@ -1041,7 +1041,7 @@ Lists TMOUT assignments that are empty, zero or longer than `max_seconds`, and u **Why.** A long or disabled timeout leaves idle sessions open. -**Fix.** Set `TMOUT=600` (or less) and remove larger assignments and unset commands. +**Fix.** Set `TMOUT` to the required number of seconds (600 or less by default; a stricter profile or configuration asks for fewer) and remove larger assignments and unset commands. **Parameters.** @@ -1905,7 +1905,7 @@ Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new a **Why.** A password that never changes stays useful to whoever obtained it. -**Fix.** Set `PASS_MAX_DAYS 90` (or less) in /etc/login.defs; apply it to existing accounts with chage. +**Fix.** Set `PASS_MAX_DAYS` in /etc/login.defs to the required number of days (90 or less by default; a stricter profile or configuration asks for fewer, such as 60); apply it to existing accounts with chage. **Parameters.** @@ -1933,7 +1933,7 @@ Checks that the passwd service's PAM stack enforces password quality (pam_pwqual **Why.** Short passwords fall quickly to guessing and offline cracking. -**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen = 8` or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits. +**Fix.** Enable pam_pwquality in the password stack (authselect, pam-auth-update), set `minlen` in /etc/security/pwquality.conf to the required length (8 or more by default; a stricter profile or configuration asks for more, such as 15), and do not set enforcing = 0 or positive credits. **Parameters.** @@ -1967,7 +1967,7 @@ Lists TMOUT assignments that are empty, zero or longer than `max_seconds`, and u **Why.** A long or disabled timeout leaves idle sessions open. -**Fix.** Set `TMOUT=600` (or less) and remove larger assignments and unset commands. +**Fix.** Set `TMOUT` to the required number of seconds (600 or less by default; a stricter profile or configuration asks for fewer) and remove larger assignments and unset commands. **Parameters.** @@ -2011,7 +2011,7 @@ Checks that the package named by the parameter `package` is not installed (dpkg A package that the control requires is installed (점검 항목이 요구하는 패키지가 설치되어 있음) — severity medium, evaluates an expression. -Checks that the package named by the parameter `package` is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter. +Checks that the package named by the parameter `package` is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter. **Why.** A control that needs a security tool or a service on the host cannot be met without its package. diff --git a/docs/stig.ko.md b/docs/stig.ko.md index 23e414b..0fdfa88 100644 --- a/docs/stig.ko.md +++ b/docs/stig.ko.md @@ -3,7 +3,7 @@ `stig-ubuntu2204`는 미 국방부가 DISA를 통해 공개하는 [Canonical Ubuntu 22.04 LTS Security Technical Implementation Guide](https://public.cyber.mil/stigs/)(STIG) V2R8의 점검 항목으로 -호스트를 점검합니다. 미국 기준을 다루는 첫 프로파일이고, 다음은 RHEL 9용 프로파일입니다. +호스트를 점검합니다. vmsctl에서 미국 기준을 다루는 프로파일입니다. ```sh sudo vmsctl scan --profile stig-ubuntu2204 @@ -38,7 +38,9 @@ vmsctl explain UBTU-22-255040 # 점검 항목이 무엇을 보고, 왜 점검 항목 ID와 중요도(CAT I은 `high`, CAT II는 `medium`, CAT III은 `low`)는 STIG의 것이며 STIG는 미국 정부 저작물입니다. 제목은 vmsctl이 직접 짧게 쓴 것입니다. 연결은 [ComplianceAsCode](https://github.com/ComplianceAsCode/content)가 이 STIG에 대해 공개한 -점검 항목 목록을 기준으로, 항목마다 요구 사항과 대조해서 만들었습니다. 어떤 배포판의 호스트든 점검 결과는 나오지만, 이 프로파일이 -대상으로 하는 것은 Ubuntu 22.04 호스트뿐입니다. +점검 항목 목록을 기준으로, 항목마다 요구 사항과 대조해서 만들었습니다. 이 프로파일은 대상 시스템을 스스로 밝힙니다(`os: [ubuntu-22.04]`). 다른 호스트에서는 모든 점검 항목이 이유와 함께 +`NOT_APPLICABLE`입니다. Ubuntu 22.04용으로 쓴 기준은 다른 시스템에 대해 참인 말을 하지 못하기 때문입니다. -점검이 갖춰지는 대로 항목을 늘립니다(가장 큰 묶음은 감사 규칙입니다). +연결 두 개는 STIG보다 엄격합니다(느슨하지는 않습니다). `UBTU-22-611035`가 쓰는 `accounts.password-min-length`는 양수 `dcredit`, +`ucredit` 크레딧을 `minlen`에서 빼므로, `minlen = 15`에 양수 크레딧을 함께 설정한 호스트는 STIG라면 통과시킬 것을 실패로 볼 수 있습니다. +`accounts.password-max-age`는 0 이하의 값도 실패로 봅니다. 점검이 갖춰지는 대로 항목을 늘립니다(가장 큰 묶음은 감사 규칙입니다). diff --git a/docs/stig.md b/docs/stig.md index 9e31119..f484655 100644 --- a/docs/stig.md +++ b/docs/stig.md @@ -2,7 +2,7 @@ `stig-ubuntu2204` checks a host against the controls of the [Canonical Ubuntu 22.04 LTS Security Technical Implementation Guide](https://public.cyber.mil/stigs/) (STIG), version V2R8, that -the US Department of Defense publishes through DISA. It is the first profile for a US baseline; the profile for RHEL 9 is next. +the US Department of Defense publishes through DISA. It is vmsctl's profile for a US baseline. ```sh sudo vmsctl scan --profile stig-ubuntu2204 @@ -38,6 +38,10 @@ not mapped. Where a control needs a package, a unit or a number, a small generic The control IDs and their importance (CAT I is `high`, CAT II `medium`, CAT III `low`) are the STIG's; the STIG is a US government work. The titles are vmsctl's own short wording. The mapping was made against the control list that [ComplianceAsCode](https://github.com/ComplianceAsCode/content) publishes for this STIG and checked against each control's requirement. -The scan reports what it finds on a host of any distribution, but only an Ubuntu 22.04 host is what the profile is for. +The profile names the system it is for (`os: [ubuntu-22.04]`): on any other host every control is `NOT_APPLICABLE`, with the reason, because a +standard written for Ubuntu 22.04 says nothing true about another system. -More controls come as the checks they need exist (the audit rules are the largest group). +Two mappings are stricter than the STIG, never looser: `UBTU-22-611035` uses `accounts.password-min-length`, which subtracts positive +`dcredit` and `ucredit` credits from `minlen`, so a host that sets `minlen = 15` together with a positive credit can fail where the STIG would +pass it; and `accounts.password-max-age` also fails a value of 0 or less. More controls come as the checks they need exist (the audit rules +are the largest group). diff --git a/internal/engine/content.go b/internal/engine/content.go index 6f63f81..5a2d996 100644 --- a/internal/engine/content.go +++ b/internal/engine/content.go @@ -179,10 +179,13 @@ type TestFile struct { // Profile maps one standard edition's controls to checks. type Profile struct { - ID string `yaml:"id"` - Revision int `yaml:"revision"` - Title string `yaml:"title"` - TitleKo string `yaml:"title_ko"` + ID string `yaml:"id"` + Revision int `yaml:"revision"` + Title string `yaml:"title"` + TitleKo string `yaml:"title_ko"` + // OS names the operating systems the profile is for, as ID-VERSION_ID of /etc/os-release (ubuntu-22.04). On any other host every + // control is NOT_APPLICABLE, with the reason: a standard written for one distribution says nothing true about another. Empty: any. + OS []string `yaml:"os"` Controls []Control `yaml:"controls"` } @@ -207,6 +210,7 @@ type Content struct { var ( checkIDRe = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*\.[a-z0-9]+(-[a-z0-9]+)*$`) profileIDRe = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`) + profileOSRe = regexp.MustCompile(`^[a-z0-9_.]+-[0-9][0-9.]*$`) paramRe = regexp.MustCompile(`^[a-z][a-z0-9_]*$`) identRe = regexp.MustCompile(`^[a-z_][a-z0-9_]*$`) factPathRe = regexp.MustCompile(`^[a-z_][a-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+(\["[^"\\]+"\])?$|^[a-z_][a-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*\["[^"\\]+"\]$`) @@ -511,6 +515,11 @@ func validateProfile(file string, pr *Profile, checks map[string]*Check) error { if strings.TrimSpace(pr.Title) == "" { p.add("title is required") } + for _, os := range pr.OS { + if !profileOSRe.MatchString(os) { + p.add("os %q must be ID-VERSION_ID such as ubuntu-22.04", os) + } + } seen := map[string]bool{} for _, ctl := range pr.Controls { if ctl.ID == "" || seen[ctl.ID] { diff --git a/internal/engine/scan.go b/internal/engine/scan.go index e76d33e..fd27d1e 100644 --- a/internal/engine/scan.go +++ b/internal/engine/scan.go @@ -219,6 +219,11 @@ func (e *Engine) Scan(ctx context.Context, h *hostfs.Host, opts Options) (*Resul profileChecks := map[string]bool{} for i, ctl := range profile.Controls { cr := aggregate(profile.ID, ctl, controlRefs[pi][i], checks) + if !profileFitsOS(profile, res.Host.OS) { + // What the standard says is about another system: nothing it checks is true or false of this one. + cr.Status = StatusNotApplicable + cr.Reason = "this profile is for " + strings.Join(profile.OS, " or ") + "; the host is " + hostOSName(res.Host.OS) + } notes = append(notes, waiveControl(opts.Waivers, profile, e.content.ProfileDigest(profile), &cr, checks, res.Host.Hostname, today)...) cr.Customized = slices.ContainsFunc(cr.Checks, func(ref string) bool { return checks[ref].Customized }) summary.Controls[cr.Status]++ @@ -410,12 +415,31 @@ func (c *Content) ProfileDigest(p *Profile) string { doc := struct { ID string Revision int + OS []string `json:",omitempty"` Controls []ctl Pack map[string]string `json:",omitempty"` - }{p.ID, p.Revision, ctls, packChecks} + }{p.ID, p.Revision, p.OS, ctls, packChecks} return "sha256:" + digestHex(doc) } +// profileFitsOS reports whether the host is one of the systems the profile is for (any, when it names none). +func profileFitsOS(p *Profile, os OSInfo) bool { + if len(p.OS) == 0 { + return true + } + return slices.Contains(p.OS, os.ID+"-"+os.VersionID) +} + +func hostOSName(os OSInfo) string { + if os.ID == "" { + return "an unknown system" + } + if os.VersionID == "" { + return os.ID + } + return os.ID + "-" + os.VersionID +} + func digestHex(v any) string { data, err := json.Marshal(v) // map keys are sorted, so this is canonical if err != nil { diff --git a/internal/engine/waiver_test.go b/internal/engine/waiver_test.go index f095c81..dedfe18 100644 --- a/internal/engine/waiver_test.go +++ b/internal/engine/waiver_test.go @@ -159,3 +159,61 @@ func TestParamOverrides(t *testing.T) { } } } + +// A profile that names its OS says nothing about another one: every control is NOT_APPLICABLE, with the reason; on the OS it +// is for, the controls are decided as usual. demoHost is ubuntu-24.04. +func TestProfileOS(t *testing.T) { + scan := func(os []string) *Result { + svc := demoSvc() + checks := []*Check{{ID: "x.fail", Version: 1, Title: "T", Severity: SeverityLow, Expect: `svc.config.permitrootlogin.value == "yes"`}} + content := &Content{Checks: map[string]*Check{"x.fail": checks[0]}, Profiles: map[string]*Profile{"p": { + ID: "p", Revision: 1, Title: "P", OS: os, Controls: []Control{{ID: "C-01", Title: "C", Severity: SeverityLow, Checks: []string{"x.fail"}}}, + }}} + e, err := New(content, svc) + if err != nil { + t.Fatal(err) + } + res, err := e.Scan(context.Background(), hostfs.NewTestHost(demoHost(), nil, false), Options{Profile: "p"}) + if err != nil { + t.Fatal(err) + } + validateSchema(t, res) + return res + } + for _, tc := range []struct { + name string + os []string + want Status + }{ + {"no OS named: any host", nil, StatusFail}, + {"the OS it is for", []string{"ubuntu-24.04"}, StatusFail}, + {"one of several", []string{"ubuntu-22.04", "ubuntu-24.04"}, StatusFail}, + {"another version", []string{"ubuntu-22.04"}, StatusNotApplicable}, + {"another distribution", []string{"debian-12"}, StatusNotApplicable}, + } { + got := scan(tc.os).Controls[0] + if got.Status != tc.want { + t.Errorf("%s: %s (%q), want %s", tc.name, got.Status, got.Reason, tc.want) + } + if tc.want == StatusNotApplicable && (!strings.Contains(got.Reason, strings.Join(tc.os, " or ")) || !strings.Contains(got.Reason, "ubuntu-24.04")) { + t.Errorf("%s: the reason does not say which systems: %q", tc.name, got.Reason) + } + } + // A profile without an OS has the digest it had before the field existed; one with an OS has another. + c := &Content{Checks: map[string]*Check{}} + plain := &Profile{ID: "p", Revision: 1, Controls: nil} + withOS := &Profile{ID: "p", Revision: 1, OS: []string{"ubuntu-22.04"}} + if c.ProfileDigest(plain) == c.ProfileDigest(withOS) { + t.Error("the OS is not part of the profile digest") + } +} + +func TestProfileOSIsValidated(t *testing.T) { + for os, ok := range map[string]bool{"ubuntu-22.04": true, "rocky-9": true, "amzn-2023": true, "ubuntu": false, "Ubuntu-22.04": false, "ubuntu 22.04": false, "": false} { + pr := &Profile{ID: "p", Revision: 1, Title: "P", OS: []string{os}} + err := validateProfile("p.yaml", pr, map[string]*Check{}) + if (err == nil) != ok { + t.Errorf("os %q: err = %v", os, err) + } + } +} diff --git a/internal/output/output_test.go b/internal/output/output_test.go index 67d79b4..582d843 100644 --- a/internal/output/output_test.go +++ b/internal/output/output_test.go @@ -575,3 +575,28 @@ func TestKoreanManualReason(t *testing.T) { } } } + +// The pointer to explain is for a table that lists a failure: not for one whose failed checks sit under controls that are not +// applicable (a profile that is for another system). +func TestTableFixPointerNeedsAFailedControl(t *testing.T) { + res := readFixture(t, "web-01.json") + var buf bytes.Buffer + if err := Write(&buf, res, "table", Options{}); err != nil { + t.Fatal(err) + } + if !strings.Contains(buf.String(), "How to fix a failed check: vmsctl explain ") { + t.Errorf("no pointer next to a failure:\n%s", buf.String()) + } + for i := range res.Controls { + if res.Controls[i].Status == engine.StatusFail { + res.Controls[i].Status = engine.StatusNotApplicable + } + } + buf.Reset() + if err := Write(&buf, res, "table", Options{}); err != nil { + t.Fatal(err) + } + if strings.Contains(buf.String(), "How to fix a failed check") { + t.Errorf("a pointer with no failed control:\n%s", buf.String()) + } +} diff --git a/internal/output/table.go b/internal/output/table.go index 98fcfdb..3d7fdb5 100644 --- a/internal/output/table.go +++ b/internal/output/table.go @@ -3,7 +3,6 @@ package output import ( "fmt" "io" - "slices" "strconv" "strings" "unicode" @@ -124,7 +123,7 @@ func writeTable(w io.Writer, res *engine.Result, opts Options) error { if !opts.Verbose { b.WriteString(p.paint(dim, "Passing and not-applicable controls are hidden; use --verbose to list them.") + "\n") } - if slices.ContainsFunc(res.Checks, func(c engine.CheckResult) bool { return c.Status == engine.StatusFail }) { + if firstFailed(res) != "" { hint := "How to fix a failed check: vmsctl explain CHECK-ID (for example vmsctl explain " + firstFailed(res) + ")." if opts.Lang == "ko" { hint = "실패한 점검의 조치 방법: vmsctl explain 점검ID --lang ko (예: vmsctl explain " + firstFailed(res) + " --lang ko)." @@ -183,12 +182,22 @@ func oneLine(s string) string { return b.String() } -// firstFailed is the ID of the first failed check, for the example of the hint. +// firstFailed is the ID of the first failed check of a failed control, for the example of the hint ("" when no control failed: a +// check that failed under a control that is not applicable, as on a host that a profile is not for, is not what the table lists). func firstFailed(res *engine.Result) string { + byRef := map[string]engine.CheckResult{} for _, c := range res.Checks { - if c.Status == engine.StatusFail { - return oneLine(c.ID) + byRef[c.Ref] = c + } + for _, ctl := range res.Controls { + if ctl.Status != engine.StatusFail { + continue + } + for _, ref := range ctl.Checks { + if c, ok := byRef[ref]; ok && c.Status == engine.StatusFail { + return oneLine(c.ID) + } } } - return "CHECK-ID" + return "" } diff --git a/internal/rulesdoc/rulesdoc_test.go b/internal/rulesdoc/rulesdoc_test.go index 8f60265..1349bba 100644 --- a/internal/rulesdoc/rulesdoc_test.go +++ b/internal/rulesdoc/rulesdoc_test.go @@ -1,6 +1,7 @@ package rulesdoc import ( + "fmt" "flag" "os" "path/filepath" @@ -133,6 +134,11 @@ func TestStigSiteIsUpToDate(t *testing.T) { t.Errorf("no section for %s", c.ID) } } + // The numbers of the page are those of the profile and of the guide (docs/stig.md says them too). + prof := content.Profiles["stig-ubuntu2204"] + if !strings.Contains(prof.Title, stigVersion) || !strings.Contains(string(mustRead(t, filepath.Join("..", "..", "docs", "stig.md"))), fmt.Sprintf("the %d controls (of the %d of %s)", len(prof.Controls), stigControls, stigVersion)) { + t.Errorf("the profile title, docs/stig.md and the page disagree about %s, %d and %d", stigVersion, stigControls, len(prof.Controls)) + } // The page names what it does not cover, and the numbers it states are the profile's. if !strings.Contains(got, "not a complete STIG assessment") || !strings.Contains(got, "package = chrony") || strings.Contains(got, "vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires.", len(p.Controls)), + lead: fmt.Sprintf("These are %d of the %d controls of the DISA Security Technical Implementation Guide for Canonical Ubuntu 22.04 LTS (%s) that vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires. On a host that is not Ubuntu 22.04 every control is not applicable.", len(p.Controls), stigControls, stigVersion), cmd: "curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh\nsudo vmsctl scan --profile stig-ubuntu2204", hint: "Every result carries its evidence (the value, the file and the line); vmsctl explain UBTU-22-255040 prints a control in the terminal. What the profile covers: docs/stig.md. About the tool: vmsctl.", tocLabel: "Controls", why: "Why it matters.", fix: "How to fix it.", human: "A person decides.", importance: "Importance", handOnly: "This control has no automatic check: a person reviews it.", params: "Values used for this control", @@ -90,7 +96,7 @@ func renderProfilePage(content *engine.Content, p *engine.Profile, t pageText) ( w("\n\n\n", t.locale) w("\n\n\n", html.EscapeString(t.title), html.EscapeString(t.desc), t.url) w("\n\n\n", t.cssPath) - w("
\n
\n vmsctl\n \n
\n
\n", t.home, t.home, t.homeLabel) + w("
\n
\n vmsctl\n \n
\n
\n", t.home, t.home, t.homeLabel) w("
\n
\n") w("

%s

\n", html.EscapeString(t.h1)) w("

%s

\n", t.lead) diff --git a/profiles/stig-ubuntu2204.yaml b/profiles/stig-ubuntu2204.yaml index f375791..0fb1cef 100644 --- a/profiles/stig-ubuntu2204.yaml +++ b/profiles/stig-ubuntu2204.yaml @@ -8,6 +8,7 @@ # it is not a complete STIG assessment. See docs/stig.md. id: stig-ubuntu2204 revision: 1 +os: [ubuntu-22.04] title: Canonical Ubuntu 22.04 LTS STIG (V2R8), the controls vmsctl checks title_ko: Canonical Ubuntu 22.04 LTS STIG(V2R8) 중 vmsctl이 점검하는 항목 controls: diff --git a/rules/accounts/password-max-age.yaml b/rules/accounts/password-max-age.yaml index 8dbdec0..46a6b0a 100644 --- a/rules/accounts/password-max-age.yaml +++ b/rules/accounts/password-max-age.yaml @@ -12,9 +12,12 @@ description_ko: >- rationale: A password that never changes stays useful to whoever obtained it. rationale_ko: >- 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다. -remediation: Set `PASS_MAX_DAYS 90` (or less) in /etc/login.defs; apply it to existing accounts with chage. +remediation: >- + Set `PASS_MAX_DAYS` in /etc/login.defs to the required number of days (90 or less by default; a stricter profile or + configuration asks for fewer, such as 60); apply it to existing accounts with chage. remediation_ko: >- - /etc/login.defs에 `PASS_MAX_DAYS 90`(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요. + /etc/login.defs의 `PASS_MAX_DAYS`를 요구하는 일수로 설정하고(기본값은 90일 이하이며, 더 엄격한 프로파일이나 설정은 60일처럼 더 짧게 + 요구합니다), 이미 있는 계정에는 chage로 적용하세요. params: max_days: {type: int, default: 90, stricter: lower, description: Maximum password age in days} setting: diff --git a/rules/accounts/password-min-length.yaml b/rules/accounts/password-min-length.yaml index a11665b..2a89952 100644 --- a/rules/accounts/password-min-length.yaml +++ b/rules/accounts/password-min-length.yaml @@ -16,11 +16,12 @@ rationale_ko: >- 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다. remediation: >- Enable pam_pwquality in the password stack (authselect, pam-auth-update), set - `minlen = 8` or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or - positive credits. + `minlen` in /etc/security/pwquality.conf to the required length (8 or more by default; a stricter profile or configuration + asks for more, such as 15), and do not set enforcing = 0 or positive credits. remediation_ko: >- - password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 - `minlen = 8` 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요. + password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf의 + `minlen`을 요구하는 길이로 설정하세요(기본값은 8 이상이며, 더 엄격한 프로파일이나 설정은 15처럼 더 길게 요구합니다). enforcing = 0이나 양수 크레딧은 + 설정하지 마세요. params: min_length: {type: int, default: 8, stricter: higher, description: Minimum password length} expect: >- diff --git a/rules/accounts/root-locked.yaml b/rules/accounts/root-locked.yaml index 73509a7..17ab760 100644 --- a/rules/accounts/root-locked.yaml +++ b/rules/accounts/root-locked.yaml @@ -20,10 +20,12 @@ remediation_ko: >- violations: over: shadow.entries as: e - where: e.name == "root" && e.state != "locked" + # root with a password that can log in; and, once, when /etc/shadow has no root entry at all (what is not there is not locked) + where: >- + e.name == "root" ? e.state != "locked" : (!shadow.entries.exists(x, x.name == "root") && e.name == shadow.entries[0].name) key: e.name text: >- - e.name + " has a password that can log in (" + e.state + ")" + e.name == "root" ? "root has a password that can log in (" + e.state + ")" : "/etc/shadow has no entry for root" tests: - name: root is locked facts: @@ -37,6 +39,10 @@ tests: facts: shadow: {present: true, entries: [{name: root, state: empty, algorithm: ""}]} want: FAIL + - name: /etc/shadow has no root entry + facts: + shadow: {present: true, entries: [{name: alice, state: set, algorithm: sha512}, {name: bob, state: locked, algorithm: ""}]} + want: FAIL - name: no shadow file input: absent facts: diff --git a/rules/accounts/session-timeout-value.yaml b/rules/accounts/session-timeout-value.yaml index 24cc7a9..91bdb1d 100644 --- a/rules/accounts/session-timeout-value.yaml +++ b/rules/accounts/session-timeout-value.yaml @@ -12,9 +12,12 @@ description_ko: >- rationale: A long or disabled timeout leaves idle sessions open. rationale_ko: >- 제한 시간이 길거나 꺼져 있으면 유휴 세션이 열린 채 남습니다. -remediation: Set `TMOUT=600` (or less) and remove larger assignments and unset commands. +remediation: >- + Set `TMOUT` to the required number of seconds (600 or less by default; a stricter profile or configuration asks for + fewer) and remove larger assignments and unset commands. remediation_ko: >- - `TMOUT=600`(또는 그보다 짧은 값)을 설정하고, 더 큰 값의 대입과 unset 명령은 지우세요. + `TMOUT`을 요구하는 초 단위 값으로 설정하고(기본값은 600초 이하이며, 더 엄격한 프로파일이나 설정은 더 짧게 요구합니다), 더 큰 값의 대입과 unset 명령은 + 지우세요. params: max_seconds: {type: int, default: 600, stricter: lower, description: Longest acceptable idle timeout in seconds} violations: diff --git a/rules/packages/installed.yaml b/rules/packages/installed.yaml index c563c7a..6009f92 100644 --- a/rules/packages/installed.yaml +++ b/rules/packages/installed.yaml @@ -5,10 +5,10 @@ title_ko: 점검 항목이 요구하는 패키지가 설치되어 있음 severity: medium description: >- Checks that the package named by the parameter `package` is installed (dpkg or rpm). The profile that uses this check says which - package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter. + package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter. description_ko: >- 매개변수 `package`가 가리키는 패키지가 설치되어 있는지 확인합니다(dpkg나 rpm). 어느 패키지인지는 이 점검을 쓰는 프로파일이 - 정합니다. 제거했지만 설정 파일이 남은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. + 정합니다. 제거했지만 설정 파일이 남은 패키지나, 풀기만 했거나 설정이 끝나지 않은 패키지는 설치된 것으로 보지 않습니다. 매개변수는 프로파일만 정합니다. rationale: >- A control that needs a security tool or a service on the host cannot be met without its package. rationale_ko: >- @@ -24,13 +24,18 @@ params: failure: >- The package named by the profile is not installed. expect: >- - params.package in packages.installed + params.package in packages.installed && packages.installed[params.package][0].state == "installed" tests: - name: installed params: {package: chrony} facts: packages: {manager: dpkg, installed: {chrony: [{version: "4.2-2ubuntu2", arch: amd64, state: installed}]}} want: PASS + - name: unpacked or half configured is not installed + params: {package: chrony} + facts: + packages: {manager: dpkg, installed: {chrony: [{version: "4.2-2ubuntu2", arch: amd64, state: half-configured}]}} + want: FAIL - name: not installed params: {package: chrony} facts: diff --git a/site/ko/kisa/index.html b/site/ko/kisa/index.html index daaa77c..520da41 100644 --- a/site/ko/kisa/index.html +++ b/site/ko/kisa/index.html @@ -22,7 +22,7 @@ vmsctl @@ -134,7 +134,7 @@

U-02 비밀번호 정책

accounts.password-min-length 비밀번호에 최소 길이가 있음

passwd 서비스의 PAM 스택이 경고만 하는 모드가 아닌 상태로 비밀번호 품질 검사(pam_pwquality 또는 pam_cracklib)를 하고, 최소 길이를 min_length자 이상으로 요구하는지 확인합니다. 양수 크레딧은 합계만큼 비밀번호를 더 짧게 만들 수 있으므로 minlen에서 뺍니다.

왜 중요한가. 짧은 비밀번호는 추측과 오프라인 크래킹에 금방 무너집니다.

-

조치 방법. password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf에 minlen = 8 이상을 설정하세요. enforcing = 0이나 양수 크레딧은 설정하지 마세요.

+

조치 방법. password 스택에서 pam_pwquality를 켜고(authselect, pam-auth-update), /etc/security/pwquality.conf의 minlen을 요구하는 길이로 설정하세요(기본값은 8 이상이며, 더 엄격한 프로파일이나 설정은 15처럼 더 길게 요구합니다). enforcing = 0이나 양수 크레딧은 설정하지 마세요.

accounts.password-complexity 비밀번호에 영문자·숫자·특수문자를 섞어 씀

@@ -152,7 +152,7 @@

accounts.password-quality-root 비밀번호 품질 검사가 ro

accounts.password-max-age 비밀번호가 만료됨

/etc/login.defs의 PASS_MAX_DAYS, 즉 새 계정에 주는 비밀번호 최대 사용 기간을 확인합니다. 이 값이 없으면 shadow-utils는 -1을 쓰는데, 비밀번호가 만료되지 않는다는 뜻입니다.

왜 중요한가. 바뀌지 않는 비밀번호는 그것을 알아낸 사람에게 계속 쓸모가 있습니다.

-

조치 방법. /etc/login.defs에 PASS_MAX_DAYS 90(또는 그보다 작은 값)을 설정하고, 이미 있는 계정에는 chage로 적용하세요.

+

조치 방법. /etc/login.defs의 PASS_MAX_DAYS를 요구하는 일수로 설정하고(기본값은 90일 이하이며, 더 엄격한 프로파일이나 설정은 60일처럼 더 짧게 요구합니다), 이미 있는 계정에는 chage로 적용하세요.

accounts.password-max-age-existing 기존 계정의 비밀번호가 만료됨

@@ -285,7 +285,7 @@

accounts.session-timeout-set 유휴 셸이 자동으로 끝남<

accounts.session-timeout-value 유휴 시간 제한이 충분히 짧음

비어 있거나 0이거나 max_seconds보다 긴 TMOUT 대입과, TMOUT을 unset하는 명령을 나열합니다. 일부 세션에만 적용될 수 있는 if나 case 블록 안의 것도 포함합니다.

왜 중요한가. 제한 시간이 길거나 꺼져 있으면 유휴 세션이 열린 채 남습니다.

-

조치 방법. TMOUT=600(또는 그보다 짧은 값)을 설정하고, 더 큰 값의 대입과 unset 명령은 지우세요.

+

조치 방법. TMOUT을 요구하는 초 단위 값으로 설정하고(기본값은 600초 이하이며, 더 엄격한 프로파일이나 설정은 더 짧게 요구합니다), 더 큰 값의 대입과 unset 명령은 지우세요.

diff --git a/site/stig/ubuntu2204/index.html b/site/stig/ubuntu2204/index.html index 3967f22..d0e1f9a 100644 --- a/site/stig/ubuntu2204/index.html +++ b/site/stig/ubuntu2204/index.html @@ -22,14 +22,14 @@ vmsctl

Ubuntu 22.04 STIG: the 27 controls vmsctl checks

-

These are 27 of the 188 controls of the DISA Security Technical Implementation Guide for Canonical Ubuntu 22.04 LTS (V2R8) that vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires.

+

These are 27 of the 188 controls of the DISA Security Technical Implementation Guide for Canonical Ubuntu 22.04 LTS (V2R8) that vmsctl can decide by reading the host, each with what it looks at, why it matters and how to fix it. This is not a complete STIG assessment: the other controls (audit rules, file ownership of system commands, smart cards, FIPS, the boot loader password, ...) are not checked yet. The control IDs and importance are the STIG's, a US government work; the titles and texts are vmsctl's own. A check is mapped only when it decides exactly what the STIG requires. On a host that is not Ubuntu 22.04 every control is not applicable.

curl -fsSL https://raw.githubusercontent.com/with-developer/vmsctl/main/install.sh | sh
 sudo vmsctl scan --profile stig-ubuntu2204

Every result carries its evidence (the value, the file and the line); vmsctl explain UBTU-22-255040 prints a control in the terminal. What the profile covers: docs/stig.md. About the tool: vmsctl.

@@ -100,7 +100,7 @@

UBTU-22-215010 The password quality library is inst

Importance medium (CAT II)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = libpam-pwquality

@@ -111,7 +111,7 @@

UBTU-22-215015 chrony is installed

Importance low (CAT III)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = chrony

@@ -177,7 +177,7 @@

UBTU-22-251010 ufw is installed

Importance medium (CAT II)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = ufw

@@ -219,7 +219,7 @@

UBTU-22-255010 The SSH server is installed

Importance high (CAT I)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = openssh-server

@@ -300,7 +300,7 @@

UBTU-22-411030 A password expires after 60 days

accounts.password-max-age Passwords expire

Checks PASS_MAX_DAYS in /etc/login.defs, the maximum password age given to new accounts. Without it, shadow-utils uses -1, which means passwords never expire.

Why it matters. A password that never changes stays useful to whoever obtained it.

-

How to fix it. Set PASS_MAX_DAYS 90 (or less) in /etc/login.defs; apply it to existing accounts with chage.

+

How to fix it. Set PASS_MAX_DAYS in /etc/login.defs to the required number of days (90 or less by default; a stricter profile or configuration asks for fewer, such as 60); apply it to existing accounts with chage.

Values used for this control: max_days = 60

@@ -317,7 +317,7 @@

accounts.session-timeout-set Idle shells time out

accounts.session-timeout-value The idle timeout is short enough

Lists TMOUT assignments that are empty, zero or longer than max_seconds, and unset TMOUT commands, including those inside if or case blocks, which can apply to some sessions.

Why it matters. A long or disabled timeout leaves idle sessions open.

-

How to fix it. Set TMOUT=600 (or less) and remove larger assignments and unset commands.

+

How to fix it. Set TMOUT to the required number of seconds (600 or less by default; a stricter profile or configuration asks for fewer) and remove larger assignments and unset commands.

Values used for this control: max_seconds = 900

@@ -326,7 +326,7 @@

UBTU-22-431010 AppArmor is installed

Importance medium (CAT II)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = apparmor

@@ -339,7 +339,7 @@

UBTU-22-611035 A password has at least 15 character

accounts.password-min-length Passwords have a minimum length

Checks that the passwd service's PAM stack enforces password quality (pam_pwquality or pam_cracklib, not in warning-only mode) with a minimum length of at least min_length characters. Positive credits let a password be shorter by up to their sum, so they count against minlen.

Why it matters. Short passwords fall quickly to guessing and offline cracking.

-

How to fix it. Enable pam_pwquality in the password stack (authselect, pam-auth-update), set minlen = 8 or more in /etc/security/pwquality.conf, and do not set enforcing = 0 or positive credits.

+

How to fix it. Enable pam_pwquality in the password stack (authselect, pam-auth-update), set minlen in /etc/security/pwquality.conf to the required length (8 or more by default; a stricter profile or configuration asks for more, such as 15), and do not set enforcing = 0 or positive credits.

Values used for this control: min_length = 15

@@ -358,7 +358,7 @@

UBTU-22-653010 The audit daemon is installed

Importance medium (CAT II)

packages.installed A package that the control requires is installed

-

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files is not installed. Only a profile sets the parameter.

+

Checks that the package named by the parameter package is installed (dpkg or rpm). The profile that uses this check says which package; a package that was removed but left its configuration files, or that is only unpacked or half configured, is not installed. Only a profile sets the parameter.

Why it matters. A control that needs a security tool or a service on the host cannot be met without its package.

How to fix it. Install the package with the package manager (for example apt install <package>).

Values used for this control: package = auditd

From a20ecd9c4b88438687d9cc1c6b016eebbd10b534 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:18:41 +0900 Subject: [PATCH 5/6] docs: markers --- README.ko.md | 2 +- docs/README.ko.md | 2 +- docs/stig.ko.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.ko.md b/README.ko.md index 3341592..aea92e1 100644 --- a/README.ko.md +++ b/README.ko.md @@ -1,4 +1,4 @@ - + # vmsctl [![CI](https://github.com/with-developer/vmsctl/actions/workflows/ci.yml/badge.svg)](https://github.com/with-developer/vmsctl/actions/workflows/ci.yml) diff --git a/docs/README.ko.md b/docs/README.ko.md index d0f40a4..eac7541 100644 --- a/docs/README.ko.md +++ b/docs/README.ko.md @@ -1,4 +1,4 @@ - + # vmsctl 문서 [English](README.md) diff --git a/docs/stig.ko.md b/docs/stig.ko.md index 0fdfa88..f40c593 100644 --- a/docs/stig.ko.md +++ b/docs/stig.ko.md @@ -1,4 +1,4 @@ - + # DISA STIG 프로파일 (Ubuntu 22.04) `stig-ubuntu2204`는 미 국방부가 DISA를 통해 공개하는 From ff8e0dac4e04e8f2a05456e0d34a4a207e37e34f Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 14 Nov 2026 18:22:56 +0900 Subject: [PATCH 6/6] fix: gofmt --- internal/rulesdoc/rulesdoc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rulesdoc/rulesdoc_test.go b/internal/rulesdoc/rulesdoc_test.go index 1349bba..c6e6761 100644 --- a/internal/rulesdoc/rulesdoc_test.go +++ b/internal/rulesdoc/rulesdoc_test.go @@ -1,8 +1,8 @@ package rulesdoc import ( - "fmt" "flag" + "fmt" "os" "path/filepath" "strings"