Product SiteDocumentation Site

第 12 章 常见问题解答 (FAQ)

12.1. Debian 操作系统的安全
12.1.1. Debian 比 X 更安全吗?
12.1.2. 我的系统存在漏洞!(您确认吗?)
12.2. 特定软件
12.2.1. proftpd is vulnerable to a Denial of Service attack.
12.2.2. After installing portsentry, there are a lot of ports open.
12.3. 有关 Debian 安全小组的问题
本章介绍源自 Debian 安全邮件列表中的一些常见问题, 当您准备发送邮件, 甚至别人告诉您去 RTFM 时, 您可以阅读它们.

12.1. Debian 操作系统的安全

12.1.1. Debian 比 X 更安全吗?

A system is only as secure as its administrator is capable of making it. Debian's default installation of services aims to be secure, but may not be as paranoid as some other operating systems which install all services disabled by default. In any case, the system administrator needs to adapt the security of the system to the local security policy.
For a collection of data regarding security vulnerabilities for many operating systems, see the http://www.cert.org/stats/cert_stats.html or generate stats using the http://nvd.nist.gov/statistics.cfm (formerly ICAT) Is this data useful? There are several factors to consider when interpreting the data, and it is worth noticing that the data cannot be used to compare the vulnerabilities of one operating system versus another.[72] Also, keep in mind that some reported vulnerabilities regarding Debian apply only to the unstable (i.e. unreleased) branch.

12.1.1.1. Is Debian more secure than other Linux distributions (such as Red Hat, SuSE...)?

There are not really many differences between Linux distributions, with exceptions to the base installation and package management system. Most distributions share many of the same applications, with differences mainly in the versions of these applications that are shipped with the distribution's stable release. For example, the kernel, Bind, Apache, OpenSSH, Xorg, gcc, zlib, etc. are all common across Linux distributions.
For example, Red Hat was unlucky and shipped when foo 1.2.3 was current, which was then later found to have a security hole. Debian, on the other hand, was lucky enough to ship foo 1.2.4, which incorporated the bug fix. That was the case in the big http://www.cert.org/advisories/CA-2000-17.html problem from a couple years ago.
There is a lot of collaboration between the respective security teams for the major Linux distributions. Known security updates are rarely, if ever, left unfixed by a distribution vendor. Knowledge of a security vulnerability is never kept from another distribution vendor, as fixes are usually coordinated upstream, or by http://www.cert.org. As a result, necessary security updates are usually released at the same time, and the relative security of the different distributions is very similar.
Debian 在安全方面主要的优势在于系统通过 apt 完成升级非常简单. Debian 在安全方面还有以下方面值得考虑:

12.1.1.2. 在 Bugtraq 中有很多 Debian bug. 这是否意味着它很脆弱吗?

Debian 发行版号称拥有最多的软件包, 可能比任何一个操纵系统都多. 安装的软件包越多, 潜在的安全问题就越大.
越来越多的人测试原代码的缺陷. 在 Debian 中许多公告与主要软件组件的源码审计有关. 每当诸如此类的源码审计出现漏洞, 它们将会被修复, 并向如 Bugtraq 的列表发送一个公告.
通常在 Debian 中发现的 bug 同样会影响到其它发行版和开发商. 检查每个公告 (DSA) 顶端的 "Debian specific: yes/no" 部分.

12.1.1.3. Debian 有与安全相关的证书吗?

简短的回答: 没有.
Long answer: certification costs money (specially a serious security certification), nobody has dedicated the resources in order to certify Debian GNU/Linux to any level of, for example, the http://niap.nist.gov/cc-scheme/st/. If you are interested in having a security-certified GNU/Linux distribution, try to provide the resources needed to make it possible.
There are currently at least two linux distributions certified at different http://en.wikipedia.org/wiki/Evaluation_Assurance_Level levels. Notice that some of the CC tests are being integrated into the http://ltp.sourceforge.net which is available in Debian in the ltp.

12.1.1.4. 有针对 Debian 的安全化程序吗?

Yes. http://bastille-linux.sourceforge.net/, originally oriented toward other Linux distributions (Red Hat and Mandrake), it currently works also for Debian. Steps are being taken to integrate the changes made to the upstream version into the Debian package, named bastille.
但是, 有些人认为一个安全设置工具并不能满足一个好的管理员的需求.

12.1.1.5. 我想要运行 XYZ 服务, 应当选择哪个?

Debian 的一个强大之处在于对于相同功能( DNS 服务器, 邮件服务器, ftp服务器, web 服务器, 等等) 有很多软件包可供选择. 对于新管理员确定哪个软件包更适合来说很容易被搞糊涂. 对于给定条件的最好的选择是基于您的特点与安全需求之间的平衡. 当您在相似的软件包之间作选择时, 应当问自己这么几个问题:
  • 上游仍在维护这个软件吗? 什么时候发行的最新版?
  • 软件包成熟吗? 版本号并不能告诉您它的成熟度. 设法查看软件的开发历史.
  • 软件 bug-ridden 吗? 有与其相关的安全公告吗?
  • 软件是否提供您所需要的所有功能? 是否多于您的真正需求?

12.1.1.6. 在 Debian 中如何使 XYZ 服务更安全?

在本文档中您会找到一些在 Debian GNU/Linux 中使一些服务(FTP,Bind)更安全的方法. 这里所没有提供的, 您可以查看程序的文档, 或常用的 Linux 信息. 大多数的用于 Unix 系统的安全指南同样适用于 Debian. 很多情况下, Debian 中服务 X 的安全设置于在其它 Linu x发行版相同行(或 Un*x ,就此而言).

12.1.1.7. 如何删除服务的所有标语?

If you do not like users connecting to your POP3 daemon, for example, and retrieving information about your system, you might want to remove (or change) the banner the service shows to users. [74] Doing so depends on the software you are running for a given service. For example, in postfix, you can set your SMTP banner in /etc/postfix/main.cf:
 
  smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
Other software is not as easy to change. ssh will need to be recompiled in order to change the version that it prints. Take care not to remove the first part (SSH-2.0) of the banner, which clients use to identify which protocol(s) is supported by your package.

12.1.1.8. 所有的 Debian 软件包都安全吗?

Debian 安全小组不可能分析 Debian 中所有的软件包的潜在漏洞, 因为没有足够的资金用于整个项目的源代码的安全审计. 但是, Debian 可受益于上游开发者.
实际上,Debian 开发者可能发布一个含有木马的软件包, 并且无法将其检查出来. 即使将其引入 Debian 的一个分支, 也不可能报告出木马可能运行的所有可能的状况. 这就是为什么 Debian 含有"无保证"条件许可的原因.
但是,Debian 用户事实上应当对有广泛用户的稳定版本有足够的信心, 其多数问题可以通过使用被发现. 对于一个重要的系统并不推荐安装未经测试的软件(如果无法提供必要的代码审计). 无论如何, 如果含有安全漏洞的软件被引入发行版, 通过包含软件包确认的使用过程, 这种问题最终可能将追踪到开发者. Debian 项目不轻易采取了这种方法.

12.1.1.9. 为什么一些日志文件/配置文件设为完全可读(world-readable), 这样不是不安全吗?

当然,您可以修改系统的缺省 Debian 许可. 当前关于日志文件和配置文件的策略是完全可读(world readable), 除非它们提供的是高度机密的信息.
如果您作修改,那么就要小心:
  • 进程也许不能写入日志, 如果您限制了它们的权限.
  • 一些软件可能不能工作了, 如果它们依靠的配置文件不可读. 例如, 如果您移除了 /etc/samba/smb.conf 的完全可读权限, 普通用户将无法运行 smbclient 程序.
FIXME: 检查策略里的写权限部分. 一些软件包(即, ftp 守护进程)似乎强制执行不同的权限.

12.1.1.10. 为什么 /root/(或 UserX)的权限是755?

实际上,其他用户存在同样的问题. 因为 Debian 的安装不在这个目录下放置任何文件, 那里没有任何需要保护的机密信息. 对于您的系统来说, 如果您觉得权限过于宽松, 可以考虑设为750. 对于其他用户,参阅 第 4.11.19.1 节 “限制用户对于其他用户信息的访问”.
This Debian security mailing list http://lists.debian.org/debian-devel/2000/debian-devel-200011/msg00783.html has more on this issue.

12.1.1.11. 在安装 grsec/防火墙后,我开始接收到许多控制信息! 怎么删除他们?

如果您正在接受控制台信息, 并已经配置了 /etc/syslog.conf 将日志信息转向其他文件或指定 TTY, 那么您可能会看到直接发送到控制台的信息.
任何一个内核的缺省控制台日志级别都为 7, 这意味着任何低优先级信息都会出现在控制台. 通常, 防火墙(日志规则)和一些其它的安全工具的日志优先级较低, 因此, 会被直接发送到控制台.
To reduce messages sent to the console, you can use dmesg (-n option, see dmseg(8)), which examines and controls the kernel ring buffer. To fix this after the next reboot, change /etc/init.d/klogd from:
  KLOGD=""
为:
  KLOGD="-c 4"
如果仍然出现, 为 -c 设置更小的数字. 在 /usr/include/sys/syslog.h 中可以找到关于不同日志级别的描述:
  #define LOG_EMERG       0       /* system is unusable */
  #define LOG_ALERT       1       /* action must be taken immediately */
  #define LOG_CRIT        2       /* critical conditions */
  #define LOG_ERR         3       /* error conditions */
  #define LOG_WARNING     4       /* warning conditions */
  #define LOG_NOTICE      5       /* normal but significant condition */
  #define LOG_INFO        6       /* informational */
  #define LOG_DEBUG       7       /* debug-level messages */

12.1.1.12. 操作系统的用户与组

12.1.1.12.1. 所有系统用户都是必需的吗?
Yes and no. Debian comes with some predefined users (user id (UID) < 99 as described in http://www.debian.org/doc/debian-policy/ or /usr/share/doc/base-passwd/README) to ease the installation of some services that require that they run under an appropriate user/UID. If you do not intend to install new services, you can safely remove those users who do not own any files in your system and do not run any services. In any case, the default behavior is that UID's from 0 to 99 are reserved in Debian, and UID's from 100 to 999 are created by packages on install (and deleted when the package is purged).
To easily find users who don't own any files, execute the following command[75] (run it as root, since a common user might not have enough permissions to go through some sensitive directories):
  cut -f 1 -d : /etc/passwd | \
  while read i; do find / -user "$i" | grep -q . || echo "$i"; done
These users are provided by base-passwd. Look in its documentation for more information on how these users are handled in Debian. The list of default users (with a corresponding group) follows:
  • root: Root 是(典型的) 超级用户.
  • daemon: 一些非特权守护进程运行时需要象 daemon.daemon (如, portmap, atd, 或许还有其它)一样对磁盘文件进行写操作. 守护进程以 nobody.nogroup 运行时不需要拥有任何文件. 更复杂或更安全的守护进程以指定用户运行. daemon 用户也可用于本地安装 daemon.
  • bin: 因为历史的原因被保留下来.
  • sys: 同 bin. 但是,sys 组拥有 /dev/vcs* 和 /var/spool/cups.
  • sync: 用户 sync 的 shell 是 /bin/sync. 因而,如果它的密码被设置对容易事猜测(譬如 "" ) ,任何人都可以通过控制台 sync 系统. 既使他们没有帐户.
  • games: 许多游戏被 SETGID 为 games, 这样就可以对它们的高分值文件进行写操作. 这是策略里边的解释.
  • man: 程序(有时)以用户 man 运行, 这样可以将 cat 的页面写入 /var/cache/man.
  • lp: 由打印机守护进程使用.
  • mail: /var/mail 目录下的信箱由 mail 组拥有, 这是策略中的解释. 用户和组同时也被其它各种各样的 MTA 使用.
  • news: 各种各样的新闻服务器以及其它相关的程序(譬如 suck)以各种各样的方式使用 news 用户和组. 在 news spool 中的文件通常为 news 用户和组拥有. 用于投递新闻的程序,如 inews 就是典型的 SETGID news.
  • uucp: uucp 用户和组由 UUCP 子系统使用. 其拥有 spool 和配置文件. 属于 uucp 组的用户,可以运行 uucico.
  • proxy: 如 daemon, 此用户和组由一些没有指定用户id, 但是需要拥有文件的守护进程(具体的, proxy 守护进程)使用. 例如, proxy 组由 pdnsd 使用, squid 以proxy用户运行.
  • majordom: 在Debian系统中, 因为历史的原因, Majordomo 有一个静态分配的 UID. 新的系统中没有.
  • postgres: Postgresql 数据库由这个用户和组拥有. 因为安全的原因, 目录 /var/lib/postgresql 下的所有文件由此用户拥有.
  • www-data: Some web servers run as www-data. Web content should not be owned by this user, or a compromised web server would be able to rewrite a web site. Data written out by web servers, including log files, will be owned by www-data.
  • backup: 这样, 备份/恢复的任务可以委派没有完全 root 权限的用户.
  • operator: operator 是过去(和现在)唯一可以不依赖于 NIS/NFS 远程登陆而'用户'账号.
  • list: 邮件列表文件和数据由此用户和组拥有. 一些邮件列表程序也是以此用户运行.
  • irc: 由 irc 守护进程使用. 因为 ircd 的一个 bug, 需要分配一个静态用户, 启动时, 它将自身 SETUID() 给一个指定 UID.
  • gnats.
  • nobody, nogroup: 不需要拥有任何文件的守护进程以用户 nobody 和组 nogroup 的方式运行. 因此, 此用户和组在一个系统上不会拥有任何文件.
其它没有相关用户的组:
  • adm: adm 组由系统监控任务使用. 这个组的成员对 /var/log 下的许多日志文件有读权限. 并且可以使用 xconsole. 过去, /var/log 就是 /usr/adm(后来是 /var/adm). 这是这个组名字的由来.
  • tty: TTY 设备由这个组拥有. 这样可以将 write 和 wall 操作传到其它人的 TTY 上.
  • disk: raw 对磁盘的访问, 等同于 root 的访问.
  • kmem: 此组可以读取 /dev/kmem 和类似的文件, 这是BSD的一个主要遗留痕迹, 任何需要直接读去系统内存的程序都需要 SETGID 为 kmem.
  • dialout: 对串口的全部和直接访问. 此组的成员可以对调制解调器, dial anywhere 等进行再配置.
  • dip: 此组的标准名称为"Dial-up IP", 此组的成员允许使用ppp, dip, wvdial, 等一类的工具, 进行拨号连接. 这个组的用户不允许配置调制解调器, 但是可以运行使用它的程序.
  • fax: 允许成员使用fax软件收/发传真.
  • voice: Voicemail, 对于使用调制解调器作为电话答录机的系统非常有用.
  • cdrom: 这个组可以用来在本地分配给用户对 CDROM 的访问权限.
  • floppy: 这个组可以用来在本地分配给用户对软驱的访问权限.
  • tape: 这个组可以用来在本地分配给用户对磁带机的访问权限.
  • sudo: 当使用 sudo 时, 这个组的成员不需要键入密码. 参阅 /usr/share/doc/sudo/OPTIONS.
  • audio: 这个组可以用来在本地分配给用户对 audio 设备的访问权限.
  • src: 这个组拥有源代码,包括 /usr/src 目录下的文件. 可以用来在本地给用户分配管理系统源代码的能力.
  • shadow: 这个组可以读取 /etc/shadow. 需要访问这个文件的一些程序需要 SETGID 为 shadow.
  • utmp: 这个组可以对 /var/run/utmp 和类似的文件进行写操作. 需要对此类文件进行写操作的程序需要 SETGID 为 utmp.
  • video: This group can be used locally to give a set of users access to a video device.
  • staff: 允许用户添加对系统((/usr/local, /home)的本地修改, 而不需要特权. 与 "adm" 组相比, 更 monitoring/security.
  • users: 当 Debian 系统使用默认的私有用户组系统(每个用户都有他们自己的组)时, 有些更愿使用传统的组系统, 所有用户都是此组的一个成员.
12.1.1.12.2. I removed a system user! How can I recover?
If you have removed a system user and have not made a backup of your password and group files you can try recovering from this issue using update-passwd (see update-passwd(8)).
12.1.1.12.3. adm 组和 staff 组之间有什么区别?
'adm' 组的成员通常为管理员, 这个组的权限允许他们不用 su 就能读取日志文件. 'staff' 组则通常为 help-desk/junior sysadmins, 允许成员在 /usr/local 目录下操作, 和在 /home 目录下创建目录.

12.1.1.13. 为什么我创建新用户时, 会同时出现一个新组?(或为什么 Debian 为每个用户创建一个所属组?)

在 Debian 中, 缺省设置为每个用户都有一个私有组. 传统的 UN*X 方案为每个用户指定了用户组. 创建的其它的组用于限制对不同项目目录下的共享文件的访问. 当单个用户操作多个项目时, 如果某个用户创建了一个文件, 文件的管理将变的困难, 它同它所属的主要组联系在一起(如,'users').
Debian 的方案是通过为每个用户指定一个他们自己的组解决了这一问题; 这样可以带有一个合适的 umask(0002)并且对给定项目目录设置了 SETGID 位, 在此目录下创建的文件都被正确的指定了组. 这使得处理多个项目更加简单, 因为不必切换所属的组或 umask.
然而, 您也可以通过修改 /etc/adduser.conf 来改变这一特性. 修改 USERGROUPS 变量为 'no', 这样当创建用户时就不会伴随产生一个新组了. 也可以设置 USERS_GID 为所有用户都属于的组的GID.

12.1.1.14. Questions regarding services and open ports

12.1.1.14.1. 为什么所有的服务安装后都被激活了?
这只是解决问题的一种方法, 既考虑到了安全性, 又兼顾对用户的友好. 除非管理员将其激活, OpenBSD 将禁用所服务. 与此不同除非将其禁用, Debian GNU/Linux 会激活所有安装的服务(更多信息参见 第 3.5.1 节 “禁用守护进程服务”). 在您安装了服务之后, 不是这样吗?
对于标准安装, 哪个是更好的解决方案, 在 Debian 的邮件列表(debian-devel 和 debian-security)上有更多的讨论, 然而, 到目前为止(2002年3月), 仍然没有达成共识.
12.1.1.14.2. 我能删除 inetd 吗?
Inetd is not easy to remove since netbase depends on the package that provides it (netkit-inetd). If you want to remove it, you can either disable it (see 第 3.5.1 节 “禁用守护进程服务”) or remove the package by using the equivs package.
12.1.1.14.3. 为什么我的111端口是打开的?
端口111是 sunrpc 的 portmapper,它是 Debian 的基本安装的默认部分, 因为不必知道何时用户的程序需要 RPC 才能正确运行. 无论如何, 它主要由 NFS 使用. 如果您不需要它, 您可以依照 第 5.13 节 “增强 RPC 服务的安全性” 的说明将其删除.
In versions of the portmap package later than 5-5 you can actually have the portmapper installed but listening only on localhost (by modifying /etc/default/portmap)
12.1.1.14.4. identd(port 113)的主要用途是什么?
Identd 服务是一个认证服务, 用于鉴别某个 TCP/IP 远程服务连接的拥有者的身份. 一个典型的例子, 当用户连接到远程主机, 远程主机上的 inetd 向113端口发回一个查询到, 索取用户信息, 通常由 mail, FTP 和 IRC 服务器使用, 也可用于跟踪您本地系统中的哪个用户试图攻击一个远程系统.
There has been extensive discussion on the security of identd (See http://lists.debian.org/debian-security/2001/debian-security-200108/msg00297.html). In general, identd is more helpful on a multi-user system than on a single user workstation. If you don't have a use for it, disable it, so that you are not leaving a service open to the outside world. If you decide to firewall the identd port, please use a reject policy and not a deny policy, otherwise a connection to a server utilizing identd will hang until a timeout expires (see http://logi.cc/linux/reject_or_deny.php3).
12.1.1.14.5. 使用 1 到 6 端口的是什么服务,如果删除?
运行命令 netstat -an, 您会看到:
  Active Internet connections (servers and established)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State
  PID/Program name
  raw        0      0 0.0.0.0:1               0.0.0.0:*               7
  -
  raw        0      0 0.0.0.0:6               0.0.0.0:*               7
  -
You are not seeing processes listening on TCP/UDP port 1 and 6. In fact, you are seeing a process listening on a raw socket for protocols 1 (ICMP) and 6 (TCP). Such behavior is common to both legitimate software like intrustion detection systems, such as iplogger and portsentry, but some trojans have also been known yo use them. If you have the mentioned packages simply remove them to close the port. If you do not, try netstat's -p (process) option to see which process is running these listeners.
12.1.1.14.6. 我发现端口 XYZ 打开了, 可以将其关闭吗?
是的,当然可以. 您所开放的端口应当遵循您的个人站点关于对其它网络提供公共服务的策略. 检查由 inetd 打开的端口(参见 第 3.5.2 节 “禁用 inetd 服务”), 或由于安装的其它软件包打开的端口, 并采取适当的措施(即,配置 inetd, 删除这个软件包, 避免其启动时运行).
12.1.1.14.7. 从 /etc/services 中删除服务, 是否对我的主机的安全有帮助?
, /etc/services 只是在真实名称和指定端口号之间提供一种映射. 从此文件中删除服务名并不能(通常)阻止运行的服务. /etc/services 修改后一些守护进程可能不能运行了, 但这样做并不规范. 正确的禁用服务的方法, 参见 第 3.5.1 节 “禁用守护进程服务”.

12.1.1.15. 常见安全问题

12.1.1.15.1. 我的密码丢了,无法访问系统了!
您所需要做的恢复步骤与您是否采纳了限制访问 lilo 和系统的 BIOS 的建议有关.
如果您两个都做了限制, 则进行下一步前, 您需要禁用只能从硬盘启动的 BIOS 设定. 如果你连 BIOS 的密码也忘了, 就需要打开机箱, 取下BIOS 的电池, 将 BIOS 的设置复位.
一旦您设定了从 CD-ROM 或软盘启动,尝试以下步骤:
  • 由救援盘启动内核
  • 转到虚拟控制台(Alt+F2)
  • 挂接 /root 所在硬盘分区
  • 编辑(Debian2.2 救援盘提供 ae 编辑器, Debian3.0 提供与 vi 很相似的 nano-tiny)/etc/shadow 并修改:
      root:asdfjl290341274075:XXXX:X:XXXX:X::: (X=any number)
    
    为:
      root::XXXX:X:XXXX:X:::
    
这将删除遗忘的 root 密码, 包含在用户名之后第一个冒号分割的部分. 保存修改, 重起系统, 以 root 使用空密码登录. 记得重新设置密码. 这样就可行了, 除非您更严谨的配置了系统, 即您不允许用户使用空密码登录, 或不允许 root 由控制台登录.
如果使用这些特性, 则您将需要以单用户模式进入. 如果对 LILO 做了限制, 则您需要在 root 重新设置了上述之后再次运行 lilo. 这相当棘手, 因为你的 /etc/lilo.conf 需要根据 root(/)文件系统来调整, 而不是真正的硬盘
一旦没有了 LILO 限制,尝试以下步骤:
  • 在系统 BIOS 完成之前按下 Alt, shift 或 Control 键, 您会得到 LILO 提示符.
  • 在提示符后键入 linux single, linux init=/bin/shlinux 1.
  • 这样您会得到一个单用户模式下的 shell 提示符(将提示键入密码, 但是您已经知道了)
  • 使用 mount 命令, 重新以 read/write 模式挂接 root(/) 分区.
      # mount -o remount,rw /
    
  • 使用 passwd 命令修改超级用户密码(因为您就是超级用户, 所有不会要求您提供原密码).

12.1.1.16. 如何配置不需要分配用户 shell 账号的服务?

For example, if you want to set up a POP service, you don't need to set up a user account for each user accessing it. It's best to set up directory-based authentication through an external service (like Radius, LDAP or an SQL database). Just install the appropriate PAM library (libpam-radius-auth, libpam-ldap, libpam-pgsql or libpam-mysql), read the documentation (for starters, see 第 4.11.1 节 “用户认证: PAM”) and configure the PAM-enabled service to use the back end you have chosen. This is done by editing the files under /etc/pam.d/ for your service and modifying the
 
  auth   required    pam_unix_auth.so shadow nullok use_first_pass
为, 例如, 对于 ldap 来说:
  auth   required    pam_ldap.so
就 LDAP 目录而论,为了使用 LDAP 认证, 一些服务需要在您的目录中提供 LDAP 方案. 如果您使用关系数据库,可以在配置 PAM 模块时, 使用一个有趣的设定. 例如, 如果您有一个带有如下表属性的数据库:
  (user_id, user_name, realname, shell, password, UID, GID, homedir, sys, pop, imap, ftp)
通过标记服务的属性布尔字段, 就可以启用或禁用对于不同服务的访问, 仅仅需要在下列文件插入合适的内容:
  • /etc/pam.d/imap:where=imap=1.
  • /etc/pam.d/qpopper:where=pop=1.
  • /etc/nss-mysql*.conf:users.where_clause = user.sys = 1;.
  • /etc/proftpd.conf: SQLWhereClause "ftp=1".

12.1.2. 我的系统存在漏洞!(您确认吗?)

12.1.2.1. 漏洞评估扫描器 X 说我的 Debian 系统存在漏洞!

许多漏洞评估扫描器在 Debian 系统上使用不能给予肯定的回答, 因为它们通过版本检查来确定给定软件包是否存在漏洞, 并不真正的进行安全漏洞测试. 因为 Debian 在修正软件漏洞后并不修改软件版本信息 (很多时候, 修复一个更新版本仅仅是移植), 一些工具认为一个更新了的 Debian 系统是存在漏洞的, 即使并不是这样.
如果您认为您的系统已经更新了最新的安全补丁, 可以与 DSA(参见 第 7.2 节 “Debian 安全公告”) 公布的安全漏洞数据库相参考, 识别虚假信息, 如果您使用的工具包括 CVE 参考.

12.1.2.2. 我在系统日志中看到一次攻击. 我的系统被入侵了吗?

A trace of an attack does not always mean that your system has been compromised, and you should take the usual steps to determine if the system is indeed compromised (see 第 11 章 攻陷之后(事件响应)). Even if your system was not vulnerable to the attack that was logged, a determined attacker might have used some other vulnerability besides the ones you have detected.

12.1.2.3. 我在日志中发现了奇怪的 'MARK' 行: 我被入侵了吗??

您也许在系统日志中发现了如下内容:
  Dec 30 07:33:36 debian -- MARK --
  Dec 30 07:53:36 debian -- MARK --
  Dec 30 08:13:36 debian -- MARK --
This does not indicate any kind of compromise, and users changing between Debian releases might find it strange. If your system does not have high loads (or many active services), these lines might appear throughout your logs. This is an indication that your syslogd daemon is running properly. From syslogd(8):
       -m interval
              The syslogd logs a mark timestamp  regularly.   The
              default interval between two -- MARK -- lines is 20
              minutes.  This can be  changed  with  this  option.
              Setting the interval to zero turns it off entirely.

12.1.2.4. 在日志中发现有用户使用'su': 我被入侵了?

有可能您在日志中发现如下类似内容:
  Apr  1 09:25:01 server su[30315]: + ??? root-nobody
  Apr  1 09:25:01 server PAM_unix[30315]: (su) session opened for user nobody by (UID=0)
不必太担心. 检查这些内容是否与 cron 有关 (通常为 /etc/cron.daily/findlogrotate):
  $ grep 25 /etc/crontab
  25 9    * * *   root    test -e /usr/sbin/anacron || run-parts --report
  /etc/cron.daily
  $ grep nobody /etc/cron.daily/*
  find:cd / && updatedb --localuser=nobody 2>/dev/null

12.1.2.5. I have found 'possible SYN flooding' in my logs: Am I under attack?

如果您在日志中发现了如下类似内容:
  May 1 12:35:25 linux kernel: possible SYN flooding on port X. Sending cookies.
  May 1 12:36:25 linux kernel: possible SYN flooding on port X. Sending cookies.
  May 1 12:37:25 linux kernel: possible SYN flooding on port X. Sending cookies.
  May 1 13:43:11 linux kernel: possible SYN flooding on port X. Sending cookies.
netstat 检查服务器是否存在大量的连接, 例如:
  linux:~# netstat -ant | grep SYN_RECV | wc -l
     9000
这表明对您的系统的 X 端口(通常是对应公共服务, 如 web 服务器, 或邮件服务器)进行了拒绝服务(DoS)攻击. 您应当激活内核中的 TCP syncookies, 参阅 第 4.18.2 节 “Configuring syncookies”. 但是, 应当注意, 这样即使您能避免系统被搞瘫, 一个 DoS 攻击仍能湮没您的网络(由于资源标示被耗尽, 系统也许暂时无法应答 TCP 连接, 直至超时). 最有效的解决方法是联系您的网络提供商.

12.1.2.6. 在日志中发现了奇怪的 root 会话: 我被入侵了?

/var/log/auth.log 文件中, 也许您会发现如下类似内容:
  May 2 11:55:02 linux PAM_unix[1477]: (cron) session closed for user root
  May 2 11:55:02 linux PAM_unix[1476]: (cron) session closed for user root
  May 2 12:00:01 linux PAM_unix[1536]: (cron) session opened for user root by
  (UID=0)
  May 2 12:00:02 linux PAM_unix[1536]: (cron) session closed for user root
这与执行的 cron 任务有关(在这个例子中,每5分钟一次). 确定哪个程序对应这些任务, 检查如下目录中的内容: /etc/crontab, /etc/cron.d, /etc/crond.daily 和 root 的 crontab 目录.

12.1.2.7. 我被入侵了, 怎么办?

这种情况下,也许您应当采取如下措施:
  • Check if your system is up to date with security patches for published vulnerabilities. If your system is vulnerable, the chances that the system is in fact compromised are increased. The chances increase further if the vulnerability has been known for a while, since there is usually more activity related to older vulnerabilities. Here is a link to http://www.sans.org/top20/.
  • 阅读本文档, 尤其 第 11 章 攻陷之后(事件响应) 部分.
  • 寻求帮助. 您可以使用 Debian 安全邮件列表, 寻求如何恢复/修补您的系统的建议.
  • Notify your local http://www.cert.org (if it exists, otherwise you may want to consider contacting CERT directly). This might or might not help you, but, at the very least, it will inform CERT of ongoing attacks. This information is very valuable in determining which tools and attacks are being used by the blackhat community.

12.1.2.8. 如何跟踪攻击?

查看日志(如果还未被篡改), 使用入侵检测系统(参见 第 10.3 节 “设置入侵检测”), traceroute, whois 和其它简单的工具(包括事故分析), 您也许能跟踪到攻击源. 这种方法是否有效与您的安全策略, 以及认为什么是攻击有关. 远程扫描是攻击吗? 漏洞探测是攻击吗?

12.1.2.9. Debian 系统中的程序 X 存在漏洞, 我该怎么办?

First, take a moment to see if the vulnerability has been announced in public security mailing lists (like Bugtraq) or other forums. The Debian Security Team keeps up to date with these lists, so they may also be aware of the problem. Do not take any further actions if you see an announcement at http://security.debian.org.
If no information seems to be published, please send e-mail about the affected package(s), as well as a detailed description of the vulnerability (proof of concept code is also OK), to mailto:team@security.debian.org. This will get you in touch with Debian's security team.

12.1.2.10. 软件包的版本号表明,我正在运行一个存在漏洞的版本!

Instead of upgrading to a new release, Debian backports security fixes to the version that was shipped in the stable release. The reason for this is to make sure that the stable release changes as little as possible, so that things will not change or break unexpectedly as a result of a security fix. You can check if you are running a secure version of a package by looking at the package changelog, or comparing its exact (upstream version -slash- debian release) version number with the version indicated in the Debian Security Advisory.


[72] For example, based on some data, it might seem that Windows NT is more secure than Linux, which is a questionable assertion. After all, Linux distributions usually provide many more applications compared to Microsoft's Windows NT. This counting vulnerabilities issues are better described in http://www.dwheeler.com/oss_fs_why.html#security by David A. Wheeler
[73] >Without diminishing the fact that some distributions, such as Red Hat or Mandrake, are also taking into account security in their standard installations by having the user select security profiles, or using wizards to help with configuration of personal firewalls.
[74] >Note that this is 'security by obscurity', and will probably not be worth the effort in the long term.
[75] Be careful, as this will traverse your whole system. If you have a lot of disk and partitions you might want to reduce it in scope.