Linux Cron 文件所有权和权限配置问题

漏洞信息

漏洞名称: Linux Cron 文件所有权和权限配置问题

漏洞类型: 配置问题

漏洞等级: 高危

漏洞描述: 该漏洞涉及Linux系统中的Cron服务配置文件(/etc/cron.allow和/etc/cron.deny)的所有权和权限设置不当问题。Cron是Linux系统中用于定时执行任务的守护进程,广泛用于服务器和桌面系统中,以实现自动化任务调度。如果这些文件的权限设置不当,可能会导致未经授权的用户能够修改或添加定时任务,从而可能引发系统被入侵或服务拒绝的风险。具体来说,漏洞的根源在于这些文件的所有权不是root用户,或者文件的权限设置过于宽松(如权限大于640),这违反了最小权限原则。攻击者可以利用这一漏洞,通过添加恶意定时任务来执行任意代码,或者在系统上执行未授权的操作,进而可能导致数据泄露、服务中断或其他安全事件。由于Cron服务通常以高权限运行,这种配置错误的影响尤为严重。

产品名称: Linux Cron

来源: https://github.com/projectdiscovery/nuclei-templates/blob/dfc176303ffebe3d9f231045fa3abe2cf2ca9874/misconfiguration%2Flinux%2Flinux-cron-ownership-perms-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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

id: linux-cron-file-permissions

info:
name: Cron File Ownership and Permissions Check
author: songyaeji
severity: high
description: >
Checks whether /etc/cron.allow and /etc/cron.deny files have proper ownership (root)
and permission (640). Misconfigured cron access files may allow unauthorized users
to schedule cron jobs, which could result in system compromise or denial of service.
reference:
- https://isms.kisa.or.kr
- Cloud Vulnerability Assessment Guide(2024) by KISA
tags: linux,cron,permissions,misconfiguration,local
metadata:
verified: true
os: linux
max-request: 1
classification:
cvss-metrics: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
cvss-score: 7.8
cwe-id: CWE-732

self-contained: true

code:
- engine:
- bash
source: |
result=""
if [ -f /etc/cron.allow ]; then
owner=$(stat -c "%U" /etc/cron.allow)
perm=$(stat -c "%a" /etc/cron.allow)
if [ "$owner" != "root" ] || [ "$perm" -gt 640 ]; then
result+="[WARN] /etc/cron.allow misconfigured\n"
fi
fi

if [ -f /etc/cron.deny ]; then
owner=$(stat -c "%U" /etc/cron.deny)
perm=$(stat -c "%a" /etc/cron.deny)
if [ "$owner" != "root" ] || [ "$perm" -gt 640 ]; then
result+="[WARN] /etc/cron.deny misconfigured\n"
fi
fi

if [ -n "$result" ]; then
echo -e "$result"
else
echo "[OK] cron files properly configured"
fi
matchers:
- type: word
part: code_1_response
words:
- "[WARN] /etc/cron.allow misconfigured"
- "[WARN] /etc/cron.deny misconfigured"


Linux Cron 文件所有权和权限配置问题
http://example.com/2025/07/31/github_179881092/
作者
lianccc
发布于
2025年7月31日
许可协议