User namespaces and setgroups()

高级Bash自动化:构建可审计、可回滚、可防御的生产级脚本体系 Bash脚本在DevOps与安全运维中早已超越临时命令行工具,演变为承载CI/CD、日志管理、配置分发等关键任务的‘自动化神经中枢’。其核心原理在于将传统Shell能力工程化:通过变量作用域控制(declare -r)、执行约束(set -euo pipefail)、输入深度校验与Linux Namespaces沙箱,实现运行时安全收敛。技术价值体现在降低等保2.0三级合规成本、消除因PATH污染或变量注入导致的提权风险,并支撑零信任场景下的最小权限自动化。典型应用场景包括金融系统日终对账、支付平台部署流水 阅读详情

User namespaces and setgroups()

By  Jonathan Corbet
December 17, 2014
Back in November, we  looked at a patch that would allow unprivileged processes to drop groups from their credentials. After that patch was posted, it was quickly shown that, in some cases, dropping groups leads to an increase in privilege; the patch in question has not been pursued since. But it was also shown that an unprivileged user can already drop groups by making use of user namespaces. It took some time, but namespace developer Eric Biederman has put together a set of patches that, he hopes, will close that vulnerability.

Group membership can be used to restrict privilege in a couple of ways. Access control lists can explicitly block access to a resource on the basis of membership in a particular group. But it is even simpler than that: if a file's protection bits are set for "no group access," a process belonging to that group will be blocked, even if the file is otherwise accessible by the world as a whole. In either case, the ability to drop a group can enable a process to access a resource that would have otherwise been denied to it.

In current kernels, using setgroups() to change a process's group membership is a privileged operation. So unprivileged processes cannot use it to get rid of any inconvenient group memberships. But a process running within a user namespace is privileged inside that namespace, so a setgroups() call there will succeed. It is easy to write a little program that uses clone() to create a child in a user namespace and has the child call setgroups()to drop membership in all supplementary groups. This privilege-escalation vulnerability has become known as CVE-2014-8989.

Eric's fix for this problem starts by disabling the use of setgroups() within a user namespace until a group-ID mapping has been set up for that namespace. That mapping is created by writing the file gid_map in the process's/proc directory; see this article for details on how the mapping files work. Other user- or group-ID-oriented system calls require the existence of a mapping before they will succeed; setgroups() now has that restriction as well.

The biggest part of the patch adds a new control file, called setgroups, to the /proc directory for each process. Writing the string "deny" to that file will disable the setgroups() system call entirely within the namespace containing the relevant process. The CAP_SYS_ADMIN capability is required, so random processes cannot disablesetgroups() in the top-level namespace; once again, a process within its own user namespace is privileged (by default) and can make this change successfully. Once setgroups() has been turned off, it cannot be enabled again in that namespace or any of its descendants. The setgroups file can only be written to before the group-ID mapping has been set.

Finally, an unprivileged process can only change the group-ID mapping of a namespace if setgroups() has been disabled. The only thing an unprivileged process can do with the group-ID mapping is to map its own primary group ID to the same ID in the parent namespace; an unprivileged process is not able to remap its supplementary groups. So, with this set of restrictions in place, it essentially become impossible to (1) play tricks with mappings to drop groups, or (2) call setgroups() at all without privilege.

Note that if a privileged process creates a user namespace, it can set up arbitrary mappings for group IDs and decline to disable setgroups(). That would make the dropping of groups within the namespace possible, but, since the process is already privileged, it could do that anyway.

The end result of all this work should be the closing of the vulnerability caused by being able to drop groups within a user namespace. But it highlights one of the hazards that come with the user namespace territory: while it seems possible to contain privilege within a user namespace, there is always the possibility of surprises like this one hiding in the corners of the system. It may be some time yet before we can be truly confident that all of those surprises have been found and that the unprivileged creation of user namespaces is truly a safe thing to allow.

Eric has asked Linus to pull these changes for the 3.19 development cycle; that pull happened just as this week's Edition was going to press. The patches have been marked for stable backporting as well, so they should eventually become available in the stable update series.

namespaces之 User Namespace机制 USER Namespaces 主要是对用户和用户组进行隔离。它是从Linux 3.8内核才慢慢支持的,现在有些linux发行版还不支持user namespaces(主要是因为还不完全成熟,处于对安全的担心,在编译内核时并未开启USER Namespaces,Centos 7就不支持,后边的测试基于Ubuntu 14.04).  User namespaces允许每个命名空间中User 阅读详情

相关推荐

User Namespaces 加固Docker container 宿主机

Docker 容器以及其所运行的宿主机的安全防护是维护可信的服务的关键。 以专业的安全领域的DevOps角度来看, 对container 以及container 的调度平台想OpenShift、Docker Swarm以及如日中天的K8S进行安全防护其实很简单。 主要是因为在技术革新如此快速的时代,目标变化的也如此频繁。由于新技术的发展,其产生的许多挑战需要去解决,在解决这些问题的方法当中,有一项是

Yet Another Cloud 587

docker基础大全总结

docker大图 Docker的安装和使用-centos7 最新的 Docker 支持情况,官方文档在这里: https://docs.docker.com/install/ Docker 对于内核支持的功能,即内核的配置选项也有一定的要求(比如必须开启 Cgroup 和 Namespace 相关选项,以及其他的网络和存储驱动等),centos7内核版本不低于 3.10, Docker 源码中提供了一个检测脚本来检测和指导内核的配置,脚本链接在这里: https://raw.githubuserconten

u011333324的博客 940

01-linux下Postgresql的安装

1.看官网 https://www.postgresql.org/download/ 2.选择系统 这里选择Red Hat family Linux (including CentOS/Fedora/Scientific/Oracle variants) 3.查看linux系统版本 参考: 03-centos 如何查看操作系统是哪个版本 :http://blog.csdn.n...

九师兄 2117

LWN:非特权容器的进展!

关注了就能看到更多这么棒的文章哦~Progress for unprivileged containersBy Jake EdgeSeptember 28, 2022LSS EUDeepL assisted translationhttps://lwn.net/Articles/909627/在过去的几年里,内核里针对创建无特权容器(containers without requiring pri...

Linux News搬运工 344

iOS开发者必备:从越狱设备里提取IPA的三种方法(含Filza、iTools实战)

本文详细介绍了iOS开发者从越狱设备提取IPA文件的三种实用方法,包括使用Filza文件管理器、AFC2配合桌面工具以及命令行高级技术。内容涵盖环境准备、操作步骤和技术原理,帮助开发者高效获取应用包文件,适用于逆向工程、测试分析等场景。

weixin_28717969的博客 850

Unity轻量级框架QFramework:四层架构与命令事件驱动的实战指南

在Unity游戏开发中,软件架构是确保项目可维护性和可扩展性的核心。通过分层架构(如MVC、DDD)和事件驱动设计,开发者能够有效管理代码复杂度,实现模块间的解耦与高效通信。QFramework作为一个轻量级框架,精准地运用了这些原理,通过严格定义的四层架构(表现层、系统层、数据层、工具层)和命令/事件通信规则,为中小型项目提供了“约束下的自由”。其核心价值在于以极简的代码(不足1000行)强制实施清晰的职责分离,如使用命令模式集中管理状态变更,并通过事件驱动实现响应式更新。这种设计特别适用于解决项目规模扩

weixin_42521032的博客 269

linux开启tftp服务,Linux tftp服务无法启动原因及解决方法

在linux下,不管使用的是哪一种super-server,inetd或者xinetd,默认情况下TFTP服务是禁用的,所以要修改文件来开启服务。根据(1)的安装方法,可以修改文件/etc/xinetd.d/tftp。主要是设置TFTP服务器的根目录,开启服务。修改后的文件如下:servicetftp{socket_type=dgramprotocol=udpwait=yesuser=r...

weixin_33908564的博客 2001

envi5.3处理高分二号影像数据详细过程记录

全文根据此篇文章进行数据处理: tm影像辐射定标_高分二号影像数据预处理及裁剪过程 其他参考: 学习笔记---遥感影像辐射定标与大气校正 利用ENVI自带全球DEM数据计算区域平均高程 高分二号数据处理流程(有高分二号的数据信息) GF2有多光谱和全色两个数据,MSS是多光谱的,PAN是全色的,多光谱的分辨率低,全色的高,需要把这两个数据融合,融合之前需要做定标等处理,获取经纬度。 一、多光谱影像处理 1. 辐射定标 以这个为例: 其他路径\2022.4.2...

ligous的博客 5万+

了解docker

了解docker 什么是docker Docker是使用go语言基于LINUX内核的cgroup,namespace以及AUFS 类的 Union FS 等技术,对进程进行封装隔离的一种操作系统层面的虚拟化技术,由于隔离的进程独立于宿主和其它的隔离的进程,因此也称其为容器。 为什么要使用 Docker 更高效的利用系统资源 由于Docker工作在进程级别,不需要进行硬件虚拟以及运行完整操作系统等额...

隔壁小翔 2018

新手别怕!用‘东北天’和‘右前上’坐标系,5分钟搞懂惯性导航姿态矩阵(含Python验证代码)

本文通过‘东北天(ENU)’和‘右前上(RFU)’坐标系,详细解析惯性导航中的姿态矩阵概念。包含Python代码验证,帮助新手快速理解坐标变换、欧拉角及旋转矩阵的构建与应用,特别强调有限转动不可交换性与无限转动次序无关的区别。

weixin_29062255的博客 336

Android车载蓝牙开发全攻略:从基础到高级优化

本文系统介绍了Android车载蓝牙开发的核心技术与实践指南。文章首先阐述了蓝牙在智能汽车中的关键作用,包括免提通话、音频流媒体等应用场景。随后详细解析了蓝牙协议基础,重点介绍了HFP、A2DP等车载常用协议。开发实战部分提供了设备发现、连接、数据传输的完整代码示例,并融入多线程和内存优化技巧。通过真实车载案例,展示了启动时间、流畅度和资源使用的优化策略。最后针对面试需求,提供了专业的技术问答,涵盖蓝牙开发全流程。全文紧密结合Android车载开发职位要求,为开发者提供了一套完整的蓝牙技术解决方案。

郑伟强dev的专栏 123

linux proc文件系统详解

linux proc文件系统详解 文章目录linux proc文件系统详解PIDattrcurrentexecfscreatekeycreateprevsockcreateautogroupauxvcgroupclear_refscmdlinecommcoredump_filtercpusetcwd -> /environexefdfdinfogid_mapiolimitsloginuidmap_filesmapsmemmountinfomountsmountstatsnetnsnuma_mapsoo

fly0512的博客 7524

基于 ESP32 的智能环境监测与远程报警系统

本系统基于 ESP32 实现了环境数据的采集、远程传输、报警通知功能,硬件成本低、接线简单、代码可直接运行。用户可根据实际需求调整传感器类型(如替换为 PM2.5 传感器、土壤湿度传感器)和功能扩展,适合嵌入式 IoT 入门学习和实际场景应用。通过多轮迭代(如优化低功耗、增加 APP 控制),可进一步提升系统的实用性和稳定性。

weixin_42300449的博客 1025

Linux OCI标准runtime-spec与内核接口映射

runtime 在 `create` 阶段调用 clone(2) 时组合这些 flags,内核在 `kernel/nsproxy.c:create_new_namespaces()` 中为每个 namespace 创建独立的 `struct nsproxy`。对于已经运行的进程(如 `exec` 操作),runtime 改用 `unshare(2)` 进入目标 namespace,此时通过 `/proc/OCI runtime-spec 与 Linux 内核接口映射。

raoxiaoz0425的博客 150

Python 爬虫实战:在房天下抓取房产信息,分析房价走势

通过本次 Python 爬虫实战,我们成功地从房天下爬取了房产信息,并进行了存储、处理、分析和可视化展示。在这个过程中,我们不仅掌握了爬虫技术的基本应用,还学会了如何对动态加载的数据进行处理和分析。然而,本次爬虫任务也存在一些局限性,例如仅爬取了部分区域的房产数据,且未对房产的图片和视频内容进行分析。在未来的工作中,我们可以进一步优化爬虫程序,爬取更多区域的房产数据,并深入分析房产的多媒体内容、用户行为模式等,为购房者和房地产从业者提供更有价值的数据支持。

u014481728的博客 1375

MOS管基础知识及应用电路Multisim仿真

本文系统介绍了MOS管的基础知识及其在电子电路中的典型应用。首先详细解析了MOS管的基本结构、分类和工作原理,包括NMOS、PMOS及CMOS的特性差异。重点阐述了MOS管的三种放大组态电路(共源、共漏、共栅)及其小信号模型分析。随后通过Multisim仿真验证了MOS管在防反接电路、开关电路、放大电路、逻辑门电路、电平转换电路和开关电源(BUCK、BOOST、BUCK-BOOST)等应用中的实际表现。文章还深入探讨了自给偏压和分压式偏置电路的设计要点。全文通过理论分析与仿真实验相结合的方式,全面展示了MO

XU157303764的博客 1495

setgroups函数:设置组代码函数

函数说明:setgroups()用来将list 数组中所标明的组加入到目前进程的组设置中. 参数size 为list()的gid_t 数目, 最大值为NGROUP(32)。#include <grp.h> int setgroups(size_t size, const gid_t * list);返回值:设置成功则返回0, 如有错误则返回-1.错误代码: EFAULT:参数list 数组地址不合

pk_20140716的专栏 4075

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

深入剖析kubernetes及企业级搭建实战(二)

三、企业级k8s搭建实战 本次安裝的版本:1.12.3 操作系统主机名节点及功能 IP备注 CentOS7.4 X86_64 master1 master/etcd 192.168.6.101 kube-apiserver、kube-controller-manager、kube-scheduler、etcd、docker、calico-image CentOS7.4 X86_65 m...

qq_37452571的博客 1049

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

CentOS 7系统,Docker想启用userns-remap,傻了吧?

今天想启用这个功能, 这样,docker里的root用户,就不用是宿主机的root用户, 安全性可以提高一个层次。 于是找了文档,对比了配置,default用了,自定义用了, 结果呢? 傻眼了~~~~全都失败。 ~~~~~~~~~~~~~~~~~~~~ 花了几小时,再想找找为何失败, 结果,原来在centos/rhel中, user namespace...

weixin_33720078的博客 943

su命令cannot set groups: Operation not permitted的解决方法

版权声明:本文由曾倩倩原创文章,转载请注明出处:  文章原文链接:https://www.qcloud.com/community/article/103 来源:腾云阁 https://www.qcloud.com/community 问题场景: user_00@hadoop-10-125-224-102:> su root Password: su: cannot set gr

qian_xiaoqian的博客 1万+

【Linux】深入解析Linux proc文件系统

在Linux上,proc是一个伪文件系统,提供了访问内核数据的方法,一般挂载在“/proc”目录,其中的大部分内容是只读的,挂载(mount)信息可能为:proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)proc文件系统支持如下挂载选项:hidepid=_n gid=_gid_n设置访问“/proc/[pid]”目录的权限,可以取值为0

Making Life Better. Making Others Better. 1万+

Linux---/proc目录全讲解

一、大概内容预览 # ls /proc 1、pid目录 “/proc/[pid]”,目录,pid为进程的数字ID,是个数值,每个运行着的进程都有这么一个目录。 “/proc/[pid]/attr”,目录,提供了安全相关的属性,可读可写,以支持安全模块如SELinux等,需配置CONFIG_SECURITY。 “/proc/[pid]/attr/current”,文件,当前的安全相关的属性。 “/proc/[pid]/attr/exec”,文件,执行命令execve时设置的安全相关的属性。 “/proc

Kammingo的博客 1822

Linux服务器查看内存使用情况

前言 在日常开发或者生产环境,我们经常需要查看linux服务的内存使用情况,所以能熟练敲出命令能便于我们快速定位问题,这里来和大家一起学习linux的常用查看内存命令。 free命令 free命令显示系统使用和空闲的内存情况,包括物理内存、交互区内存(swap)和内核缓冲区内存。 很清晰明白的显示出了总内存多少,已使用多少,还剩下多少。这里可以看到Swap的used已使用了811Mb,服务器上跑了一个下载音频的进程,物理内存已经不够用了,所以从磁盘中虚拟出一部分的内存。当然我们可以使用free.

爱琴孩的博客 1726

CentOS 6.0 配置 tftp-server

yum install tftp*   安装好tftp-server包, 需要把/etc/xinetd.d/tftp文件做一下几个修改。 # default: off # description: The tftp server serves files using

delicioustian的专栏 3724
上一篇: Jump label
下一篇: 如何在程序中升高和降低权限
samssm
博客等级 码龄19年 68粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值