User Home Directory and Shell Environment File Ownership & Permission Check

漏洞信息

漏洞名称: User Home Directory and Shell Environment File Ownership & Permission Check

漏洞类型: 配置问题

漏洞等级: 中危

漏洞描述: 该漏洞涉及Linux系统中用户主目录及shell环境文件(如.bashrc、.bash_profile、.bash_logout)的所有权和权限配置问题。如果这些文件不被用户或root拥有,或者具有不安全的写入权限,恶意用户可能操纵环境变量或注入恶意命令。

受影响产品: Linux操作系统中的shell环境文件是用户登录时自动执行的脚本,用于配置用户的环境变量和执行初始化命令。这些文件广泛存在于所有基于Linux的系统中,是系统安全配置的重要组成部分。

漏洞解释: 此漏洞属于配置问题,具体表现为shell环境文件的所有权不正确或权限设置过于宽松。技术根源在于系统管理员未能正确设置文件权限,导致未授权用户可能修改这些文件,从而在用户登录时执行恶意代码。

影响分析: 此漏洞可能导致恶意用户通过修改环境文件,实现权限提升或执行任意命令。攻击者可以利用此漏洞在受害用户登录时自动执行恶意代码,无需额外认证。由于这是本地漏洞,攻击者需要具有对系统的某种访问权限,但一旦利用成功,影响范围可能从单个用户扩展到整个系统,特别是在多用户环境中。

产品名称: Linux shell environment files

来源: https://github.com/projectdiscovery/nuclei-templates/blob/1dc5e4c5a7e3689548a72d7cb2a00b803fccc824/misconfiguration%2Flinux%2Fhome-env-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
36
37
38
39
40
41
42

id: home-env-permission-check

info:
name: User Home Directory and Shell Environment File Ownership & Permission Check
author: songyaeji
severity: medium
description: >
If shell startup and environment files (e.g. .bashrc, .bash_profile, .bash_logout) are not owned by the user or root,
or have insecure write permissions, malicious users can manipulate environment variables or inject malicious commands.
tags: linux,local,permissions,home,shell,compliance
reference:
- https://isms.kisa.or.kr
- Cloud Vulnerability Assessment Guide(2024) by KISA
metadata:
os: linux
verified: true
max-request: 1

self-contained: true

code:
- engine:
- bash
source: |
for user in $(awk -F: '$6 ~ /^\/home/ {print $1}' /etc/passwd); do
HOME_DIR=$(eval echo ~$user)
find "$HOME_DIR" -maxdepth 1 -type f \( -name ".bashrc" -o -name ".bash_profile" -o -name ".bash_logout" \) -exec ls -l {} \;
done
matchers:
- type: regex
name: insecure-perms
part: code_1_response
regex:
- "^-..w..w..w"
- "^-.{2}w.{2}w.{2}w"
- type: negative-word
name: not-owned-by-user
words:
- "root"
part: code_1_response


User Home Directory and Shell Environment File Ownership & Permission Check
http://example.com/2025/07/29/github_3362455921/
作者
lianccc
发布于
2025年7月29日
许可协议