/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用户拥有,并且权限设置为644,以确保只有root用户有写权限,其他用户仅有读权限。如果这些条件不满足,就可能被利用。此漏洞的影响范围广泛,因为Linux系统在服务器和个人电脑中都有广泛应用。攻击者利用此漏洞可以在不需要认证的情况下,通过本地访问修改/etc/hosts文件,进而可能引发中间人攻击、数据泄露或服务中断等安全问题。由于漏洞利用条件相对简单,且影响直接,因此被评定为高危漏洞。

产品名称: Linux系统

来源: https://github.com/projectdiscovery/nuclei-templates/blob/dfc176303ffebe3d9f231045fa3abe2cf2ca9874/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/31/github_495157671/
作者
lianccc
发布于
2025年7月31日
许可协议