بنقرة واحدة
detecting-container-drift-at-runtime
通过监控二进制执行偏移、文件系统变更以及与原始容器镜像的配置偏差,检测对运行中容器的未授权修改。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
通过监控二进制执行偏移、文件系统变更以及与原始容器镜像的配置偏差,检测对运行中容器的未授权修改。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
通过分析 Zeek dns.log 中的高熵子域名查询、超量查询量、超长查询长度以及异常 DNS 记录类型,检测 DNS 隧道和数据外泄中的隐蔽通道通信。适用于:当需要狩猎基于 DNS 的 C2 或数据外泄通道、调查异常 DNS 查询模式、或响应涉及 DNS 隧道工具(iodine、dnscat2、DNSExfiltrator)的威胁情报时使用。
实施 Google 的 BeyondCorp 零信任访问模型,通过 IAP、Access Context Manager 和 Chrome Enterprise Premium,消除网络边界的隐式信任,强制执行基于身份的访问控制,实现无 VPN 的安全应用访问。适用于将传统 VPN 替换为零信任架构、部署 Identity-Aware Proxy、配置设备信任策略、或为远程办公实施上下文感知访问控制时使用。
在授权的安全评估过程中,使用 Burp Suite 的扫描器、Intruder 和 Repeater 工具识别和验证跨站脚本(XSS)漏洞。适用于 Web 应用渗透测试中检测反射型、存储型和 DOM 型 XSS,验证自动化扫描器报告的 XSS 发现,以及评估 CSP 和 XSS 过滤器的有效性时使用。
攻击活动溯源归因分析涉及系统性地评估证据,以确定哪个威胁行为者或组织对某次网络行动负责。本技能涵盖使用 Diamond Model 和 ACH(竞争假设分析)收集并加权溯源归因指标、分析基础设施重叠、TTP 一致性、恶意软件代码相似性、操作时序模式和语言痕迹,以构建置信度加权的溯源归因评估。
从 PE 文件和内存转储中提取并分析 Cobalt Strike beacon 配置,以识别 C2 基础设施、Malleable C2 配置文件和攻击者操作惯例。
使用 Ghidra 及专用脚本对 Go 编译的恶意软件进行逆向工程,包括函数恢复、字符串提取和去符号表 Go 二进制文件的类型重建。
| name | detecting-container-drift-at-runtime |
| description | 通过监控二进制执行偏移、文件系统变更以及与原始容器镜像的配置偏差,检测对运行中容器的未授权修改。 |
| domain | cybersecurity |
| subdomain | container-security |
| tags | ["container-drift","runtime-security","immutable-containers","falco","kubernetes","container-security","drift-detection","microsoft-defender"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
容器偏移是指运行中的容器通过未授权的文件修改、意外的二进制执行、配置变更或软件包安装,偏离其原始镜像状态的现象。由于容器应被视为不可变基础设施,任何偏移都是潜在的入侵指标。检测技术利用 DIE(检测、隔离、驱逐)模型——不可变工作负载在运行期间不应发生变化,因此任何观察到的变化都可能是恶意活动的证据。
基于镜像的比对:将运行中容器的文件系统与源镜像进行比较,识别已添加、修改或删除的文件。
行为监控:使用 eBPF 或内核级监控来检测偏离预期行为的进程执行、文件访问和网络活动。
摘要验证:持续验证运行中的容器镜像摘要是否与已批准的部署清单匹配。
- rule: Drift Detected (Container Image Modified Binary)
desc: 检测执行原始容器镜像中不存在的二进制文件
condition: >
spawned_process and
container and
not proc.pname in (container_entrypoint) and
proc.is_exe_upper_layer = true
output: >
检测到偏移:容器中执行了新的二进制文件
(user=%user.name command=%proc.cmdline container=%container.name
image=%container.image.repository:%container.image.tag
exe_path=%proc.exepath)
priority: WARNING
tags: [container, drift]
- rule: Container Shell Spawned
desc: 检测应不可变容器中的交互式 shell
condition: >
spawned_process and
container and
proc.name in (bash, sh, dash, zsh, csh, ksh) and
not proc.pname in (container_entrypoint)
output: >
容器中启动了 shell (user=%user.name shell=%proc.name
container=%container.name image=%container.image.repository)
priority: WARNING
tags: [container, drift, shell]
- rule: Package Manager Execution in Container
desc: 检测包管理器的使用,表明存在偏移
condition: >
spawned_process and
container and
proc.name in (apt, apt-get, yum, dnf, apk, pip, pip3, npm, gem, cargo)
output: >
容器中执行了包管理器 (user=%user.name
command=%proc.cmdline container=%container.name
image=%container.image.repository)
priority: ERROR
tags: [container, drift, package-manager]
- rule: Container File System Write
desc: 检测对容器上层文件系统的写入操作
condition: >
open_write and
container and
fd.typechar = 'f' and
not fd.name startswith /tmp and
not fd.name startswith /var/log and
not fd.name startswith /proc
output: >
容器中发生文件写入 (user=%user.name file=%fd.name
container=%container.name)
priority: NOTICE
tags: [container, drift, filesystem]
通过使容器文件系统不可变来防止偏移:
apiVersion: apps/v1
kind: Deployment
metadata:
name: immutable-app
spec:
template:
spec:
containers:
- name: app
image: app:v1.0@sha256:abc123...
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
runAsNonRoot: true
volumeMounts:
- name: tmp
mountPath: /tmp
- name: cache
mountPath: /var/cache
volumes:
- name: tmp
emptyDir:
sizeLimit: 100Mi
- name: cache
emptyDir:
sizeLimit: 50Mi
apiVersion: v1
kind: Namespace
metadata:
name: production
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
#!/bin/bash
# 将运行中容器的摘要与已批准清单进行比对
NAMESPACE="production"
kubectl get pods -n "$NAMESPACE" -o json | jq -r '
.items[] |
.spec.containers[] |
"\(.image) \(.imageID)"
' | while read IMAGE IMAGE_ID; do
APPROVED_DIGEST=$(kubectl get deploy -n "$NAMESPACE" -o json | \
jq -r ".items[].spec.template.spec.containers[] | select(.image==\"$IMAGE\") | .image")
if [[ "$IMAGE" != *"@sha256:"* ]]; then
echo "[WARN] 容器使用了可变标签: $IMAGE"
fi
done
对于 Azure Kubernetes 环境,Microsoft Defender 提供内置的二进制偏移检测:
{
"alertType": "K8S.NODE_ImageBinaryDrift",
"severity": "Medium",
"description": "执行了原始容器镜像中不存在的二进制文件",
"remediationSteps": [
"调查二进制文件的来源和用途",
"检查容器是否已被入侵",
"从干净镜像重建容器",
"启用 readOnlyRootFilesystem"
]
}