> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/di-27-zhang-an-quan/di-27.1-jie-xin-xi-an-quan-gai-lun.md).

# 27.1 信息安全概论

信息安全指信息系统（包括硬件、软件、数据、人、物理环境及其基础设施等）受到保护，使其免受偶然或恶意因素的破坏、更改与泄露，信息的机密性、完整性和可用性得到保证，系统可靠、正常地运行，信息服务连续不中断。

安全是全体用户的共同责任。任何系统中的弱点都可能使入侵者获取关键信息并对整个网络造成破坏。信息安全的核心原则之一是 CIA 三要素，即信息系统的机密性（Confidentiality）、完整性（Integrity）和可用性（Availability）。CIA 三要素的概念可追溯至 20 世纪 70 年代中后期的计算机安全研究，后由美国国家标准与技术研究院（National Institute of Standards and Technology, NIST）在其安全标准框架中正式采纳与推广。

```sh
信息安全 CIA 三要素：

  信息安全核心目标
     │
     │  保障三大属性
     ▼
  机密性（Confidentiality，C）
     仅授权方可访问
     示例：信用卡信息加密存储
     │
     ▼
  完整性（Integrity，I）
     数据未被未授权篡改
     示例：订单未被篡改
     │
     ▼
  可用性（Availability，A）
     授权方可随时访问
     示例：可随时查询订单状态
```

客户和用户期望其数据得到保护，因此 CIA 三要素是计算机安全的基石。例如，客户期望其信用卡信息得到安全存储（机密性），其订单不会被未经授权篡改（完整性），并且其可随时访问订单信息（可用性）。

为保障 CIA 安全，安全专家采用纵深防御（Defense in Depth）策略。该策略的理念是在多个层面实施安全措施，防止单一层面的安全失效导致整体防御体系崩溃。例如，系统管理员不能仅启用防火墙便认为网络或系统是安全的，还必须审计账户、检查二进制文件的完整性，并确保系统中未安装恶意工具。要实施有效的安全策略，必须了解潜在威胁及其防御方法。

```sh
纵深防御（Defense in Depth）多层防护：

  外层防护
     │
     │  防火墙（ipfw/pf/ipf）
     │  网络入侵检测（IDS）
     ▼
  主机防护
     │
     │  账户认证安全（强密码、PAM）
     │  安全等级（securelevel）
     │  MAC 强制访问控制
     ▼
  应用防护
     │
     │  权限最小化（Capsicum）
     │  W^X、ASLR、PIE 缓解措施
     ▼
  数据防护
     │
     │  文件完整性校验（mtree）
     │  全盘加密（GEOM）
     │  安全事件审计（auditd）
     ▼
  任何单层失效，其余层仍提供保护
```

计算机安全中的威胁不仅包括远程攻击者试图进行未经授权的系统访问，还涵盖内部人员、恶意软件、未经授权的网络设备、自然灾害、安全漏洞，甚至来自竞争对手的威胁。

系统和网络可能遭到未授权访问，此类访问可能是意外发生，也可能由远程攻击者实施，甚至源于企业间谍活动或前员工。用户应在安全事件发生时做好应急响应准备，如实通报情况，同时将相关事件报告给安全团队。作为管理员，了解威胁并做好应对准备同样重要。

> **技巧**
>
> 当前已有数百种关于系统与网络安全防护的标准实践。问题不在于应当遵循哪种最佳实践、行业标准或法律要求，而在于应始终秉持以下信念：“世界上没有绝对安全的操作系统”。另见 2014 年德国电影 [*Who Am I – Kein System ist sicher*](https://www.imdb.com/title/tt3042408/) 即《[我是谁：没有绝对安全的系统](https://movie.douban.com/subject/25932086/)》。

作为 FreeBSD 用户，理解如何防范攻击与入侵至关重要。

FreeBSD 操作系统内置安全事件审计支持。事件审计支持可靠、细粒度且可配置的日志记录，涵盖了各种安全相关的系统事件，包括登录、配置更改以及文件和网络访问。这些日志记录在实时系统监控、入侵检测和事后分析中极具价值。

FreeBSD 支持基于 POSIX®.1e 草案的安全扩展。这些安全机制包括文件系统访问控制列表（Access Control Lists, ACL）和强制访问控制（MAC）。MAC 允许加载访问控制模块以实施安全策略。一些模块为系统的狭窄子集提供保护，强化特定服务，而另一些则提供跨所有主体和对象的全面标签安全。强制性部分的定义意味着控制的执行由管理员和操作系统共同完成。这与默认的安全机制——自主访问控制（DAC）形成对比，后者将控制权交由用户自主决定。

## FreeBSD 的安全设计

* Leidinger 博客：Leidinger, A. FreeBSD Security Hardening with Compiler Options\[EB/OL]. (2025-05-24)\[2026-03-26]. <https://www.leidinger.net/blog/2025/05/24/freebsd-security-hardening-with-compiler-options/>. FreeBSD 项目已对部分 Port 实施加固。另见 Bug 284270：FreeBSD Project. Bug 284270 - Add new features fortify, stack\_autoinit and zeroregs\[EB/OL]. \[2026-03-26]. <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284270>.
* 披露的安全漏洞少于其他主流操作系统（尽管可能存在样本数量较少的客观因素）。截至 2025 年 9 月，FreeBSD 基本系统（用户空间与内核）的 CVE 漏洞数量约为 Linux 内核的二十分之一（根据 CVEdetails.com. CVE security vulnerability database. Security vulnerabilities, exploits, references and more\[EB/OL]. \[2026-03-26]. <https://www.cvedetails.com/>. 统计），而 Linux 内核的 CVE 数量远超 Windows（二者并非同一维度：Linux 内核仅为内核，而 Windows 通常指全部组件）。同期，OpenBSD 的 CVE 漏洞数量约为 FreeBSD 的 40%，不同项目的 CVE 分配政策和报告文化存在显著差异，CVE 数量不能直接等同于安全性的绝对比较。
* 可避免在产品和架构中出现单点故障，提升系统整体可用性与韧性。
* 安全事件审计。
* Robert Watson, Stacey Son. TrustedBSD - FreeBSD Wiki\[EB/OL]. (2022-09-15)\[2026-03-26]. <https://wiki.freebsd.org/TrustedBSD/>. FreeBSD 集成了标准 UNIX DAC、ACL、TrustedBSD MAC 安全框架（基于 POSIX®.1e 草案的安全扩展）
* 集成 W^X 策略，参见 D28050 代码审查：kib. Implement enforcing write XOR execute mapping policy\[EB/OL]. (2021-01-08)\[2026-03-26]. <https://reviews.freebsd.org/D28050>.
* 默认启用了内核和用户空间的 PIE 和 ASLR。ASLR 最初由 D27666 代码审查提出（2020-12-18），PIE 默认启用由 D28328 实现，二者合并至 HEAD 后，自 FreeBSD 13.2-RELEASE（2023 年 4 月 11 日）起 ASLR 对 64 位可执行文件默认启用。参见 D27666 代码审查:mw. Enable ASLR by default for 64-bit executables\[EB/OL]. (2020-12-18)\[2026-04-17]. <https://reviews.freebsd.org/D27666> 、D28328 代码审查:mw. Enable PIE by default on 64-bit architectures\[EB/OL]. \[2026-04-17]. <https://reviews.freebsd.org/D28328>; FreeBSD 13.2-RELEASE 公告:FreeBSD Project. FreeBSD 13.2-RELEASE Announcement\[EB/OL]. (2023-04-11)\[2026-04-17]. <https://www.freebsd.org/releases/13.2R/announce/>.
* FreeBSD 完成了 National Institute of Standards and Technology（NIST，美国国家标准及技术研究所）安全软件开发框架（SSDF）自我证明（Attestation），参见 FreeBSD 基金会 SSDF 证明新闻：FreeBSD Foundation. FreeBSD Foundation Announces SSDF Attestation\[EB/OL]. (2023-11-03)\[2026-03-26]. <https://freebsdfoundation.org/news-and-events/latest-news/freebsd-foundation-announces-ssdf-attestation/>.
* 发布了 FreeBSD 14 CIS 基准。参见 FreeBSD 基金会 CIS 基准博客：FreeBSD Foundation. New CIS® FreeBSD 14 Benchmark: Secure Your Systems with Expert-Guided Best Practices\[EB/OL]. (2024-08-19)\[2026-03-26]. <https://freebsdfoundation.org/blog/new-cis-freebsd-14-benchmark-secure-your-systems-with-expert-guided-best-practices/>.
* 正在实现 FreeBSD 的零信任构建，参见 Sovereign Tech Agency 相关赞助。
* 基于 GEOM 框架的全盘加密（含 ZFS、swap）方案。
* 正在改进软件物料清单（Software Bill of Materials，SBOM），参见 Sovereign Tech Agency 相关赞助。
* Capsicum 框架，并且已经对基本系统中大量工具进行了能力化加固。参见 Capsicum Wiki：FreeBSD Project. Capsicum - FreeBSD Wiki\[EB/OL]. \[2026-03-26]. <https://wiki.freebsd.org/Capsicum>.
* FreeBSD 内核拥有五种不同的安全级别（securelevel）可以自由选择，参见 security 手册页：FreeBSD Project. security - introduction to security under FreeBSD\[EB/OL]. \[2026-03-26]. <https://man.freebsd.org/cgi/man.cgi?query=security&sektion=7>. 另见 mitigations 手册页：FreeBSD Project. mitigations - FreeBSD Security Vulnerability Mitigations\[EB/OL]. \[2026-03-26]. <https://man.freebsd.org/cgi/man.cgi?query=mitigations&sektion=7>. 手册页还介绍了 FreeBSD 上若干安全漏洞缓解手段。

## 课后习题

1. 试分析人们往往对“官方网站”分发的软件持有天然信任感的原因（例如“只从官方网站下载软件”这一流行说法），并评述此种信任是否正确可靠。（参见 DMkiIIer. Warning: HWMonitor 1.63 download on the official site may contain malware? \[EB/OL]. r/pcmasterrace, Reddit, (2026-04-10)\[2026-04-11]. <https://www.reddit.com/r/pcmasterrace/comments/1sh4e5l/warning_hwmonitor_163_download_on_the_official/>.）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/di-27-zhang-an-quan/di-27.1-jie-xin-xi-an-quan-gai-lun.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
