/etc/hosts File Owner and Permission Check

漏洞信息

漏洞名称: /etc/hosts File Owner and Permission Check

漏洞类型: 配置问题

漏洞等级: 高危

漏洞描述: 该漏洞涉及Linux系统中的/etc/hosts文件权限配置问题。/etc/hosts文件用于存储主机名与IP地址的映射关系,是系统网络配置的重要组成部分。如果该文件的权限配置不当,非root用户可写入,攻击者可能利用此漏洞注册恶意的DNS映射,将合法域名重定向到恶意网站,从而实施钓鱼攻击(pharming attacks)。

漏洞的技术根源在于文件权限设置不当,即/etc/hosts文件的所有者不是root,或者文件的权限设置过于宽松,允许非特权用户进行修改。这种配置问题属于权限管理不当,可能导致严重的安全风险。

该漏洞的影响较为严重,攻击者可以利用此漏洞进行DNS欺骗,进而实施中间人攻击、钓鱼攻击等,威胁用户的数据安全和隐私。由于漏洞利用不需要用户交互,且可以自动化执行,因此风险等级被评定为高危。为了防止此类攻击,建议确保/etc/hosts文件的所有者为root,且权限设置为644,即只有root用户有写权限,其他用户仅有读权限。

产品名称: Linux系统

来源: https://github.com/projectdiscovery/nuclei-templates/blob/1dc5e4c5a7e3689548a72d7cb2a00b803fccc824/misconfiguration%2Flinux%2Fetc-hosts-permission-check.yaml

类型: projectdiscovery/nuclei-templates:github issues

POC详情

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

id: etc-hosts-permission-check

info:
name: /etc/hosts File Owner and Permission Check
author: songyaeji
severity: high
description: >
If the /etc/hosts file is writable by non-root users, attackers may register malicious DNS mappings and redirect legitimate domains to malicious sites (pharming attacks). This check ensures /etc/hosts is owned by root and has appropriate permissions.
reference:
- https://isms.kisa.or.kr/main/csap/notice/
- Cloud Vulnerability Assessment Guide (2024) by KISA
tags: linux,local,hosts,file,permission,ownership,misconfiguration
metadata:
verified: true
os: linux
max-request: 1
classification:
cwe-id: CWE-732
cvss-metrics: CVSS:3.0/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
cvss-score: 7.4

self-contained: true

code:
- engine:
- bash
source: |
stat -c "%U %G %a" /etc/hosts 2>/dev/null || echo "not-found"
matchers:
- type: regex
part: code_1_response
regex:
- '^root\s+root\s+([0-5]?[0-9]{2}|644)$'


/etc/hosts File Owner and Permission Check
http://example.com/2025/07/29/github_2712907261/
作者
lianccc
发布于
2025年7月29日
许可协议