Aqua容器安全解决方案_第1页
Aqua容器安全解决方案_第2页
Aqua容器安全解决方案_第3页
Aqua容器安全解决方案_第4页
Aqua容器安全解决方案_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Aqua容器安全解决方案

POC测试步骤

edvance

安领科技

2017-10-27

Version[1.0]

版权说明

包含于此篇文档中的信息属于商业或财务机密(或授权)信息。文档为安

领有限公司所专有,且只用于评估目的,除非被安领有限公司授权,否则

此文档的全部或者部分信息不得用于再版或者引用。

版本历史

日期版本描述

2017-10-271.0

内容

1.准备工作5

2.镜像扫描6

2.1白名单镜像...................................................6

2.2禁止未扫描镜像运行..........................................6

2.3镜像安装包的黑白名单........................................6

2.4自定义规则扫描镜像...........................................6

2.5包含敏感信息的镜像..........................................7

2.6结合JENKINS进行镜像扫描......................................7

3.威胁阻止9

3.1PROCESSLIMITS..................................................................................................9

3.2只允许LINK内容器互相通信....................................9

4.徽感信息管理10

4.1自纳管SECRET...............................................................................................10

4.2CYBERARK纳管SECRET....................................................................................10

5.容器运行限制12

5.1以指定用户运行容器..........................................12

5.2限制容器运行时的只读文件...................................13

5.3限制容器运行时的可执行命令.................................14

5.4限制CONTAINER运行时的进出网络...............................15

5.5黄金镜像一保证CONTAINER不对容器内任何文件进行修改..........16

5.6限制CONTAINER不以特权模式运行...............................17

5.7限制CONTAINER挂我的数据卷..................................17

5.8自主学习并生成安全规则.....................................18

5.9限制容器运行时使用的资源及进程数...........................19

5.10环境变量加密...............................................20

6.网络控制21

6.1容器与HOST之间网络限制.....................................21

6.2容器与容器间的网络限制.....................................21

7.主机权限管控23

7.1角色权限管控...............................................23

7.2自定义R01E角色.............................................23

7.3通过IMAGE的LABEL来分发权限.................................24

8.其他25

8.1ROOTPLEASE容器修改主机配置文件..............................25

8.2私有REGISTRY搭建............................................25

8.3SWARM部署AQUAAGENT...............................................................................26

8.4RANCHER部署AQUAAGENT.............................................................................27

1.准备工作

在DockerHost主机上安装完AquaServer环境后,可执行以下步骤将测试用镜像及配置文件导入到环境

中。

1.将optfolder下的文件夹上传到DockerHost的/opt路径下

2.通过df-h命令确保测试主机/var路径挂载磁盘剩余空间大于10G,否则导入镜像会导致磁盘满

3.将测试镜像上传到DockerHost主机内,并通过dockerloadstar包路径,来导入测试镜像

4.登录AquaWeb端>>lmages»Addimages»localengine,手动逐一添加步骤2里导入的镜像文件。

除了imagescan/labeltest外都导入,此镜像将用于未扫描镜像测试。

注:如果不想逐一添加也可配置自动拉取本地镜像,System»lntegrations»LocalEngine〉〉勾选

AutomaticallyPullNewImages。这样AquaAgent就会在配置的指定拉取时间拉取本地镜像进行扫描。

国Audit

Integrations

Administration

ModifyRegistry:LocalEngine

合Policiesv

RegistryTypeDockerEngine

ImageAssurance

Endpointunlx-y/ZVar/run/dockersock

ThreatMhigation

RuntimeProfilesegsix初var/run/dockersock

ContainerFlrewail

UserAccessControlQAutomat»ca»yPullNewImajes

Whenenabled,theserverwillautomaticallypullnewrepoartones/ima9esfromtheregistryevey

mSecrets

目Hosts

DailyPullTime03:00

QCompliance<

紫Systemv

Integrations

labels

AquaGatewaysSaveChangesICancel

Users

Settings

5.登录AquaWebj^»Systerr)»Settings,点击Import按钮导入aqua_settings.json文件

6.通过groupadddocker添力口docker用户组

2.镜像扫描

2.1白名单镜像

1.通过ImageAssurance内配置,首先设置DisallowImagesbyCVESeverity,则执行

dockerrun-v/:/hostOS-i-tchrisfosterelli/rootplease失败

2.通过ImagiAssurance内配置,设置chrisfcsterHIi/rcctpleasa镜像为WhiWlistlmagp,则执行

dockerrun-v/:/hostOS-i-tchrisfosterelli/rootplease成功

2.2禁止未扫描镜像运行

1.通过ImageAssurance内配置,设置BlockUnregisteredImages,同时对应label(key=vaule)的镜像可

以做例外,如下图

BlockUnregisteredImages〜>

QEnablebtockunregisteredimages

Donotallowtoruncontainersfromunauthorizedimages

Whitdistimageswiththefollowingpnfix(es):

+Add

Whitdistimageswiththefollowingdockb

+Add

DOCKERLABEL

license=GPLv20

2.执行dockerrun-dimagescan/labeltest未扫描镜像可以正常运行,因为此镜像已打了license=GPLv2

的label,如果将此例外去?■即被禁止运行

2.3镜像安装包的黑白名单

1.通过ImageAssurance内,设置PackageBlacklist,禁止包含黑名单Package的镜像运行,可填写

python包,所有版本,则执行dockerrun-dcentos被禁止

2.通过ImageAssurance内,设置PackageWhitelist,可以设置镜像必须包含的安装程序包,如未包含

白名单内安装包,镜像将被禁止执行,可填写python包,所有版本,则执行dockerrun-dalpine被

禁止

2.4自定义规则扫描镜像

1.通过ImageAssurance内,设置CustomChecks可以使用自定义规则脚本进行扫描,脚本返回0则禁

用镜像。使用默认SSH包检查脚本即可,任何安装了SSH包的镜像都将被禁用

CustomChecks

QEnablecustomchecks

Anyshellscriptthatresultsinexit-code10,willflagtheimageasdisallowed.

Note:Whenyoueditandsavecustomchecks,youneedtorescantheimagesmanuallyto

enforcethenewchecks.

>ManageScripts

Thispokeywillbeappliedtoimagesthat

containthefollowingword.SpecifythescriptthatwIBbeusedforthe

customcheck:_______

***willassignthepolicytoallimages.

Add

Example-nginx

PatternScript

*check_sshd_installed0

2.在Images页面将imagescan/centoswithssh镜像Rescan重新扫描

3.执行dockerrun-it-rmimagescan/centoswithssh/bin/bash被禁止,因为此镜像安装了SSH包被

Disallow

2.5包含敏感信息的镜像

1.在System»Settings内,勾选ScanOptions1的Scansensitivedatainimages并Save

2.通过ImageAssurance内,设置DisallowImageswithSensitiveData,可以设置包含敏感信息(比如

PrivateRSAkey)的镜像被禁止运行

3.执行dockerrun-dimagescan/sensitivedata失败,因为其/opt路径下有id_rsa的PrivateRSAkey

2.6结合Jenkins进行镜像扫描

1.在Dockerhost主机上执行:

chmod-R777/opt/jenkins

dockerrun-d\

-uroot\

-v/opt/jenkins:/var/jenkins_home\

-v/var/run/docker.sock:/var/run/docker.sock\

-v$(whichdocker):/usr/bin/docker:ro\

-v/usr/lib64/libsystemd-journal.so.O:/usr/lib/x86_64-linux-gnu/libsystemd-journal.so.O\

-v/usr/lib64/libsystemd-idl28.so.0:/usr/lib/x86_64-lirux-gnu/libsystemd-idl28.so.0\

-v/usr/lib64/libdevmapper.so.l.02:/usr/lib/x86_64-linux-gnu/libdevmapper.so.l.02\

-v/usr/lib64/libgcrypt.so.ll:/usr/lib/x86_64-linux-gnu/libgcrypt.so.ll\

-v/ui>r/lib64/libdw.bo.l:/ubr/lib/x86_64-liriux-griu/libdw.j>o.l\

-v/usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7\

-p9090:8080\

-namejenkins\

--restart=always\

jenkins

2.生成的ienkins可通过http:〃(DockerHostlP>:9090进入,用户名为admin,密码为password。

3.进入ManageJenkins»ConfigureSystem将以下各项按实际情况填写,其中的IP地址都是docker

host测试主机的。

4.点击test项目>>manage,谀置项目要扫描的镜像名及其所属Registry名,此处Registry名为在Aqua

Server»System»lntegrations»Registry里进行绑定的名字,

Imagetoscan:

OLocalimage每

@Hostedimage®

Hidebaseimagevulnecabilries

5.最后运行test项目的build即可,里面已添加了Aqua镜像三描的步骤,从Consoleoutput杳看扫描

执行结果

3.威胁阻止

3.1Processlimits

1.通过ThreatMitigation内,勾选ForkGuadr卜.的EnableForkBombProtection,设置Processlimit为

10后保存

2.执行dockerrun-dthreattest/process,里面已开启了超过10个进程,多余进程会被禁止生成

3.2只允许Link内容器互相通信

1.执行以下命令生成两个容器:

dockerrun-it-v/opt/aquatest:/usr/share/nginx/html:ro-p80:80-d-namenginxweb\

networktest/nginxweb

dockerrun-it-d-nametestcentos

生成后进入test容器可以curl到nginx发布的网页

dockerexec-ittest/bin/bash

curlhttp:〃<dockerhostip>

2.在ThreatMitigation»BlockNetworkingBetweenunlinkedContainers下勾选BlockNetwork保存后,

再次进入test容器无法curl到网页

3.重新生成新的带link的centos访问容器即可curl到网页

dockerrun-it-d-linknginxv/eb:testlinkcentos

4.敏感信息管理

4.1自纳管Secret

1.通过之前的配置导入,前台网页Secret内应已有一个aqua.password

2.运行dockerrun-it-d-namesecretsecrettest/static_password

此容器己将aqua.passwcrd作为Password环境变量打入c用户执行dockerinspectsecret|grpp

password只会看到Password={aqua.password),看不到真实值

3.用户执行dockerexec-itsecret/bin/bash进入容器执行env命令后,可看到真实值。同时用户如在

前台网页端对aqua.password的值进行更改后,容器内对应值也会动态刷新到,不需要重启容器

4.2CyberArk纳管Secret

1.Aqua可以CyberArk的CCP进行绑定配置,通过其获取CyberArk平台内保存的密码.通过

System»lntegrations»SecretKeyStores,点击AddSecretKeyStore进行绑定,其中的Test

Connection按钮没有任何实际作用。

ModifyKeyStore:CCP(CyberArkEnterprisePasswordVault)

QEnabled

*ConnectionURL

https:〃192.168.195/

*AppID

AIMWebService2

♦Safe

Windows

PullInterval(minutes)①

1

Labels®

TestConnection

ConnecitionURL:CCP的访问地址,只需要填写IP地址,不需要后缀

AppID:CCP使用的AppID

Safe:获取密码账号所/Safe

PullInterval:定期刷新时间(测试下来没有实际功能,即无法将新值自动刷新到容器内)

2.在绑定的CyberarkVault内,创建WindowsSafe,配置CCP相关APPID和Provider用户对此Safe有

获取密码权限,同时创建•个测试账号,账号名为CyberArkVaultTest

3.在Aqua网页端>>Secrets»AddNewSecret,在Store处选择步骤一新建的CyberArkStore名,在

Name处填写Vault内账号名,即CyberArkVaultTest

Secrets>NewSecret

CCP(CyberArkEnterprisePasswordVaUH)

4.点击Save的同时,Aqua会尝试获取密码,如有报错会直接在页面内显示出来

5.运行dockerrunitdnamesecretsccrcttcst/static_password

此容器已将CCP.CyberArkVaultTest作为CyberArkPassword环境变量打入。用户执行dockerinspect

secret|grepCyber只会看到CyberArkPassword={CCP.CyberArkVaultTest},看不到真实值

6.用户执行dockerexec-itsecret/bin/bash进入容器执行env命令后,可看到真实值。

5.容器运行限制

5.1以指定用户运行容器

当运行容器时没以也参数指定运行用户环境时,Docker默认将以root用户运行容器,最高用户权限所

带来的风险可想而知。用户可通过AquaSecurity中的Runtimeprofile来限制容器运行时只能以当前Host

用户的UID和GID来运行

IdentityInsideTheContainer

Allowcontainertorunwithanyuser

•Runinowner'susercontext.UsetheUIDandGIDoftheuserwhoexecutedthecontainer

Restrictcontainertorunwithspecificusers

Preventrootuserfromrunningcontainers

1.不加-u参数运行容器后,得到的UID和GID为Host当前用户docker

dockerdocxker5dockerrun-it--nanetestruntimecentos/bin/bash

WARNING:Error叮/home/docker/.docker/config.json:permissiondenied

WARNING:YourkerneldoesnotsupportswapUnitcapabilitiesorthecgroup1snotmounted,neworyHaltedwithoutswap.

bash:/root/.bashrc二:P_e_rm_issi-on-de.nied

iid-lOOO(docker)gid-1000(docker)^roups-1000(docker),4(adn),24(cdron),27(sudo),30(tape),46(plugdev)t110(lxd),115(lpadmin),116(sambashare)

2.同时我们可以限制容器不以root用户运行。

IdentityInsideTheContainer

•Allowcontainertorunwilhanyuser

Runinowner'susercontext.UsetheUIDandGIDoftheuserwhoexecutedthecontainer

Restrictcontainertorunwithspecificusers

QPreventrootuserfromrurningcontainers

3.当以root用户运行容器时,得至ljPermissionDenied的报错,同时AquaSecurity内也有对应

Block日志。运彳亍命令为dockerrun-itruntime/runuser/bin/sh

root@aqua~]#dockerrun-itruntime/runuser/bin/sh

ernrissiondenied

r*ArlVfllib/iiiH_

Containerelastic_thompson'triedtochangeuidtouser(0)

imageruntime/runusef:atest

Contaner:eas*c.thompson

ConxanerID:d304266-a610

User:roo:

ProcessID:1

Runtme3rofileRuntr-e_Runuser

ReasonforBlockUnauthorizeduse,blockedbyrun:meprofie

5.2限制容器运行时的只读文件

1.用户通常希望在Container运行时不要对容器的一些关键系统或程序文件进行修改,比如/etc、

/bin目录等。AquaSecurit/可以通过RuntimeProfile来做到这点

Read-OnlyDirectoriesandFiles

Speedydirectororftes®oe^srictedBSreadcZy

Direct©7menuj£endMmslash/

+Add

READONLYDIRECTORYORFILE

~/etc/0

/bin/0

ExcludeList

Specrfydirectooescrfies:ha:willoeexd'jdedfremtheIts:aoo.w

4-Add

2.设置对/etc目录的只读后,以root用户运行容器仍旧无法对/etc目录下的任何文件进行修改。

运行命令为dockerrun-itruntime/file/bin/sh,之后vi/etc/hostname修改文件会有如下报错

reerror:operationnotpermitted!

Userroot-performed7bin/busybox/etc/hostname

Image:runtime,-fie:ates:

Container:AFA二也小m

ContainerID:002567-edCOD

US«r:fOOX

UserId:0

EffectiveUser:root

EffectiveUserID:0

Category:2

Action:open

Resource:exc/hostname

ResourceDigest:

Process:

ProcessID:6

Runt*reProfie:Runtm«_PeasOniyFIe

ReasonforBlockjnauthonzedactonDeckedDyruntmeprofile

5.3限制容器运行时的可执行命令

i.限制用户在容器运行时的可执行命令是十分重要的,其能有效避免一些误操作所带来的严重后

果。AquaSecurity可通过Runtimeprofile里的AllowedExecutables来设置容器运行时的可执行

命令白名单,如下图我们只允许执行/bin/bash命令。

AllowedExecutables

Separateallowedexecutablesforsuperandnon-supefusers

+Add

EXECUTABLEFILE

bin/besh0

bin/sh0

Ifempv.allexecuxableswi:beallc.ved

2.当用户试图执行Is命令时,得至Permissiondenied的报港,同时AquaSecurity处也有对应

Block日志。

[root@aquadockerrun-itruntime/command/bin/bash

bash:/usr/libexec/grepconf.sh:/bin/sh:badinterpreter:Permissiondeni®

bash:/usr/bin/tty:Permissiondenied

[root@533e4e669fc8I/]#Is

bash:/usr/bin/ls:Permissiondenied

[root@533e4e669fc8/]#

3.当用户在AllowedExecutables处加上Is命令后,此命令即可正常在容器内执行。即使sh脚本

中有相关命令也同样被禁止

HSeparateallowedexecutablesforsuperandnon-superusers

+Add

EXECUTABLEFILE

/bti/bash0

/bin/sh0

/bin/ls0

Ifempty,allexecutableswillbeallowed

***»«*•••,••一・,・*・・・,■••=・■・•*■*・、*・•①~・・・=、•

[root©533e4e669fc8.q*Is

anaconda-post.logbindevetchomeliblib64lost+foundmediamntoptprocrootrunsbinsrvsystmpusrvar

[root@533e4e669fc8/]#

5.4限制Container运行时的进出网络

1.对于Container运行时的对外通信,用户可以限制其进出网络,从而隔绝容器不必要的网络通

信。用户可以在AquaSecurity内Runtimeprofile的Network选项禁止对应镜像生成的Container

的对外通信。

Network

Denyinboundnetwork

QDenyoutbound旌-方产

2.这样当Container内部尝试与外部网络通信时,就会失败。同时AquaSecurity也会记录对应的

Block事件。测试命令为dockerrun-itruntime/network/bin/sh

一•J••»・•一•

/#ping3

PING192168.200.33(3):56databytes

AC

—3pingstatistics—

120packetstransmitted,0packetsreceived,100%packetloss

/*

Userroot'performed11921682003342192

Image:runtrreretwork:ares:

Container:sleepy.kepler

ContainerID:73c7679d9481

User:root

UserId:0

EffectiveUserID:0

Category:network

Action:connect

IPAddress:19216820033

Port:42192

Process:

ProcessID:933

RuntmeProfeRumEjNsvork

ReasonforBlockNetworkconnectont/ockedbyruntimeprofile

5.5黄金镜像一保证Container不对容器内任何文件进行修改

1.针对一些黄金镜像,用户不希望容器对其进行任何修改。则我们可以在AquaSecurity的

runtimeprofile中的ContainerEngineControls中勾选Read-onlyrootfilesystemo

ContainerEngineControls

Thefollowingcontrolswilbeenforcedwithanycontainerexecution.Notethesecontrolswillalsobeenforcedonaudit-onlyhosts.

3Read-onlyrootfilesystem①

Nonewprivileges®

Seccompprofile:

I________________________________________________________________________________________________z]

DropCapabilities:

selectcapabilitytodrop...

2.用户尝试修改、新增、删除容器内的文件报错,无法进行增删改。测试语句dockerrun・it

runtime/goldenimage/bin/sh

/etc#touchtest

touch:test:Read-onlyfilesystem

/art-a

—>PackageIzo.x86_640:2.06-8.el7willbeerased

——>Packagepython-decorator.noarch0:3.4.0-3.el7willbeerased

-->ProcessingDependency:python-decoratorforpackage:python-firewall-0.4.3.2-8.1.el7_3.3.noa

—>Packagepython-slip.noarch0:0.4.0-2.el7willbeerased

E45:'readonly'opticxiisset(add!tooverride)

5.6限制Container不以特权模式运行

1.容器运行时如果加上‘-privileged'参数,即会以特权模式运行,可访问Host上的所有设备,

此容器几乎与主机上其他运行的进程一样可访问主机资源,这将带来十分高的安全风险。所以

我们可以通过AquaRuntimeProfile里的配置禁用特权模式运行容器。

LockdownvX

Preventrunningexecutablenotinoriginalimage

Preventrunningcontainerwhenimageparametersarechanged①

C3Preventrunningwithelevatedprivileges(e.g.-privileged,-network:host)①

2.设置后,当用户再次想以特权模式运行容器时得到'Blockedbvruntimeprofile'的报错,同时

AquaAudit日志里也有相关Block信息,测试命令为dockerrun-it-privileged

runtime/nonprivileged/bin/sh。

[root@aqua~]#dockerrun-一pr~iv,leged"]runtime,'nonpr「vi~leged/bin/sh

docker:Errorresponsefromdaemon:[Aqua-security]YOUdonothavepermissiontoexecutethiscommand,

see'dockerrun--help'.

v08Nov05:USOPM*BlockUserroocrancommand-ce”onnostaqua

dockercreateruntim«/nonpnvihg«d:late3t

Host:aqud

imageName:runtfne/nonprtvle9eclaiesr

UserAccewRule:Runtime.Nonprivile^ec

ReasonforBlockOontawextendedpri»legeswLeWocKedbyruntimeprofile

5.7限制Container挂载的数据卷

1.挂载数据卷是Container容器间分享永久数据的一种方式,这些永久数据通常都会影响应用运

行时的配置,一些误操作的写入可能会导致Container内的应用无法正常运行,所以针对挂载

数据卷的限制也是十分必要的。我们可以通过AquaRuntimeProfile里的Allowedvolumes配置

来指定Container运行时允许挂载的数据卷及其写入读取权限。

Volumes

Allowedvolumes:

ReadWrite,+Add

MountPathAccess

/daxa/caxareaoonly0

2.当用户想要挂载其他数据卷时,得到‘Blockedbyruntirreprofile'的报错。同样当用户想要以

ReadWrite权限挂载时也会报错,运行语句为dockerrun-rm-it-v/data:/dataruntime/volumes

/bin/sho必须指定ro权限才能正确挂载,,运行语句为dockerrun-rm-it-v/data:/da:a:ro

runtime/volumes/bin/sh。

[root@aquadockerrun--rm-it-vuntime/volumes/bin/sh

docker:Errorresponsefromdaemon:[Aquasecurity]YOUdonothavepermissiontoexecutethiscommand.centaln<

See'dockerrun-help".

[root@aquadockerrun--rm-it-v/data:/data:roruntime/volumes/bin/sh

5.8自主学习并生成安全规则

1.有时我们自定义的规则无法满足一些复杂的Container运行情景,此时我们可以让Aqua进行自

主学习,其会根据指定image生成的Container运行情况,自动生成对应的Container运行规则。

如下图,我们在AquaSystem及image级别开启了自动Profile生成。

AutomaticProfilingOptions

QProfileallimagesautomatically①

Enforcementmode①:EnforceAuditOnly

Learningphaseduration(inmnutes):10

Learningphaseduration(inexecutions):2

・UseDefault

>centos

QProfileAutomatically

>jenkins

UseExisting

>jiihiintii

CreateNew

>kam/pingUseProfiler

>leam/tutorial

>nginx071

7nginxG5Aqia.defaul

nginxlatest0(approved)。310

nginxvi©3A10AOSelectLab(

nginxvltestaqua①3A10AO

2.待配置的10分钟学习时间过后,Aqua即会根据之前Container运行的情况,自动生成对应的

运行规则,用户可在此基础上再进行自定义调整。

,NameMnxIoolwn9iHeAvailableProfiUControh

Oeser0MAutomaticallygeneratedbyAqua

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论